mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
logtail: delete unused code from old way to configure zstd
Updates #cleanup Change-Id: I666ecf08ea67e461adf2a3f4daa9d1753b2dc1e4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
e2586bc674
commit
ec87e219ae
@ -90,8 +90,11 @@ func newIPN(jsConfig js.Value) map[string]any {
|
|||||||
c := logtail.Config{
|
c := logtail.Config{
|
||||||
Collection: lpc.Collection,
|
Collection: lpc.Collection,
|
||||||
PrivateID: lpc.PrivateID,
|
PrivateID: lpc.PrivateID,
|
||||||
// NewZstdEncoder is intentionally not passed in, compressed requests
|
|
||||||
// set HTTP headers that are not supported by the no-cors fetching mode.
|
// Compressed requests set HTTP headers that are not supported by the
|
||||||
|
// no-cors fetching mode:
|
||||||
|
CompressLogs: false,
|
||||||
|
|
||||||
HTTPC: &http.Client{Transport: &noCORSTransport{http.DefaultTransport}},
|
HTTPC: &http.Client{Transport: &noCORSTransport{http.DefaultTransport}},
|
||||||
}
|
}
|
||||||
logtail := logtail.NewLogger(c, log.Printf)
|
logtail := logtail.NewLogger(c, log.Printf)
|
||||||
|
@ -47,11 +47,6 @@
|
|||||||
CollectionNode = "tailnode.log.tailscale.io"
|
CollectionNode = "tailnode.log.tailscale.io"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Encoder interface {
|
|
||||||
EncodeAll(src, dst []byte) []byte
|
|
||||||
Close() error
|
|
||||||
}
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Collection string // collection name, a domain name
|
Collection string // collection name, a domain name
|
||||||
PrivateID logid.PrivateID // private ID for the primary log stream
|
PrivateID logid.PrivateID // private ID for the primary log stream
|
||||||
@ -66,9 +61,6 @@ type Config struct {
|
|||||||
Buffer Buffer // temp storage, if nil a MemoryBuffer
|
Buffer Buffer // temp storage, if nil a MemoryBuffer
|
||||||
CompressLogs bool // whether to compress the log uploads
|
CompressLogs bool // whether to compress the log uploads
|
||||||
|
|
||||||
// Deprecated: Use CompressUploads instead.
|
|
||||||
NewZstdEncoder func() Encoder // if set, used to compress logs for transmission
|
|
||||||
|
|
||||||
// MetricsDelta, if non-nil, is a func that returns an encoding
|
// MetricsDelta, if non-nil, is a func that returns an encoding
|
||||||
// delta in clientmetrics to upload alongside existing logs.
|
// delta in clientmetrics to upload alongside existing logs.
|
||||||
// It can return either an empty string (for nothing) or a string
|
// It can return either an empty string (for nothing) or a string
|
||||||
@ -162,9 +154,6 @@ func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
|
|||||||
}
|
}
|
||||||
l.SetSockstatsLabel(sockstats.LabelLogtailLogger)
|
l.SetSockstatsLabel(sockstats.LabelLogtailLogger)
|
||||||
l.compressLogs = cfg.CompressLogs
|
l.compressLogs = cfg.CompressLogs
|
||||||
if cfg.NewZstdEncoder != nil {
|
|
||||||
l.zstdEncoder = cfg.NewZstdEncoder()
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
l.uploadCancel = cancel
|
l.uploadCancel = cancel
|
||||||
@ -192,7 +181,6 @@ type Logger struct {
|
|||||||
sentinel chan int32
|
sentinel chan int32
|
||||||
clock tstime.Clock
|
clock tstime.Clock
|
||||||
compressLogs bool
|
compressLogs bool
|
||||||
zstdEncoder Encoder
|
|
||||||
uploadCancel func()
|
uploadCancel func()
|
||||||
explainedRaw bool
|
explainedRaw bool
|
||||||
metricsDelta func() string // or nil
|
metricsDelta func() string // or nil
|
||||||
@ -273,9 +261,6 @@ func (l *Logger) Shutdown(ctx context.Context) error {
|
|||||||
io.WriteString(l, "logger closing down\n")
|
io.WriteString(l, "logger closing down\n")
|
||||||
<-done
|
<-done
|
||||||
|
|
||||||
if l.zstdEncoder != nil {
|
|
||||||
return l.zstdEncoder.Close()
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,15 +364,9 @@ func (l *Logger) uploading(ctx context.Context) {
|
|||||||
body := l.drainPending()
|
body := l.drainPending()
|
||||||
origlen := -1 // sentinel value: uncompressed
|
origlen := -1 // sentinel value: uncompressed
|
||||||
// Don't attempt to compress tiny bodies; not worth the CPU cycles.
|
// Don't attempt to compress tiny bodies; not worth the CPU cycles.
|
||||||
if (l.compressLogs || l.zstdEncoder != nil) && len(body) > 256 {
|
if l.compressLogs && len(body) > 256 {
|
||||||
var zbody []byte
|
zbody := zstdframe.AppendEncode(nil, body,
|
||||||
switch {
|
zstdframe.FastestCompression, zstdframe.LowMemory(true))
|
||||||
case l.zstdEncoder != nil:
|
|
||||||
zbody = l.zstdEncoder.EncodeAll(body, nil)
|
|
||||||
default:
|
|
||||||
zbody = zstdframe.AppendEncode(nil, body,
|
|
||||||
zstdframe.FastestCompression, zstdframe.LowMemory(true))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only send it compressed if the bandwidth savings are sufficient.
|
// Only send it compressed if the bandwidth savings are sufficient.
|
||||||
// Just the extra headers associated with enabling compression
|
// Just the extra headers associated with enabling compression
|
||||||
|
Loading…
Reference in New Issue
Block a user