diff --git a/internalv2compat/compat.go b/internalv2compat/compat.go index 7a113d400..38c5575a7 100644 --- a/internalv2compat/compat.go +++ b/internalv2compat/compat.go @@ -8,6 +8,7 @@ package internalv2compat import ( "os" + "sync" "sync/atomic" "go.uber.org/zap" @@ -63,3 +64,19 @@ type IsHTTP interface { type IsThrift interface { isThrift() } + +var v2Tracing struct { + sync.Mutex + enabled bool +} + +func SetV2TracingEnabled(enabled bool) { + v2Tracing.Lock() + defer v2Tracing.Unlock() + v2Tracing.enabled = enabled +} +func V2TracingEnabled() bool { + v2Tracing.Lock() + defer v2Tracing.Unlock() + return v2Tracing.enabled +} diff --git a/tracing/tracer.go b/tracing/tracer.go index 77e64baac..a5234c3d6 100644 --- a/tracing/tracer.go +++ b/tracing/tracer.go @@ -12,6 +12,8 @@ import ( "github.com/opentracing/opentracing-go" "github.com/reddit/baseplate.go/detach" + //lint:ignore SA1019 This library is internal only, not actually deprecated + "github.com/reddit/baseplate.go/internalv2compat" "github.com/reddit/baseplate.go/log" "github.com/reddit/baseplate.go/mqsend" "github.com/reddit/baseplate.go/randbp" @@ -82,6 +84,10 @@ type Tracer struct { // If it fails to do so, UndefinedIP will be used instead, // and the error will be logged if logger is non-nil. func InitGlobalTracer(cfg Config) error { + if internalv2compat.V2TracingEnabled() { + cfg.Logger.Log(context.Background(), `v2 tracing is enabled; skipping v0 tracer configuration`) + return nil + } var tracer Tracer if cfg.QueueName != "" { if cfg.MaxQueueSize <= 0 || cfg.MaxQueueSize > MaxQueueSize {