Skip to content

Commit

Permalink
Merge pull request #464 from NthPortal/OtelJava-LocalContext/PR
Browse files Browse the repository at this point in the history
Expose `OtelJava`'s `LocalContext`
  • Loading branch information
NthPortal authored Jan 30, 2024
2 parents 47b737d + 06b51d3 commit 8e1bde5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})
}
}

0 comments on commit 8e1bde5

Please sign in to comment.