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

Expose child Spans from OpenTracing API to support tracing legacy code? #81

Open
kalexmills opened this issue Jan 24, 2020 · 3 comments

Comments

@kalexmills
Copy link

I have a use-case where we're using http4s to drive legacy code written in Java (which we're not ready to rewrite in the typelevel style).

I would like to be able to share a trace initiated from http4s via natchez (and code written in #5) to pass down a child OpenTracing Span to serve as the root span of my legacy Java calls.

I realize this breaks the nice abstraction / hiding provided by natchez, but there can be reasons for consenting adults to do so from time-to-time.

Are we open to adding extension methods to the entrypoint hooks (like in JaegerTracer) to construct and return a child span from the OpenTracing API, or would that ruin everything?

@kalexmills
Copy link
Author

Mkay, so this can be done.

Trace[F].kernel yields a Map[String, String] which you can just use to reconstruct a new span using whatever fancy mechanism you want.

👍

@tpolecat
Copy link
Member

The contents of the map are only meaningful to Natchez, so I would not count on being able to inspect it and pull out usable data.

If you have access to your Span[F] you can try to downcast it to JaegerSpan which gives you access to the underlying span and tracer. If all you have is Trace[F] then you're out of luck unless we give you a way to surface the current span (which we could).

In general this seems bad because as you say it breaks the abstraction, and if you change your tracing back end it will break code that assumes a particular implementation.

@kalexmills
Copy link
Author

kalexmills commented Jan 25, 2020

Having a way to surface the current span could be useful in one of maybe a few different ways.

@kalexmills kalexmills reopened this Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants