Skip to content

Commit

Permalink
Merge pull request #669 from gfloyd/config-traceid-128bit
Browse files Browse the repository at this point in the history
Add config option to generate 64 bit root span IDs
  • Loading branch information
pschultz committed Jun 27, 2019
2 parents 22fa963 + 7970d11 commit 9c92965
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@

Thanks to [@murphymj25](https://github.com/murphymj25) for the patch.

* [PR #669](https://github.com/fabiolb/fabio/pull/669): Add option for downgrading tracing IDs to 64 bit

When tracing is enabled, fabio injected 128 bit root span IDs if necessary.
This can now be downgraded to 64 bit IDs by setting the new
`tracing.TraceID128Bit` option to false.

Existing 128 bit trace IDs in incoming requests are not affected by this
option and forwarded unchanged.

Thanks to [@gfloyd](https://github.com/gfloyd) for the patch.

### [v1.5.11](https://github.com/fabiolb/fabio/releases/tag/v1.5.11) - 25 Feb 2019

#### Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 9c92965

Please sign in to comment.