opentelemetry-go-contrib icon indicating copy to clipboard operation
opentelemetry-go-contrib copied to clipboard

AWS X-Ray could contain only Root value

Open regeda opened this issue 2 years ago • 5 comments

The XRay propagator always expects the Parent value:

X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1

The AWS spec says that the Parent value might be absent and the following headers are also correct:

X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793
X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Sampled=1

This change makes the span id from the first 8 bytes of the trace id if the Parent value is not exist.

regeda avatar Mar 07 '22 10:03 regeda

CLA Signed

The committers are authorized under a signed CLA.

  • :white_check_mark: Anthony Regeda (06aee999739ce7ae57bff00d2a202091fe7db2e4)

This change makes the span id from the first 8 bytes of the trace id if the Parent value is not exist.

I'm not sure this is correct. My read of those docs is that the parent span ID may not exist when the trace ID was generated by a system that doesn't produce a segment to XRay, such as the API Gateway. Copying bits from the trace ID for the parent span ID seems likely to result in errors constructing the trace graph as the root span will look like it is missing a parent.

Aneurysm9 avatar Mar 07 '22 16:03 Aneurysm9

The current implementation considers the following trace as invalid:

X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793

bc no Parent

Then the library generates a new Root with a random Parent and the origin Root has been lost.

My approach keeps the origin Root and adds the Parent derived from the root to respect validation rules: both Root and Parent should exist

regeda avatar Mar 09 '22 12:03 regeda

@willarmiros

anuraaga avatar Mar 18 '22 02:03 anuraaga

Codecov Report

Merging #1890 (f089897) into main (fdbade3) will increase coverage by 4.4%. The diff coverage is 77.7%.

:exclamation: Current head f089897 differs from pull request most recent head 63d5178. Consider uploading reports for the commit 63d5178 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #1890     +/-   ##
=======================================
+ Coverage   69.2%   73.7%   +4.4%     
=======================================
  Files        147     141      -6     
  Lines       6884    6407    -477     
=======================================
- Hits        4768    4725     -43     
+ Misses      2000    1540    -460     
- Partials     116     142     +26     
Impacted Files Coverage Δ
propagators/aws/xray/propagator.go 70.1% <77.7%> (+5.6%) :arrow_up:
instrumentation/net/http/otelhttp/wrap.go 50.0% <0.0%> (-25.0%) :arrow_down:
instrumentation/net/http/otelhttp/config.go 80.6% <0.0%> (-7.3%) :arrow_down:
instrumentation/net/http/otelhttp/handler.go 78.2% <0.0%> (-6.1%) :arrow_down:
samplers/jaegerremote/sampler_remote.go 85.2% <0.0%> (-2.2%) :arrow_down:
...ation/github.com/gin-gonic/gin/otelgin/gintrace.go 80.7% <0.0%> (-1.6%) :arrow_down:
...trumentation/github.com/gorilla/mux/otelmux/mux.go 86.2% <0.0%> (-0.9%) :arrow_down:
propagators/b3/b3_propagator.go 98.5% <0.0%> (-0.5%) :arrow_down:
propagators/jaeger/jaeger_propagator.go 97.1% <0.0%> (-0.2%) :arrow_down:
detectors/gcp/gce.go 8.7% <0.0%> (ø)
... and 40 more

codecov[bot] avatar Mar 21 '22 12:03 codecov[bot]