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

fix: add type checking in propagators #904

Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Mar 26, 2020

Fixes #903

@dyladan dyladan added the bug Something isn't working label Mar 26, 2020
@dyladan
Copy link
Member Author

dyladan commented Mar 26, 2020

@jordanworner would appreciate you taking a look at this.

@@ -66,7 +66,6 @@ export class B3Propagator implements HttpTextPropagator {
const traceIdHeader = getter(carrier, X_B3_TRACE_ID);
const spanIdHeader = getter(carrier, X_B3_SPAN_ID);
const sampledHeader = getter(carrier, X_B3_SAMPLED);
if (!traceIdHeader || !spanIdHeader) return context;
const traceId = Array.isArray(traceIdHeader)
Copy link
Member Author

Choose a reason for hiding this comment

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

The root of this issue was that Array.isArray turns our unknown into an any which made the type system not complain like we would have expected.

@codecov-io
Copy link

codecov-io commented Mar 26, 2020

Codecov Report

Merging #904 into master will decrease coverage by 0.24%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #904      +/-   ##
==========================================
- Coverage   92.85%   92.60%   -0.25%     
==========================================
  Files         244      243       -1     
  Lines       10982    10954      -28     
  Branches     1067     1084      +17     
==========================================
- Hits        10197    10144      -53     
- Misses        785      810      +25     
Impacted Files Coverage Δ
...metry-core/src/context/propagation/B3Propagator.ts 93.75% <100.00%> (-0.13%) ⬇️
...y-core/src/context/propagation/HttpTraceContext.ts 93.33% <100.00%> (-6.67%) ⬇️
...propagator-jaeger/src/JaegerHttpTracePropagator.ts 96.29% <100.00%> (ø)
...ry-api/test/noop-implementations/noop-span.test.ts 50.00% <0.00%> (-50.00%) ⬇️
...-api/test/noop-implementations/noop-tracer.test.ts 52.63% <0.00%> (-47.37%) ⬇️
.../opentelemetry-api/src/trace/NoopTracerProvider.ts 57.14% <0.00%> (-22.86%) ⬇️
...ntelemetry-tracing/test/MultiSpanProcessor.test.ts 97.43% <0.00%> (-2.57%) ⬇️
packages/opentelemetry-tracing/src/config.ts 100.00% <0.00%> (ø)
... and 25 more

@jordanworner
Copy link
Contributor

@dyladan I applied your fix and retested my gRPC server using both the b3 and trace context propagators and that seems to have fixed it. Requests now work with or without the parent metadata.

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

LGTM, It would be nice if you can test.

@dyladan
Copy link
Member Author

dyladan commented Mar 26, 2020

Trying to figure out a good way to test

@dyladan
Copy link
Member Author

dyladan commented Mar 26, 2020

@mayurkale22 added tests

@dyladan dyladan merged commit 47212de into open-telemetry:master Mar 27, 2020
@dyladan dyladan deleted the grcp-match-undefined branch March 27, 2020 13:17
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC plugin throws an error when no traceparent is present
6 participants