Skip to content
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

Merged
merged 14 commits into from
Nov 20, 2020

Conversation

malafeev
Copy link
Contributor

@malafeev malafeev commented Nov 3, 2020

Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@malafeev malafeev changed the title add baggage propagators to default propagators add baggage propagator to default propagators Nov 3, 2020
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@carlosalberto
Copy link
Contributor

IIRC there's a spot where, if the user specified values (b3, jaeger, etc), we put all the propagators in a TraceMultiPropagator, right? If that's the case, we need to update that as well, to prevent adding the Baggage propagator there ;)

@malafeev
Copy link
Contributor Author

malafeev commented Nov 4, 2020

@carlosalberto if user specifies propagators (e.g. b3, jaeger) then Baggage propagator will not be added.
Baggage propagator added only if user didn't specify any propagator or if user specified baggage propagator.
In the case if user provided b3,baggage then Baggage propagator will be added in a TraceMultiPropagator.
Am I right that TraceMultiPropagator should never contain Baggage propagator even if user specified multiple propagators including baggage?

@trask
Copy link
Member

trask commented Nov 4, 2020

Am I right that TraceMultiPropagator should never contain Baggage propagator even if user specified multiple propagators including baggage?

Yes, I hadn't thought about this, but it makes sense, as TraceMultiPropagator stops extracting once it extracts a span context successfully.

Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@malafeev
Copy link
Contributor Author

malafeev commented Nov 5, 2020

@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())
Copy link
Contributor Author

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.

Copy link
Contributor

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 😄

Copy link
Member

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?

Copy link
Contributor

@carlosalberto carlosalberto Nov 5, 2020

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).

Copy link
Member

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?

Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@iNikem iNikem Nov 10, 2020

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

Sergei Malafeev added 3 commits November 9, 2020 21:26
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
Copy link
Contributor

@iNikem iNikem left a 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())
Copy link
Contributor

@iNikem iNikem Nov 10, 2020

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Sergei Malafeev added 2 commits November 10, 2020 23:17
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@malafeev
Copy link
Contributor Author

I didn't update README yet, let me finish with javadoc.
And I'm not sure that it should be in instrumentation README, maybe better place is otel-java.

Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@malafeev
Copy link
Contributor Author

updated README

@malafeev malafeev requested a review from iNikem November 12, 2020 16:19
Copy link
Member

@trask trask left a 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

TextMapPropagator textPropagator = TEXTMAP_PROPAGATORS.get(propagatorId.trim().toLowerCase());
List<String> propagatorIds =
propagators.stream()
.map(propagator -> propagator.trim().toLowerCase())
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@malafeev
Copy link
Contributor Author

@trask I applied your suggested changes except one about case sensitivity.

Signed-off-by: Sergei Malafeev <sergei@malafeev.org>
@trask
Copy link
Member

trask commented Nov 13, 2020

last request is that I think this behavior of OTEL_PROPAGATORS should be documented in the spec

@carlosalberto can you take this?

@carlosalberto
Copy link
Contributor

@trask This part is not documented at all in the Spec (although there's a ticket to standardize TraceMultiPropagator, which only exists for Java at the moment, as an improvement in order to not extract SpanContext more than once), so no need to do it there for now.

However, we should, for sanity purposes, document this in TraceMultiPropagator in OTel Java, mentioning it should only contain SpanContext-only Propagators, in order to avoid unexpected, incorrect scenarios. Does that makes sense?

(We could also document in the Spec that the OTEL_PROPAGATOR values, and probably all env-var values, should be lower-case. Sounds about right?)

@trask
Copy link
Member

trask commented Nov 15, 2020

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

@carlosalberto
Copy link
Contributor

Hey @trask

Sorry for the delay.

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

So the idea of TraceMultiPropagator is simply that we don't extract SpanContext more than once (as an optimization), and MUST NOT change the propagation semantics at all. Logically speaking, the only thing to be careful about these days, is that only trace-only Propagators are added to it.

So, when we standardize this in the Spec, semantics MUST NOT change, and we will simply offer this as a optimization.

@trask
Copy link
Member

trask commented Nov 19, 2020

@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.

@malafeev
Copy link
Contributor Author

@trask I merged your PR

@iNikem
Copy link
Contributor

iNikem commented Nov 19, 2020

@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.

@malafeev
Copy link
Contributor Author

For user it's simple like OTEL_PROPAGATORS=b3,baggage. Internally it's complicated but not for end user.

@iNikem
Copy link
Contributor

iNikem commented Nov 19, 2020

For user it's simple like OTEL_PROPAGATORS=b3,baggage. Internally it's complicated but not for end user.

So if I specify b3multi, I will not get baggage? So I have to always specify baggage if I want to propagated? What about jaeger,baggage?

@iNikem
Copy link
Contributor

iNikem commented Nov 19, 2020

How should user know at all that some of the "Supported propagators are tracecontext, baggage, b3, b3multi, jaeger, ottracer, and xray" are trace only (which ones?), some are baggage only (which ones?) and some are both?

@malafeev
Copy link
Contributor Author

malafeev commented Nov 19, 2020

I don't think these questions should be answered here. Explanation of how propagators work is the otel-java or spec job.

@iNikem
Copy link
Contributor

iNikem commented Nov 19, 2020

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.

@carlosalberto
Copy link
Contributor

carlosalberto commented Nov 19, 2020

@iNikem Hah! Yes, the user doesn't really need to worry about the propagators, at least through OTEL_PROPAGATORS - actual users of TraceMultiPropagator do however, as it helps to prevent double extraction of SpanContext, with the restriction that if another concern is extracted as part of it, such as baggage, it MUST NOT be included there (Jaeger is the prime example).

We should definitely document that (specially in OTel Java itself).

In other words:

  • Only Trace/SpanContext-only Propagators must be added to TraceMultiPropagator.
  • HttpTraceContext, AWSPropagator, B3 (both single and multi encoding) can be added to TraceMultiPropagator.
  • Baggage and Jaeger (and soon OTPropagator) must not be added to TraceMultiPropagator, as they are not Trace/SpanContext-only Propagators.

I'd say: in case of doubt, don't use TraceMultiPropagator, as it's an optimization to prevent multiple extraction of the same data.

@trask
Copy link
Member

trask commented Nov 19, 2020

@iNikem is it ok to dismiss your request for changes, or is there anything else you'd like in this PR?

@trask
Copy link
Member

trask commented Nov 20, 2020

Closes #1632 (does it work to put that here?)

Copy link
Contributor

@iNikem iNikem left a 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.

@iNikem
Copy link
Contributor

iNikem commented Nov 20, 2020

@iNikem is it ok to dismiss your request for changes, or is there anything else you'd like in this PR?

why do you ask when you haven't yet approved it yourself? :)

@trask
Copy link
Member

trask commented Nov 20, 2020

why do you ask when you haven't yet approved it yourself? :)

oops 😅

@trask trask merged commit 4b3bbf6 into open-telemetry:master Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants