-
Notifications
You must be signed in to change notification settings - Fork 86
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
WithContext not populated when a reload layer is used #121
Comments
We are running into the same problem with tracing_opentelemetry 0.23.0. Removing the reload layer makes the |
I probably won't have time to look into this myself but happy to review a PR that tries to address this. |
that bug is always exists |
I am trying to investigate this issue Discovered, the reload method. It will only downcast_ref NoneLayerMarker. This is the code for tracing-subscriber: #[doc(hidden)]
unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()> {
// Safety: it is generally unsafe to downcast through a reload, because
// the pointer can be invalidated after the lock is dropped.
// `NoneLayerMarker` is a special case because it
// is never dereferenced.
//
// Additionally, even if the marker type *is* dereferenced (which it
// never will be), the pointer should be valid even if the subscriber
// is reloaded, because all `NoneLayerMarker` pointers that we return
// actually point to the global static singleton `NoneLayerMarker`,
// rather than to a field inside the lock.
if id == TypeId::of::<layer::NoneLayerMarker>() {
return try_lock!(self.inner.read(), else return None).downcast_raw(id);
}
None
} According to my investigation, this function always returns None. It will never downcast_raw load WithContext. How can I modify it? |
Bug Report
Hi there. I am building a cli which may-or-may-not have opentelemetry enabled. We initialize tracing early on and conditionally enable opentelemetry based on some flags. We use reload layers starting with
None
to allow enabling layers later on. Everything works, except context propagation. If the layer is not present when the registry is init'ed,WithContext
is not set up correctly meaningset_parent
and friends silently fails due to not being able to downcast the subscriber (L142).tracing-opentelemetry/src/span_ext.rs
Lines 139 to 150 in 5e3354e
I can confirm this does not work as expected even if the reload layer is initialized with
Some(T)
either. The layer does work if you use a Some(T) without the reload layer, however.Version
Platform
macOS / Linux
The text was updated successfully, but these errors were encountered: