-
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
Add keys func to TextMapCarrier #1493
Comments
keys
func to TextMapCarrier
I don't read the spec as requiring that the carrier must provide a
This
Indeed, it seems that the expectation is that the
We could add a |
Reading the spec alongside the Java-language reference implementation, I see that This design makes sense in Java because the carrier is a generic argument: // getter for carriers of type C
interface Getter<C> {
Iterable<String> keys(C carrier)
String get(C carrier, String key)
}
interface TextMapPropagator {
// Extract from context given a carrier and a *compatible* getter.
<C> Context extract(Context ctx, C carrier, Getter<C> getter);
} However, this design doesn't make sense in pre-generics Go (I would argue that it will remain un-idiomatic even once Go has generics), because in Go we specialize Instead, I think it's better to do as the original issue suggested and simply add a |
Digging a bit further - if I make // before
prop.Extract(ctx, req.Header)
// after
prop.Extract(ctx, HeaderCarrier(req.Header)) I'm going to submit a PR with this design, but it's worth thinking about alternatives. |
As per spec, the carrier must provide a
keys
methodhttps://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#keys
The text was updated successfully, but these errors were encountered: