Skip to content

Commit

Permalink
Add config option to use 128 bit trace IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Floyd committed Jun 27, 2019
1 parent 22fa963 commit 7970d11
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/config.go
Expand Up @@ -175,6 +175,7 @@ type Tracing struct {
Topic string
SamplerRate float64
SpanHost string
TraceID128Bit bool
}

type AuthScheme struct {
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Expand Up @@ -100,5 +100,6 @@ var defaultConfig = &Config{
Topic: "Fabiolb-Kafka-Topic",
SamplerRate: -1,
SpanHost: "localhost:9998",
TraceID128Bit: true,
},
}
1 change: 1 addition & 0 deletions config/load.go
Expand Up @@ -204,6 +204,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.Tracing.Topic, "tracing.Topic", defaultConfig.Tracing.Topic, "OpenTrace Collector Kafka Topic")
f.Float64Var(&cfg.Tracing.SamplerRate, "tracing.SamplerRate", defaultConfig.Tracing.SamplerRate, "OpenTrace sample rate percentage in decimal form")
f.StringVar(&cfg.Tracing.SpanHost, "tracing.SpanHost", defaultConfig.Tracing.SpanHost, "Host:Port info to add to spans")
f.BoolVar(&cfg.Tracing.TraceID128Bit, "tracing.TraceID128Bit", defaultConfig.Tracing.TraceID128Bit, "Generate 128 bit trace IDs")
f.BoolVar(&cfg.GlobMatchingDisabled, "glob.matching.disabled", defaultConfig.GlobMatchingDisabled, "Disable Glob Matching on routes, one of [true, false]")

f.StringVar(&cfg.Registry.Custom.Host, "registry.custom.host", defaultConfig.Registry.Custom.Host, "custom back end hostname/port")
Expand Down
6 changes: 3 additions & 3 deletions trace/trace.go
Expand Up @@ -47,12 +47,12 @@ func CreateCollector(collectorType, connectString, topic string) zipkin.Collecto
return collector
}

func CreateTracer(recorder zipkin.SpanRecorder, samplerRate float64) opentracing.Tracer {
func CreateTracer(recorder zipkin.SpanRecorder, samplerRate float64, traceID128Bit bool) opentracing.Tracer {
tracer, err := zipkin.NewTracer(
recorder,
zipkin.WithSampler(zipkin.NewBoundarySampler(samplerRate, 1)),
zipkin.ClientServerSameSpan(false),
zipkin.TraceID128Bit(true),
zipkin.TraceID128Bit(traceID128Bit),
)

if err != nil {
Expand Down Expand Up @@ -93,7 +93,7 @@ func InitializeTracer(traceConfig *config.Tracing) {
// Create a new Zipkin Collector, Recorder, and Tracer
collector := CreateCollector(traceConfig.CollectorType, traceConfig.ConnectString, traceConfig.Topic)
recorder := zipkin.NewRecorder(collector, false, traceConfig.SpanHost, traceConfig.ServiceName)
tracer := CreateTracer(recorder, traceConfig.SamplerRate)
tracer := CreateTracer(recorder, traceConfig.SamplerRate, traceConfig.TraceID128Bit)

// Set the Zipkin Tracer created above to the GlobalTracer
opentracing.SetGlobalTracer(tracer)
Expand Down

0 comments on commit 7970d11

Please sign in to comment.