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

sdk-trace: add SpanExportersAutoConfigure #477

Merged

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Feb 5, 2024

Due to modularity and lack of SPI on Native/Scala.js platforms, I came up with the following solution:

OpenTelemetrySdk
  .autoConfigured(
    _.addExporterConfigurer(OtlpSpanExporterAutoConfigure[IO]) // add the external configurer here
  )
  .use { autoConfigured =>
    val sdk = autoConfigured.sdk

    for {
      tracer <- sdk.tracerProvider.get("my-tracer")
      _ <- tracer
        .span("test", Attribute("test", "test123"))
        .use(sd => IO.println(sd.context))
    } yield ()
  }

The SDK autoconfigure will be able to:

  1. Configure the telemetry resource
  2. Configure the tracer provider (batch span processor, etc)
  3. Configure sampler
  4. Partially configure span exporter (the external exporters must be registered manually)

@iRevive iRevive added the module:sdk Features and improvements to the sdk module label Feb 5, 2024
}

private def otlpMissingWarning: F[Unit] = {
Console[F].errorln(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have any better idea how to communicate with the user that dependency is missing. The service will not start anyway, but we will also provide a meaningful help message.

@iRevive iRevive force-pushed the sdk-trace/span-exporter-autoconfigure branch from 5806d4c to 27817be Compare February 5, 2024 19:01
@iRevive
Copy link
Contributor Author

iRevive commented Feb 5, 2024

Alternatively, we can make a super module 'otel4s-sdk-autoconfigure' and automatically register the OTLP exporter there.

@armanbilge
Copy link
Member

lack of SPI on Native/Scala.js platform

Scala Native actually got support for SPI recently, but I think it will only land in the 0.5.0 release.

There is a possibility that Scala.js may also eventually implement SPI to help support WASM.


But I don't think either of those things should block this PR. I will take a closer look.

@iRevive iRevive force-pushed the sdk-trace/span-exporter-autoconfigure branch from 27817be to 118dc96 Compare February 9, 2024 12:27
@iRevive
Copy link
Contributor Author

iRevive commented Feb 13, 2024

I will merge the PR to unblock the upcoming changes.

@iRevive iRevive merged commit c4ee366 into typelevel:main Feb 13, 2024
10 checks passed
@iRevive iRevive deleted the sdk-trace/span-exporter-autoconfigure branch February 13, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:sdk Features and improvements to the sdk module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants