-
Notifications
You must be signed in to change notification settings - Fork 37
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
Utility functions for integrating with Java code #534
Comments
We've been exploring these utility functions: #340 (review). We may add utility methods in the future, but we should consider all benefits and drawbacks. With the upcoming changes in the Before: def createOtel4s[F[_]: Async](implicit L: Local[F, Context]): F[OtelJava[F]] =
Async[F].delay(GlobalOpenTelemetry.get).map(OtelJava.local[F])
def program[F[_]: Async](otel4s: OtelJava[F])(implicit L: Local[F, Context]): F[Unit] = {
val _ = (otel4s, L) // both OtelJava and Local[F, Context] are available here
Async[F].unit
}
val run: IO[Unit] =
IOLocal(Context.root).flatMap { implicit ioLocal: IOLocal[Context] =>
createOtel4s[IO].flatMap(otel4s => program(otel4s))
} After: def program[F[_]: Async](otel4s: OtelJava[F]): F[Unit] = {
val local: Local[IO, Context] = otel4s.localContext
Async[F].unit
}
def run: IO[Unit] =
OtelJava.autoConfigured[IO]() { otel4s =>
program(otel4s)
} P.S. I will update an example on the site. |
Thanks @iRevive. I can see that we're trying to provide an even easier integration with java code relying on ThreadLocal context propagation. In that case, how about we add the suggested methods to the documentation? In particular I think asyncWithContext has some nuance which will be good to document. |
Yeah, that sounds good. I guess we can provide more detailed and enhanced examples. |
Happy to do the PR for the doc update :) (including the simplified setup code snippet you provide) |
It would be awesome, thanks in advance! |
Thanks for the detailed docs on integrating with libs that rely on java OTel!
Are you open to adding some standard utility functions for integrating with Java code relying on Java OTel?
I'm thinking of:
The text was updated successfully, but these errors were encountered: