Opentelemetry context propagation in the QCS SDK broke when py_function_sync_async migrated from QCS SDK to this repository. The missing bit is the with_current_context and corresponding (use opentelemetry::trace::FutureExt;):
macro_rules! py_function_sync_async {
(
$(#[$meta: meta])+
async fn $name: ident($($(#[$arg_meta: meta])*$arg: ident : $kind: ty),* $(,)?) $(-> $ret: ty)? $body: block
) => {
async fn $name($($arg: $kind,)*) $(-> $ret)? {
$body
}
::paste::paste! {
$(#[$meta])+
#[allow(clippy::too_many_arguments)]
#[pyo3(name = $name "")]
pub fn [< py_ $name >](py: ::pyo3::Python<'_> $(, $(#[$arg_meta])*$arg: $kind)*) $(-> $ret)? {
use opentelemetry::trace::FutureExt;
$crate::py_sync::py_sync!(py, $name($($arg),*).with_current_context())
}
$(#[$meta])+
#[pyo3(name = $name "_async")]
#[allow(clippy::too_many_arguments)]
pub fn [< py_ $name _async >](py: ::pyo3::Python<'_> $(, $(#[$arg_meta])*$arg: $kind)*) -> ::pyo3::PyResult<&::pyo3::PyAny> {
use opentelemetry::trace::FutureExt;
$crate::py_sync::py_async!(py, $name($($arg),*).with_current_context())
}
}
};
}
To avoid introducing anything Opentelemetry in this repository, we should support this macro matching on a sync function that returns a future.
Opentelemetry context propagation in the QCS SDK broke when
py_function_sync_asyncmigrated from QCS SDK to this repository. The missing bit is thewith_current_contextand corresponding (use opentelemetry::trace::FutureExt;):To avoid introducing anything Opentelemetry in this repository, we should support this macro matching on a sync function that returns a future.