Skip to content

Commit ec87e21

Browse files
committed
logtail: delete unused code from old way to configure zstd
Updates #cleanup Change-Id: I666ecf08ea67e461adf2a3f4daa9d1753b2dc1e4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent e2586bc commit ec87e21

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

cmd/tsconnect/wasm/wasm_js.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ func newIPN(jsConfig js.Value) map[string]any {
9090
c := logtail.Config{
9191
Collection: lpc.Collection,
9292
PrivateID: lpc.PrivateID,
93-
// NewZstdEncoder is intentionally not passed in, compressed requests
94-
// set HTTP headers that are not supported by the no-cors fetching mode.
93+
94+
// Compressed requests set HTTP headers that are not supported by the
95+
// no-cors fetching mode:
96+
CompressLogs: false,
97+
9598
HTTPC: &http.Client{Transport: &noCORSTransport{http.DefaultTransport}},
9699
}
97100
logtail := logtail.NewLogger(c, log.Printf)

logtail/logtail.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ const (
4747
CollectionNode = "tailnode.log.tailscale.io"
4848
)
4949

50-
type Encoder interface {
51-
EncodeAll(src, dst []byte) []byte
52-
Close() error
53-
}
54-
5550
type Config struct {
5651
Collection string // collection name, a domain name
5752
PrivateID logid.PrivateID // private ID for the primary log stream
@@ -66,9 +61,6 @@ type Config struct {
6661
Buffer Buffer // temp storage, if nil a MemoryBuffer
6762
CompressLogs bool // whether to compress the log uploads
6863

69-
// Deprecated: Use CompressUploads instead.
70-
NewZstdEncoder func() Encoder // if set, used to compress logs for transmission
71-
7264
// MetricsDelta, if non-nil, is a func that returns an encoding
7365
// delta in clientmetrics to upload alongside existing logs.
7466
// It can return either an empty string (for nothing) or a string
@@ -162,9 +154,6 @@ func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
162154
}
163155
l.SetSockstatsLabel(sockstats.LabelLogtailLogger)
164156
l.compressLogs = cfg.CompressLogs
165-
if cfg.NewZstdEncoder != nil {
166-
l.zstdEncoder = cfg.NewZstdEncoder()
167-
}
168157

169158
ctx, cancel := context.WithCancel(context.Background())
170159
l.uploadCancel = cancel
@@ -192,7 +181,6 @@ type Logger struct {
192181
sentinel chan int32
193182
clock tstime.Clock
194183
compressLogs bool
195-
zstdEncoder Encoder
196184
uploadCancel func()
197185
explainedRaw bool
198186
metricsDelta func() string // or nil
@@ -273,9 +261,6 @@ func (l *Logger) Shutdown(ctx context.Context) error {
273261
io.WriteString(l, "logger closing down\n")
274262
<-done
275263

276-
if l.zstdEncoder != nil {
277-
return l.zstdEncoder.Close()
278-
}
279264
return nil
280265
}
281266

@@ -379,15 +364,9 @@ func (l *Logger) uploading(ctx context.Context) {
379364
body := l.drainPending()
380365
origlen := -1 // sentinel value: uncompressed
381366
// Don't attempt to compress tiny bodies; not worth the CPU cycles.
382-
if (l.compressLogs || l.zstdEncoder != nil) && len(body) > 256 {
383-
var zbody []byte
384-
switch {
385-
case l.zstdEncoder != nil:
386-
zbody = l.zstdEncoder.EncodeAll(body, nil)
387-
default:
388-
zbody = zstdframe.AppendEncode(nil, body,
389-
zstdframe.FastestCompression, zstdframe.LowMemory(true))
390-
}
367+
if l.compressLogs && len(body) > 256 {
368+
zbody := zstdframe.AppendEncode(nil, body,
369+
zstdframe.FastestCompression, zstdframe.LowMemory(true))
391370

392371
// Only send it compressed if the bandwidth savings are sufficient.
393372
// Just the extra headers associated with enabling compression

0 commit comments

Comments
 (0)