The goal of this MR is to support collection of Rust traces by Python end users. Specifically this entails:
Connecting traces from Python to Rust.
Ensuring all network API calls are instrumented with tracing (QCS API client already has support for this with the tracing-opentelemetry feature).
Supporting the ability of Python users to configure and initialize Rust tracing subscribers.
Design & Implementation
The pyo3_opentelemetry::pypropagate macro will get the OpenTelemetry context from Python, deserialize it, and set it as the current context on the Rust side. This ensures traces initialized on the Python side are connected to traces within Rust.
You will see many calls to FutureExt::with_current_context on the Rust side. This ensures that any Rust futures propagate their traces across async / await. This is especially relevant for network calls.
In order to configure and initialize a tracing subscriber from Python, we add the tracing_subscriber module from pyo3-tracing-subscriber (see crates/python/src/lib.rs::qcs_sdk). We also autogenerate stubs for this Python module in crates/python/build.rs (stub files are formatted with cargo make format-tracing-subscriber).
Goals
The goal of this MR is to support collection of Rust traces by Python end users. Specifically this entails:
Design & Implementation
pyo3_opentelemetry::pypropagate
macro will get the OpenTelemetry context from Python, deserialize it, and set it as the current context on the Rust side. This ensures traces initialized on the Python side are connected to traces within Rust.tracing_subscriber
module frompyo3-tracing-subscriber
(see crates/python/src/lib.rs::qcs_sdk). We also autogenerate stubs for this Python module in crates/python/build.rs (stub files are formatted withcargo make format-tracing-subscriber
).