typelevel / otel4s

An OpenTelemetry library for Scala based on Cats-Effect
https://typelevel.org/otel4s
Apache License 2.0
168 stars 34 forks source link

Ability to Run SpanFinalizer Strategies is Private #205

Closed ChristopherDavenport closed 4 months ago

ChristopherDavenport commented 1 year ago

https://github.com/typelevel/otel4s/blob/main/core/trace/src/main/scala/org/typelevel/otel4s/trace/SpanFinalizer.scala#L95

The backends can build up strategies, but because the cases are private, and run is private there is no way to expose them to a different backend.

Workaround

package org.typelevel.otel4s.backdoor

import cats.Applicative
import org.typelevel.otel4s.trace.{Span,SpanFinalizer}

object StrategyRunBackend {
  def run[F[_]: Applicative](
    backend: Span.Backend[F],
    finalizer: SpanFinalizer
  ) = SpanFinalizer.run(backend, finalizer)
}
iRevive commented 4 months ago

The new otel4s-sdk-trace module provides a simple way to implement a customized exporter while taking care of the span's lifecycle.