zio-telemetry
zio-telemetry copied to clipboard
OpenTelemetry: Baggage gets lost when integrating with zio-http
The issue was reported in the Discord channel (https://discord.com/channels/629491597070827530/639825316021272602/1133362501208252476):
Hi! I've now managed to get zio-telemetry root spans and attributes working as zio-http middleware. However, it seems that the opentelemetry Context is not automatically forwarded into the zio-http runtime somehow, which makes Baggage get lost. E.g., Here's an example of two tests where the first one(
"span"
) passes but the second one ("baggage"
) fails:... override def spec: Spec[Tracing with TestEnvironment with Scope, Any] = suite("TracingContextSpec")( test("span") { for { tracing <- ZIO.service[Tracing] result <- Http.fromHandler(Handler.status(Ok)) .mapZIO(_ => tracing.getCurrentSpan.map(_.asInstanceOf[ReadWriteSpan].getName)) .runZIO(Request.get(URL.empty)).option @@ tracing.aspects.span("test") } yield assertTrue(result.contains("test")) }, test("baggage") { for { tracing <- ZIO.service[Tracing] result <- Http.fromHandler(Handler.status(Ok)) .mapZIO(_ => tracing.getCurrentBaggage.map(_.getEntryValue("foo"))) .runZIO(Request.get(URL.empty)).option @@ tracing.aspects.setBaggage("foo", "bar") } yield assertTrue(result.contains("bar")) }, )
How can I ensure that the Baggage will be available inside the Http effect?