-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Prototypes proposed spec changes to allow extraction of multiple header values #5973
base: main
Are you sure you want to change the base?
Prototypes proposed spec changes to allow extraction of multiple header values #5973
Conversation
…, extending TextMapCarrier. Gives example extracting requests with multiple 'baggage' headers set.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5973 +/- ##
=======================================
- Coverage 84.6% 84.6% -0.1%
=======================================
Files 272 272
Lines 22897 22918 +21
=======================================
+ Hits 19391 19401 +10
- Misses 3162 3173 +11
Partials 344 344 |
multiCarrier, isMultiCarrier := carrier.(MultiTextMapCarrier) | ||
if isMultiCarrier { | ||
return extractMultiBaggage(parent, multiCarrier) | ||
} |
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.
Not as gross as I expected 👍
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 think your prototype is good. For an actual PR we would need to improve the docs and call out the MultiTextMapCarrier in more places.
PS. Not feeling well today so treat my review with low confidence (like an pre-approval). I will do my best to look at it again once I recover and have a clearer mind.
@open-telemetry/go-maintainers, PTAL at this prototype |
@@ -29,6 +29,19 @@ func (b Baggage) Inject(ctx context.Context, carrier TextMapCarrier) { | |||
|
|||
// Extract returns a copy of parent with the baggage from the carrier added. | |||
func (b Baggage) Extract(parent context.Context, carrier TextMapCarrier) context.Context { | |||
multiCarrier, isMultiCarrier := carrier.(MultiTextMapCarrier) |
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.
AFAIK type assertions can introduce an additional heap allocation. The extraction is on the hot path.
Can you add some benchmark for this method and add benchstat
results to the PR description so that we can see what is the performance overhead?
Can you also implement the MultiTextMapCarrier
for TraceContext
so that we can also use the existing BenchmarkExtract
to validate the performance overhead for TraceContext
(which is probably more popular than Baggage)?
PS. I do not expect anyone would say that an additional heap allocation would be a blocker. Maybe at some point Go runtime would not make a heap allocation when doing a type assertion. Still, we should be aware of the performance consequences of a new functionality.
MultiTextMapCarrier
, extendingTextMapCarrier
- addsGetAll(string) []string
.MultiTextMapCarrier
forHeaderCarrier
propagator.Baggage
to use theGetAll()
method if it's implemented.Does not introduce any breaking changes or alter any existing tests.
Spec issue: open-telemetry/opentelemetry-specification#433
Corresponding Java prototype: open-telemetry/opentelemetry-java#6852