-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Change tracingService methods to use contexts #19093
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,23 +46,14 @@ type Span interface { | |
|
|
||
| // NewSpan creates a new Span with the currently installed tracing plugin. | ||
| // If no tracing plugin is installed, it returns a fake Span that does nothing. | ||
| func NewSpan(inCtx context.Context, label string) (Span, context.Context) { | ||
| parent, _ := currentTracer.FromContext(inCtx) | ||
| span := currentTracer.New(parent, label) | ||
| outCtx := currentTracer.NewContext(inCtx, span) | ||
|
|
||
| return span, outCtx | ||
| func NewSpan(ctx context.Context, label string) (Span, context.Context) { | ||
| return currentTracer.New(ctx, label) | ||
| } | ||
|
Comment on lines
-49
to
51
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to flag this as the core of the change - everything else is making this change work.
|
||
|
|
||
| // NewFromString creates a new Span with the currently installed tracing plugin, extracting the span context from | ||
| // the provided string. | ||
| func NewFromString(inCtx context.Context, parent, label string) (Span, context.Context, error) { | ||
| span, err := currentTracer.NewFromString(parent, label) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| outCtx := currentTracer.NewContext(inCtx, span) | ||
| return span, outCtx, nil | ||
| return currentTracer.NewFromString(inCtx, parent, label) | ||
| } | ||
|
|
||
| // AnnotateSQL annotates information about a sql query in the span. This is done in a way | ||
|
|
@@ -104,10 +95,10 @@ func AddGrpcClientOptions(addInterceptors func(s grpc.StreamClientInterceptor, u | |
| // tracingService is an interface for creating spans or extracting them from Contexts. | ||
| type tracingService interface { | ||
| // New creates a new span from an existing one, if provided. The parent can also be nil | ||
| New(parent Span, label string) Span | ||
| New(ctx context.Context, label string) (Span, context.Context) | ||
|
|
||
| // NewFromString creates a new span and uses the provided string to reconstitute the parent span | ||
| NewFromString(parent, label string) (Span, error) | ||
| NewFromString(ctx context.Context, parent, label string) (Span, context.Context, error) | ||
|
|
||
| // FromContext extracts a span from a context, making it possible to annotate the span with additional information | ||
| FromContext(ctx context.Context) (Span, bool) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: OpenTelemetry returns
(context.Context, Span)I believe. Would it be a hassle to match it? Not a strong opinion so feel free to ignore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it, but this order matches more of the existing Vitess codebase, and I didn’t want to mess about with changing that yet.
IMO the right option is going to be to add otel now, drop opentracing soon, and then do a final cleanup pass.