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

Context switching between Natchez and backend instrumentation #706

Open
bpholt opened this issue Jan 20, 2023 · 2 comments
Open

Context switching between Natchez and backend instrumentation #706

bpholt opened this issue Jan 20, 2023 · 2 comments

Comments

@bpholt
Copy link
Member

bpholt commented Jan 20, 2023

Many of backends support auto-instrumentation for certain popular (non-Scala FP) libraries, typically using Java ThreadLocals to maintain the current span. If you're working in an app that has a tagless final / cats effect portion (where Natchez is a good fit) and also a non-FP Scala portion, it's not clear how best to propagate the span context between the two worlds in the same app.

I don't have a good solution for this, but if one exists, it would be nice to add it to the library, or at least document it. If one doesn't exist, that would also be good to document, so users can avoid frustration.

@dimitarg
Copy link

dimitarg commented Feb 25, 2023

Not a contributor to this repository. It's a very broad question. I don't believe anything can solve this in full generality - we're working on a similar problem right now.I don't have anything working well yet. I think a starting point might be to use the opentelemetry backend - if your solution supports it - then at the boundary between your Natchez-aware code and auto-instrumented, obtain the "current" kernel / trace id and mess with contexts / executors, relying on the global opentelemetry instance. That's my game plan anyways.

@armanbilge
Copy link
Member

I don't believe anything can solve this in full generality - we're working on a similar problem right now

Yes, I believe that's a good summary.

then at the boundary between your Natchez-aware code and auto-instrumented, obtain the "current" kernel / trace id and mess with contexts / executors,

We had some discussion on the Typelevel Discord, it should be solvable. The issue is nailing down the API to expose.

https://discord.com/channels/632277896739946517/839263556754472990/1072641756111306763

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

3 participants