Skip to content

Fix objstore tracing instrumentation #5074

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

Merged
merged 2 commits into from
Dec 29, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* [BUGFIX] Updated `golang.org/x/net` dependency to fix CVE-2022-27664. #5008
* [BUGFIX] Fix panic when otel and xray tracing is enabled. #5044
* [BUGFIX] Fixed no compact block got grouped in shuffle sharding grouper. #5055
* [BUGFIX] Tracing: Fix missing object storage span instrumentation. #5074

## 1.14.0 2022-12-02

Expand Down
5 changes: 4 additions & 1 deletion pkg/cortex/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import (
"context"

"github.com/opentracing/opentracing-go"
objstoretracing "github.com/thanos-io/objstore/tracing"
"github.com/thanos-io/thanos/pkg/tracing"
"google.golang.org/grpc"
)

// ThanosTracerUnaryInterceptor injects the opentracing global tracer into the context
// in order to get it picked up by Thanos components.
func ThanosTracerUnaryInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
ctx = objstoretracing.ContextWithTracer(ctx, opentracing.GlobalTracer())
return handler(tracing.ContextWithTracer(ctx, opentracing.GlobalTracer()), req)
}

// ThanosTracerStreamInterceptor injects the opentracing global tracer into the context
// in order to get it picked up by Thanos components.
func ThanosTracerStreamInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
ctx := objstoretracing.ContextWithTracer(ss.Context(), opentracing.GlobalTracer())
return handler(srv, wrappedServerStream{
ctx: tracing.ContextWithTracer(ss.Context(), opentracing.GlobalTracer()),
ctx: tracing.ContextWithTracer(ctx, opentracing.GlobalTracer()),
ServerStream: ss,
})
}
Expand Down