diff --git a/docs/config.yaml b/docs/config.yaml index 5afca479c39..eff5a7a6d3d 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -407,6 +407,8 @@ tracing: jaeger: # The address of the jaeger-agent where spans should be sent to local_agent_address: 127.0.0.1:6831 + # The tracing header format + propagation: jaeger sampling: # The type of the sampler you want to use. Supports: # - const diff --git a/driver/configuration/provider_viper.go b/driver/configuration/provider_viper.go index e340be6951c..58343f95679 100644 --- a/driver/configuration/provider_viper.go +++ b/driver/configuration/provider_viper.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/viper" "github.com/ory/x/corsx" + "github.com/ory/x/stringsx" "github.com/sirupsen/logrus" @@ -251,6 +252,10 @@ func (v *ViperProvider) TracingJaegerConfig() *tracing.JaegerConfig { SamplerType: viperx.GetString(v.l, "tracing.providers.jaeger.sampling.type", "const", "TRACING_PROVIDER_JAEGER_SAMPLING_TYPE"), SamplerValue: viperx.GetFloat64(v.l, "tracing.providers.jaeger.sampling.value", float64(1), "TRACING_PROVIDER_JAEGER_SAMPLING_VALUE"), SamplerServerURL: viperx.GetString(v.l, "tracing.providers.jaeger.sampling.server_url", "", "TRACING_PROVIDER_JAEGER_SAMPLING_SERVER_URL"), + Propagation: stringsx.Coalesce( + viper.GetString("JAEGER_PROPAGATION"), // Standard Jaeger client config + viperx.GetString(v.l, "tracing.providers.jaeger.propagation", "", "TRACING_PROVIDER_JAEGER_PROPAGATION"), + ), } } diff --git a/tracing/tracer.go b/tracing/tracer.go index 4700f42c367..87aaa693f64 100644 --- a/tracing/tracer.go +++ b/tracing/tracer.go @@ -8,6 +8,7 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" jeagerConf "github.com/uber/jaeger-client-go/config" + "github.com/uber/jaeger-client-go/zipkin" ) type Tracer struct { @@ -25,6 +26,7 @@ type JaegerConfig struct { SamplerType string SamplerValue float64 SamplerServerUrl string + Propagation string } func (t *Tracer) Setup() error { @@ -52,8 +54,21 @@ func (t *Tracer) Setup() error { jc.Reporter.LocalAgentHostPort = t.JaegerConfig.LocalAgentHostPort } + var configs []jeagerConf.Option + + // This works in other jaeger clients, but is not part of jaeger-client-go + if t.JaegerConfig.Propagation == "b3" { + zipkinPropagator := zipkin.NewZipkinB3HTTPHeaderPropagator() + configs = append( + configs, + jeagerConf.Injector(opentracing.HTTPHeaders, zipkinPropagator), + jeagerConf.Extractor(opentracing.HTTPHeaders, zipkinPropagator), + ) + } + closer, err := jc.InitGlobalTracer( t.ServiceName, + configs..., ) if err != nil { @@ -119,6 +134,10 @@ func HelpMessage() string { Example: TRACING_PROVIDER_JAEGER_LOCAL_AGENT_ADDRESS=127.0.0.1:6831 +- TRACING_PROVIDER_JAEGER_PROPAGATION: The tracing header propagation format. Defaults to jaeger. + + Example: TRACING_PROVIDER_JAEGER_PROPAGATION=b3 + - TRACING_SERVICE_NAME: Specifies the service name to use on the tracer. Default: ORY Hydra