-
Notifications
You must be signed in to change notification settings - Fork 791
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 baggage propagator to default propagators #1545
Conversation
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/PropagatorsInitializer.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
IIRC there's a spot where, if the user specified values ( |
@carlosalberto if user specifies propagators (e.g. |
Yes, I hadn't thought about this, but it makes sense, as |
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@trask @carlosalberto fixed adding Baggage propagator to TraceMultiPropagator |
@@ -50,6 +53,7 @@ public static void initializePropagators(List<String> propagators) { | |||
OpenTelemetry.setGlobalPropagators( | |||
DefaultContextPropagators.builder() | |||
.addTextMapPropagator(HttpTraceContext.getInstance()) | |||
.addTextMapPropagator(W3CBaggagePropagator.getInstance()) |
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.
@carlosalberto
W3CBaggagePropagator
should be first one or last one?
it doesn't matter for inject but for extract we return context from last propagator.
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.
It does't matter for the default configuration case 😄
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.
@carlosalberto does it matter the order we add W3CBaggagePropagator
for the non-default configuration case?
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.
@trask So Baggage
propagators work just like the Trace ones (B3, TraceContext, etc), regarding the fact that, upon successful extraction, any previous value will be overridden (i.e. that last one wins).
Currently only the Jaeger propagator does Baggage
extraction besides W3CBaggage
, so the order may matter in such case, e.g. if the user explicitly specifies OTEL_PROPAGATORS=jaeger,baggage
, then W3CBaggage
will have higher priority, given the case that Baggage
was propagated using both Jaeger
and W3CBaggage
formats.
Then again, when users specify this, they should know what they are doing, IMHO 😉 (although maybe we should add a note in OTel Java regarding this, etc).
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.
@carlosalberto do u know what we should do if the user specifies:
OTEL_PROPAGATORS=jaeger,baggage,tracecontext
Should we add both TraceMultiPropagator(jaeger,tracecontext) and W3BaggagePropagator? And if so, do u know whether we should add TraceMultiPropagator first or last?
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.
@malafeev Yes ;) - and put a comment in the code on why we are doing it (i.e. Jaeger handles BOTH tracing and baggage, etc).
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
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.
@malafeev I think both users and developers will have a hard time understanding how otel.propagators
works now :) Please document the final result both in PropagatorsInitializer.java
and in README. The latter, for example, currently does very poor job explaining the difference between trace context propagators and baggage ones.
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.
@iNikem I added javadoc, is it clear enough?
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.
Sorry, but no :) I will add comments to javadoc. And we still have to update README
# Conflicts: # README.md
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
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.
This PR introduces quiet complex rules about how propagators are configured and how they impact each other. These rules are not documented neither for developers in PropagatorsInitializer
nor for end-users in README.
@@ -50,6 +53,7 @@ public static void initializePropagators(List<String> propagators) { | |||
OpenTelemetry.setGlobalPropagators( | |||
DefaultContextPropagators.builder() | |||
.addTextMapPropagator(HttpTraceContext.getInstance()) | |||
.addTextMapPropagator(W3CBaggagePropagator.getInstance()) |
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.
Sorry, but no :) I will add comments to javadoc. And we still have to update README
* extraction next rules applied: | ||
* | ||
* <ul> | ||
* <li>W3CBaggagePropagator is added to DefaultContextPropagators to allow another propagator |
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.
Is it always added? Or only if baggage
value is provided?
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.
added can be
... only
* <ul> | ||
* <li>W3CBaggagePropagator is added to DefaultContextPropagators to allow another propagator | ||
* extract Context. | ||
* <li>JaegerPropagator is added to DefaultContextPropagators because it extracts both 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.
Is it always added? Or only if jaeger
value is provided?
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.
added can be
... only
* <li>JaegerPropagator is added to DefaultContextPropagators because it extracts both Context | ||
* and Baggage. Otherwise in TraceMultiPropagator it may not get a chance to extract any | ||
* existing Baggage. | ||
* <li>W3CBaggagePropagator comes after JaegerPropagator, as it can have more complex/complete |
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.
Above you say "returns first successful extracted Context", here you seem to say that later Baggage extraction can enrich the previous one. If context and baggage extractions behave differently in this regard, we have to say so explicitly.
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.
updated.
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
I didn't update README yet, let me finish with javadoc. |
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
updated README |
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.
ok, I think I understand propagators now 😅
of course, that's what I thought before too 😁
last request is that I think this behavior of OTEL_PROPAGATORS
should be documented in the spec
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/PropagatorsInitializer.java
Outdated
Show resolved
Hide resolved
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/PropagatorsInitializer.java
Outdated
Show resolved
Hide resolved
TextMapPropagator textPropagator = TEXTMAP_PROPAGATORS.get(propagatorId.trim().toLowerCase()); | ||
List<String> propagatorIds = | ||
propagators.stream() | ||
.map(propagator -> propagator.trim().toLowerCase()) |
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 don't see mention of supporting case-insensitivity in the spec, I would suggest leaving this out?
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.
it was from beginning I suppose, didn't want change behavior
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.
ok, I created #1632 to track this
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/PropagatorsInitializer.java
Outdated
Show resolved
Hide resolved
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/PropagatorsInitializer.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@trask I applied your suggested changes except one about case sensitivity. |
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@carlosalberto can you take this? |
@trask This part is not documented at all in the Spec (although there's a ticket to standardize However, we should, for sanity purposes, document this in (We could also document in the Spec that the |
thanks @carlosalberto my concern with this not being defined in the spec, is that once it is defined, if it varies from our implementation, it would be a breaking change for our users |
# Conflicts: # README.md
Hey @trask Sorry for the delay.
So the idea of So, when we standardize this in the Spec, semantics MUST NOT change, and we will simply offer this as a optimization. |
@carlosalberto thanks for that explanation, I think I understand now(!?). @malafeev I sent a PR to your PR that I think would clarify a lot of questions/troubles that reviewers had understanding this. |
Simplify the rules
@trask I merged your PR |
@trask @malafeev @carlosalberto Can you please update me on this PR? I am still concerned that just from README nobody will understand how to configure propagators. Especially when interested in baggage as well. |
For user it's simple like |
So if I specify |
How should user know at all that some of the "Supported propagators are |
I don't think these questions should be answered here. Explanation of how propagators work is the otel-java or spec job. |
You may be right, I will not argue. Then we should link to that explanation from our README. |
@iNikem Hah! Yes, the user doesn't really need to worry about the propagators, at least through We should definitely document that (specially in OTel Java itself). In other words:
I'd say: in case of doubt, don't use |
@iNikem is it ok to dismiss your request for changes, or is there anything else you'd like in this PR? |
Closes #1632 (does it work to put that here?) |
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 have created #1716 for proper documentation.
why do you ask when you haven't yet approved it yourself? :) |
oops 😅 |
cc @carlosalberto