-
Notifications
You must be signed in to change notification settings - Fork 848
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 Getter.Keys() with Jaeger Baggage support. #1549
Add Getter.Keys() with Jaeger Baggage support. #1549
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1549 +/- ##
=========================================
Coverage ? 84.30%
Complexity ? 1819
=========================================
Files ? 215
Lines ? 7354
Branches ? 800
=========================================
Hits ? 6200
Misses ? 852
Partials ? 302
Continue to review full report at Codecov.
|
The problem with making this a collection is it will often need to be materialised, even if you can get away with calling |
I'd be fine to have |
Can you add the concrete example of how the Jaeger propagator will use this new feature to this PR? I think that will be very useful for the spec PR, as well, to demonstrate how you're doing to use it. |
Ew, Java and your improper type inference...
context_prop/src/main/java/io/opentelemetry/context/propagation/TextMapPropagator.java
Outdated
Show resolved
Hide resolved
* Returns all the keys in the given carrier. | ||
* | ||
* @param carrier carrier of propagation fields, such as an http request. | ||
* @since 0.10.0 |
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 we've gotten rid of all the @since
tags for now; we'll set them all to 1.0 when we're ready to release.
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.
Oh, I totally forgot about it. Will do.
return builder == null ? null : builder.build(); | ||
} | ||
|
||
@SuppressWarnings("StringSplitter") |
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 relevant for this PR in particular, but I think we should turn off this warning globally, since it's telling us to use guava, which we don't to do for the API, and won't, ever.
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.
+1
@Test | ||
void extract_Nothing() { | ||
// Context remains untouched. | ||
assertThat( | ||
jaegerPropagator.extract( | ||
Context.current(), Collections.<String, String>emptyMap(), Map::get)) | ||
Context.current(), Collections.<String, String>emptyMap(), getter)) |
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.
might be a little safer/cleaner to just use Context.root()
here, so we know that we don't have a pre-polluted 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.
Fair enough, will update.
This looks ok (although it makes me sad that our Getter is no longer a SMI). Based on the discussion above, I had thought you would go with an Iterable/Iterator, rather Collection as the return type for |
Wanted to give a last try at |
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.
The Jaeger specific parts are looking good to me, but I'm not an expert in the propagation format. Perhaps @objectiser or @yurishkuro would want to double-check as well?
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.
Mostly looks nice thanks
...ropagators/src/main/java/io/opentelemetry/extensions/trace/propagation/JaegerPropagator.java
Outdated
Show resolved
Hide resolved
|
||
for (String key : getter.keys(carrier)) { | ||
if (key.startsWith(BAGGAGE_PREFIX)) { | ||
if (key.length() <= BAGGAGE_PREFIX.length()) { |
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.
Since we already checked startsWith I think this can be equals check
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'd rather stick to check the length, as it only depends on a numerical comparison.
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.
Ah I meant an equal check on the length - if it starts with it, then the length is guarateed to be at least that length and the <
here looks redundant
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.
Done.
...ropagators/src/main/java/io/opentelemetry/extensions/trace/propagation/JaegerPropagator.java
Outdated
Show resolved
Hide resolved
...gators/src/test/java/io/opentelemetry/extensions/trace/propagation/JaegerPropagatorTest.java
Outdated
Show resolved
Hide resolved
Neither is default. In OT, HTTP and TextMap are different, so Jaeger url-encodes baggage for HTTP, but not for TextMap (eg in Kafka headers there's no need to url-encode).
That is correct. The official baggage format (in and out) is uberctx-{key}. jaeger-baggage header was invented later for manual injection via curl. |
context_prop/src/main/java/io/opentelemetry/context/propagation/TextMapPropagator.java
Outdated
Show resolved
Hide resolved
Oh, interesting. @yurishkuro , what do you think we should do here? Maybe have two versions, one that does encoding, one that does not? Or maybe something else? e.g.
|
...ropagators/src/main/java/io/opentelemetry/extensions/trace/propagation/JaegerPropagator.java
Outdated
Show resolved
Hide resolved
6582c36
to
01e2341
Compare
@open-telemetry/java-approvers Please review the latest updates. @yurishkuro Updated the code based on your feedback. In a follow up we can add the encoded-values case, if that works for you. |
@yurishkuro Also, there's the question on whether, upon no existing baggage at all in the carrier, we should put an empty |
I would try to avoid that. Even if there is an immutable singleton |
looks like this needs a rebase, @carlosalberto |
@jkwatson Rebased ;) |
Fixes #967
Implements the open-telemetry/opentelemetry-specification#825 update, and implements Jaeger Baggage support to verify that the API is correct/useful (based on their own propagator)
Iterable
forkeys()
.trace-context
section, as it broke some versions of Java 11 (see this).Baggage
inContext
in case there was not Baggage to be extracted at all.For Jaeger reviewers:
TextMap
propagators registered by default (encoded and non-encoded propagation). We need to define the encoding case in a follow-up (somehow).@open-telemetry/java-approvers
cc @pavolloffay @jpkrohling