I'm writing a Pingora proxy instance. It uses multiple async functions from a trait to indicate various stages. There is a common context that I can provide. I am trying to instrument the whole request lifecycle, however, since Tokio/Pingora can call the stage functions at anytime or on any thread. This does present some challenges to measuring the stages underneath the whole request parent span.
How can I get the current parent span to be active once the functions are called back?
What I'm using:
- The Open Telemetry crates
- The Tokio tracing crate
I've tried:
- storing the various flavors of
Span
in my context - storing the current tracing context in my context then calling
.attach()
What I'm looking for in a tracing graph:
|-- Request/Parent Span ---------------------------------------|
|-- Stage 1 Span --|
|-- Stage 2 Span --|
|-- Upstream --|
tracing
within your application which is configured to export OpenTelemetry data via thetracing-opentelemetry
subscriber? Or are you doing something else?