Skip to content

Commit

Permalink
Add multiple tracing propagators
Browse files Browse the repository at this point in the history
This commit adds more tracing propagators to allow the system to work with both
W3C tracing context and the "old" Jaeger tracing context that Prometheus still
uses. This is a combination of future proofing and compatibility.
  • Loading branch information
kradalby committed Feb 3, 2021
1 parent 4cef704 commit def47ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/thanos-io/thanos v0.12.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.16.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0
go.opentelemetry.io/contrib/propagators v0.16.0 // indirect
go.opentelemetry.io/otel v0.16.0
go.opentelemetry.io/otel/exporters/trace/jaeger v0.16.0
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,15 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48=
go.opentelemetry.io/contrib v0.16.0 h1:cScR/U3bjTjxsBv939wh4miANY/akdP644rsg9msrIA=
go.opentelemetry.io/contrib v0.16.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.16.0 h1:Px1Aq1dWypvYhuuvb2Y0sL8j66L6GDKfVECP8/QMMZ0=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.16.0/go.mod h1:hFqINJwGPTvDeAdDVxQXV+5HV944veeLbuexbZeVeqs=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0 h1:hPbUH5fugPACtUdBWGL5glNqzowwHvnOdnwvQOATWgM=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0/go.mod h1:dNF4PMGeouMEPAWDwgEjsGFlod9hAU8oj0TU0w2J19g=
go.opentelemetry.io/contrib/propagators v0.16.0 h1:6M16whHin+Uz2zMefuxmFG5CITQ2Q1CHnt2vKxWcQ+A=
go.opentelemetry.io/contrib/propagators v0.16.0/go.mod h1:5kVVCrfVbGf6mu9Lk6DS91EDrkdneQdqUkJhmZXrOrA=
go.opentelemetry.io/otel v0.16.0 h1:uIWEbdeb4vpKPGITLsRVUS44L5oDbDUCZxn8lkxhmgw=
go.opentelemetry.io/otel v0.16.0/go.mod h1:e4GKElweB8W2gWUqbghw0B8t5MCTccc9212eNHnOHwA=
go.opentelemetry.io/otel/exporters/trace/jaeger v0.16.0 h1:gOnjphv9uycs+AfZprppdsm/P7B0CVxPr5E1UtT2wqw=
Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import (
"github.com/thanos-io/thanos/pkg/store/storepb"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"

grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
jaegerPropagator "go.opentelemetry.io/contrib/propagators/jaeger"
jaegerExporter "go.opentelemetry.io/otel/exporters/trace/jaeger"
)

Expand Down Expand Up @@ -60,6 +63,12 @@ func initTracer() func() {
log.Fatal(err)
}

otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
jaegerPropagator.Jaeger{},
propagation.TraceContext{},
propagation.Baggage{},
))

return flush
}

Expand Down

0 comments on commit def47ee

Please sign in to comment.