Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: skip reconfiguration if tracer already configured #633

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions internalv2compat/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package internalv2compat

import (
"os"
"sync"
"sync/atomic"

"go.uber.org/zap"
Expand Down Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions tracing/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
redloaf marked this conversation as resolved.
Show resolved Hide resolved
"github.com/reddit/baseplate.go/log"
"github.com/reddit/baseplate.go/mqsend"
"github.com/reddit/baseplate.go/randbp"
Expand Down Expand Up @@ -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 {
Expand Down