mirror of https://github.com/tailscale/tailscale/
feature/logtail: pull logtail + netlog out to modular features
Removes 434 KB from the minimal Linux binary, or ~3%. Primarily this comes from not linking in the zstd encoding code. Fixes #17323 Change-Id: I0a90de307dfa1ad7422db7aa8b1b46c782bfaaf7 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/17316/head
parent
e466488a2a
commit
11b770fbc9
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build ts_omit_logtail
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasLogTail is whether the binary was built with support for modular feature "upload logs to log.tailscale.com (debug logs for bug reports and also by network flow logs if enabled)".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_logtail" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasLogTail = false
|
||||
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build !ts_omit_logtail
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasLogTail is whether the binary was built with support for modular feature "upload logs to log.tailscale.com (debug logs for bug reports and also by network flow logs if enabled)".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_logtail" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasLogTail = true
|
||||
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build ts_omit_netlog
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasNetLog is whether the binary was built with support for modular feature "Network flow logging support".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_netlog" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasNetLog = false
|
||||
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build !ts_omit_netlog
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasNetLog is whether the binary was built with support for modular feature "Network flow logging support".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_netlog" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasNetLog = true
|
||||
@ -0,0 +1,65 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package logtail
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"tailscale.com/tstime"
|
||||
"tailscale.com/types/logid"
|
||||
)
|
||||
|
||||
// DefaultHost is the default host name to upload logs to when
|
||||
// Config.BaseURL isn't provided.
|
||||
const DefaultHost = "log.tailscale.com"
|
||||
|
||||
const defaultFlushDelay = 2 * time.Second
|
||||
|
||||
const (
|
||||
// CollectionNode is the name of a logtail Config.Collection
|
||||
// for tailscaled (or equivalent: IPNExtension, Android app).
|
||||
CollectionNode = "tailnode.log.tailscale.io"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Collection string // collection name, a domain name
|
||||
PrivateID logid.PrivateID // private ID for the primary log stream
|
||||
CopyPrivateID logid.PrivateID // private ID for a log stream that is a superset of this log stream
|
||||
BaseURL string // if empty defaults to "https://log.tailscale.com"
|
||||
HTTPC *http.Client // if empty defaults to http.DefaultClient
|
||||
SkipClientTime bool // if true, client_time is not written to logs
|
||||
LowMemory bool // if true, logtail minimizes memory use
|
||||
Clock tstime.Clock // if set, Clock.Now substitutes uses of time.Now
|
||||
Stderr io.Writer // if set, logs are sent here instead of os.Stderr
|
||||
StderrLevel int // max verbosity level to write to stderr; 0 means the non-verbose messages only
|
||||
Buffer Buffer // temp storage, if nil a MemoryBuffer
|
||||
CompressLogs bool // whether to compress the log uploads
|
||||
MaxUploadSize int // maximum upload size; 0 means using the default
|
||||
|
||||
// MetricsDelta, if non-nil, is a func that returns an encoding
|
||||
// delta in clientmetrics to upload alongside existing logs.
|
||||
// It can return either an empty string (for nothing) or a string
|
||||
// that's safe to embed in a JSON string literal without further escaping.
|
||||
MetricsDelta func() string
|
||||
|
||||
// FlushDelayFn, if non-nil is a func that returns how long to wait to
|
||||
// accumulate logs before uploading them. 0 or negative means to upload
|
||||
// immediately.
|
||||
//
|
||||
// If nil, a default value is used. (currently 2 seconds)
|
||||
FlushDelayFn func() time.Duration
|
||||
|
||||
// IncludeProcID, if true, results in an ephemeral process identifier being
|
||||
// included in logs. The ID is random and not guaranteed to be globally
|
||||
// unique, but it can be used to distinguish between different instances
|
||||
// running with same PrivateID.
|
||||
IncludeProcID bool
|
||||
|
||||
// IncludeProcSequence, if true, results in an ephemeral sequence number
|
||||
// being included in the logs. The sequence number is incremented for each
|
||||
// log message sent, but is not persisted across process restarts.
|
||||
IncludeProcSequence bool
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_logtail
|
||||
|
||||
package logtail
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
tslogger "tailscale.com/types/logger"
|
||||
"tailscale.com/types/logid"
|
||||
)
|
||||
|
||||
// Noop implementations of everything when ts_omit_logtail is set.
|
||||
|
||||
type Logger struct{}
|
||||
|
||||
type Buffer any
|
||||
|
||||
func Disable() {}
|
||||
|
||||
func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
|
||||
return &Logger{}
|
||||
}
|
||||
|
||||
func (*Logger) Write(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (*Logger) Logf(format string, args ...any) {}
|
||||
func (*Logger) Shutdown(ctx context.Context) error { return nil }
|
||||
func (*Logger) SetVerbosityLevel(level int) {}
|
||||
|
||||
func (l *Logger) SetSockstatsLabel(label any) {}
|
||||
|
||||
func (l *Logger) PrivateID() logid.PrivateID { return logid.PrivateID{} }
|
||||
func (l *Logger) StartFlush() {}
|
||||
|
||||
func RegisterLogTap(dst chan<- string) (unregister func()) {
|
||||
return func() {}
|
||||
}
|
||||
|
||||
func (*Logger) SetNetMon(any) {}
|
||||
@ -1,6 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_netlog && !ts_omit_logtail
|
||||
|
||||
// Package netlog provides a logger that monitors a TUN device and
|
||||
// periodically records any traffic into a log stream.
|
||||
package netlog
|
||||
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_netlog || ts_omit_logtail
|
||||
|
||||
package netlog
|
||||
|
||||
type Logger struct{}
|
||||
|
||||
func (*Logger) Startup(...any) error { return nil }
|
||||
func (*Logger) Running() bool { return false }
|
||||
func (*Logger) Shutdown(any) error { return nil }
|
||||
func (*Logger) ReconfigRoutes(any) {}
|
||||
Loading…
Reference in New Issue