diff --git a/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala b/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala index 39b57d98c..8cac050b7 100644 --- a/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala +++ b/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala @@ -43,12 +43,16 @@ import org.typelevel.otel4s.oteljava.metrics.Metrics import org.typelevel.otel4s.oteljava.trace.Traces import org.typelevel.otel4s.trace.TracerProvider -sealed class OtelJava[F[_]] private ( +final class OtelJava[F[_]] private ( + jOtel: JOpenTelemetry, val propagators: ContextPropagators[Context], val meterProvider: MeterProvider[F], val tracerProvider: TracerProvider[F], -) extends Otel4s[F] { +)(implicit val localContext: LocalContext[F]) + extends Otel4s[F] { type Ctx = Context + + override def toString: String = s"OtelJava{$jOtel}" } object OtelJava { @@ -78,12 +82,11 @@ object OtelJava { val metrics = Metrics.forAsync(jOtel) val traces = Traces.local(jOtel, contextPropagators) new OtelJava[F]( + jOtel, contextPropagators, metrics.meterProvider, traces.tracerProvider, - ) { - override def toString: String = jOtel.toString - } + ) } /** Lifts the acquisition of a Java OpenTelemetrySdk instance to a Resource. diff --git a/oteljava/all/src/test/scala/org/typelevel/otel4s/oteljava/OtelJavaSuite.scala b/oteljava/all/src/test/scala/org/typelevel/otel4s/oteljava/OtelJavaSuite.scala index 4b78d05f7..667eea93f 100644 --- a/oteljava/all/src/test/scala/org/typelevel/otel4s/oteljava/OtelJavaSuite.scala +++ b/oteljava/all/src/test/scala/org/typelevel/otel4s/oteljava/OtelJavaSuite.scala @@ -28,7 +28,7 @@ class OtelJavaSuite extends CatsEffectSuite { .forAsync[IO](testSdk) .map(testOtel4s => { val res = testOtel4s.toString() - assert(clue(res).startsWith("OpenTelemetrySdk")) + assert(clue(res).contains("OpenTelemetrySdk")) }) } }