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

OpenTelemetry: Return null when getting a missing header #662

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

kierendavies
Copy link
Contributor

If the Propagator expects a header which is missing from the kernel, it catches the NoSuchElementException, silently fails the propagation, and instead generates a new trace ID.

java.util.NoSuchElementException: key not found: baggage
	at scala.collection.immutable.Map$Map2.apply(Map.scala:298)
	at natchez.opentelemetry.OpenTelemetrySpan$$anon$1.get(OpenTelemetrySpan.scala:168)
	at natchez.opentelemetry.OpenTelemetrySpan$$anon$1.get(OpenTelemetrySpan.scala:167)
	at io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator.extract(W3CBaggagePropagator.java:98)
	at io.opentelemetry.context.propagation.MultiTextMapPropagator.extract(MultiTextMapPropagator.java:65)
	at natchez.opentelemetry.OpenTelemetrySpan$.fromKernel$$anonfun$1(OpenTelemetrySpan.scala:142)
	at cats.effect.IOFiber.runLoop(IOFiber.scala:335)
	at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1322)
	at cats.effect.IOFiber.run(IOFiber.scala:119)
	at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:585)

The OpenTelemetry propagators expect either null or empty string when a header is missing.

If the Propagator expects a header which is missing from the kernel, it
catches the `NoSuchElementException`, silently fails the propagation, and
instead generates a new trace ID.

```
java.util.NoSuchElementException: key not found: baggage
	at scala.collection.immutable.Map$Map2.apply(Map.scala:298)
	at natchez.opentelemetry.OpenTelemetrySpan$$anon$1.get(OpenTelemetrySpan.scala:168)
	at natchez.opentelemetry.OpenTelemetrySpan$$anon$1.get(OpenTelemetrySpan.scala:167)
	at io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator.extract(W3CBaggagePropagator.java:98)
	at io.opentelemetry.context.propagation.MultiTextMapPropagator.extract(MultiTextMapPropagator.java:65)
	at natchez.opentelemetry.OpenTelemetrySpan$.fromKernel$$anonfun$1(OpenTelemetrySpan.scala:142)
	at cats.effect.IOFiber.runLoop(IOFiber.scala:335)
	at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1322)
	at cats.effect.IOFiber.run(IOFiber.scala:119)
	at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:585)
```

The OpenTelemetry propagators expect either `null` or empty string when
a header is missing.
@mpilquist mpilquist merged commit 8d72092 into typelevel:main Nov 22, 2022
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.

2 participants