-
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
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
6968344 to
9918597
Compare
New and NewFromString in the tracingService interface are called by trace.NewSpan and trace.NewFromString, who take and return a context. This aligns them, so the plugin matches their caller. This makes the interface more compatible with OpenTelemetry API, making it easier to write an upcoming tracing plugin using that API. Signed-off-by: Matthew McPherrin <git@mcpherrin.ca>
9918597 to
9f7ce81
Compare
Signed-off-by: Matthew McPherrin <git@mcpherrin.ca>
eea0f0d to
9de286e
Compare
|
I've looked at the CI failures and they don't seem related. Flakes? (Except pull request labels, which I don't have permission to set) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19093 +/- ##
=======================================
Coverage 69.87% 69.88%
=======================================
Files 1613 1613
Lines 216002 216020 +18
=======================================
+ Hits 150939 150968 +29
+ Misses 65063 65052 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| 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) | ||
| } |
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 want to flag this as the core of the change - everything else is making this change work.
NewSpan(ctx context.Context, label string) (Span, context.Context) matches what we want for Opentelemetry, so we just collapse currentTracer.FromContext -> currentTracer.New -> currentTracer.NewContext into currentTracer.New.
mattlord
left a comment
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.
Thanks, @mcpherrinm ! ❤️
| outCtx := currentTracer.NewContext(inCtx, span) | ||
|
|
||
| return span, outCtx | ||
| func NewSpan(ctx context.Context, label string) (Span, context.Context) { |
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.
Description
The tracingService interface has methods New and NewFromString that are called by trace.NewSpan and trace.NewFromString.
trace.NewSpan and trace.NewFromString take and return a context.
That matches what OpenTelemetry's API wants, but doesn't match the tracingService interface they call.
By making the tracingService methods use contexts, it'll be much easier to add OpenTelemetry for #17341 as the APIs are aligned.
Related Issue(s)
fixes #19125
blocked on #19092
blocks #17341
Checklist
Deployment Notes
This should have no functional changes, though I don't know if anyone is depending on these public interfaces outside of the Vitess codebase.
AI Disclosure
No AI written code, though some AI use while implementing this interface for OpenTelemetry is what motivated the change.