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

Map x-ray key/value pairs to baggage. #3106

Merged
merged 3 commits into from
Apr 7, 2021

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Apr 5, 2021

No description provided.

@anuraaga
Copy link
Contributor Author

anuraaga commented Apr 5, 2021

@willarmiros Please review too :)

@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #3106 (4355c92) into main (55affa7) will increase coverage by 90.86%.
The diff coverage is 94.23%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #3106       +/-   ##
===========================================
+ Coverage        0   90.86%   +90.86%     
- Complexity      0     2884     +2884     
===========================================
  Files           0      329      +329     
  Lines           0     9024     +9024     
  Branches        0      907      +907     
===========================================
+ Hits            0     8200     +8200     
- Misses          0      544      +544     
- Partials        0      280      +280     
Impacted Files Coverage Δ Complexity Δ
...opentelemetry/extension/aws/AwsXrayPropagator.java 92.64% <94.23%> (ø) 36.00 <0.00> (?)
...on/incubator/trace/LeakDetectingSpanProcessor.java 86.04% <0.00%> (ø) 8.00% <0.00%> (?%)
...propagation/B3PropagatorExtractorSingleHeader.java 96.55% <0.00%> (ø) 12.00% <0.00%> (?%)
...pentelemetry/sdk/testing/assertj/TracesAssert.java 84.61% <0.00%> (ø) 7.00% <0.00%> (?%)
.../io/opentelemetry/api/common/AttributeKeyImpl.java 100.00% <0.00%> (ø) 4.00% <0.00%> (?%)
...java/io/opentelemetry/api/common/AttributeKey.java 100.00% <0.00%> (ø) 8.00% <0.00%> (?%)
...metry/extension/aws/AwsConfigurablePropagator.java 100.00% <0.00%> (ø) 3.00% <0.00%> (?%)
...ry/sdk/metrics/AbstractAsynchronousInstrument.java 100.00% <0.00%> (ø) 2.00% <0.00%> (?%)
...io/opentelemetry/sdk/metrics/SdkMeterProvider.java 90.90% <0.00%> (ø) 11.00% <0.00%> (?%)
...ry/sdk/trace/samplers/ImmutableSamplingResult.java 100.00% <0.00%> (ø) 4.00% <0.00%> (?%)
... and 320 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55affa7...4355c92. Read the comment docs.

Copy link

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

Generally looks good & compatible with how X-Ray treats baggage today. But wondering if we can or should raise the bar and implement a piece of the X-Ray spec. In addition we'd actually document this behavior publicly which it is not today.

@@ -190,14 +210,21 @@ public static AwsXrayPropagator getInstance() {
+ "' with value "
+ traceHeader
+ "'. Returning INVALID span context.");

Choose a reason for hiding this comment

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

Is this log message still correct to say we're returning INVALID context? It is returning an invalid context, but is it returning the invalid context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, just removed that bit since it's sort of an implementation detail, logging the actual problem is what matters.

if (baggage == null) {
baggage = Baggage.builder();
}
baggage.put(trimmedPart.substring(0, equalsIndex), value.trim());

Choose a reason for hiding this comment

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

So interestingly the X-Ray Trace header spec has a limit of 256 bytes on incoming arbitrary key-value pairs after the defined fields (baggage). This is not publicly documented, and is only implemented in the Node SDK. So clearly it's not critical to matching the behavior of the X-Ray SDKs, but I think it's still worth calling out since a limit on the baggage size is a safe thing to do to prevent malicious headers from stalling a program. Would be interested to hear your thoughts/if there are any existing considerations for this in OTel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for calling this out! The interesting point is to compare to w3c baggage

https://w3c.github.io/baggage/#limits

It's limit is 8192 - it's different but I don't see a big reason for that to affect how xray propagator itself works given it's a different spec. And smaller can be increased to larger later if we ever needed to. Will add the limit.

Choose a reason for hiding this comment

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

Awesome! Good to know about the w3c limits. LGTM.

Copy link
Contributor Author

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Added limit

@@ -190,14 +210,21 @@ public static AwsXrayPropagator getInstance() {
+ "' with value "
+ traceHeader
+ "'. Returning INVALID span context.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, just removed that bit since it's sort of an implementation detail, logging the actual problem is what matters.

@anuraaga anuraaga merged commit 768bde8 into open-telemetry:main Apr 7, 2021
This was referenced Dec 19, 2021
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.

3 participants