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

[Question] current_trace_id and current_span_id are returning nil #138

Open
kurt-bautista opened this issue Jan 27, 2022 · 2 comments
Open

Comments

@kurt-bautista
Copy link

I was able to set up spandex+spandex_phoenix+spandex_datadog correctly I think, as I'm able to see traces in Datadog

I am now trying to set up distributed tracing, but when I call MyApp.Tracer.current_trace_id so I can pass the correct headers, I get nil. Any ideas on why that is? Thanks in advance :)

@GregMefford
Copy link
Member

It should be spandex_phoenix that initiates a span, either using the Telemetry hooks that Phoenix emits, or by putting use SpandexPhoenix in your Router or Endpoint module, depending on how you want it to work. The current span context is stored in the Process Dictionary, so if you cross a BEAM process boundary (e.g. Task.async or GenServer.call), you will have to manually pass that somehow across the boundary to continue the trace in the downstream process, similar to if it has been an RPC call to another microservice.

Without knowing more specifics, that's my best guess about what's going on, but let me know if that rings a bell for you or if you have more details you can share.

@kurt-bautista
Copy link
Author

Yup that was it, we had a couple of async calls. Follow up question though, our application makes extensive use of LiveViews. Is there any way we could start/continue the trace through those? Or would we have to manually start a new trace/pass the span context to every LiveView? Would making use of an ETS strategy help us in any way?

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