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: Baggage gets lost when integrating with zio-http #739

Open
grouzen opened this issue Jul 25, 2023 · 0 comments
Open

OpenTelemetry: Baggage gets lost when integrating with zio-http #739

grouzen opened this issue Jul 25, 2023 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@grouzen
Copy link
Contributor

grouzen commented Jul 25, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant