You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letmut layers = Vec::new();// conditionally make console_subscriber layerif using_console {// console_subscriber code
layers.push(console_subscriber.boxed());};let env_filter_builder = EnvFilter::builder();let layer = reload::Layer::new(layer);// Generate `apm_layer` and `logging_layer`// [1] `apm_layer` is the layer that calls tokio::spawn to create a named bg threadfnconsole_filter(meta:&tracing::Metadata<'_>) -> bool{if meta.is_event(){return !(meta.target().starts_with("runtime") || meta.target().starts_with("tokio"));}
!(meta.name().starts_with("runtime.") || meta.target().starts_with("tokio"))}let apm_layer = apm_layer.with_filter(FilterFn::new(console_filter));let logging_layer = logging_layer.with_filter(FilterFn::new(console_filter));
layers.push(apm_layer.boxed());
layers.push(logging_layer.boxed());
layers.push(layer.boxed());
tracing_subscriber::registry().with(layers).init();
My issue is the console_subscriber does not see the tokio::spawned background task in [1] apm_layer.
Due to not being able to setup the layers in phases, I can't seem to figure out how to acheive this.
I have attempted to use a reload::Layer around a Option<Vec<Layer>> to defer adding apm_layer and logging_layer until after .init but i get
a none to suprising panic, since the layer is initially added as None which skips a bunch of needed setup
a `Filtered` layer was used, but it had no `FilterId`; was it registered with the subscriber?
I'm not sure how to work around this at this point. Its not the biggest deal, but essentially all tokio::spawn before .init are not visible in the tokio-console.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have something (simplified here) like this
My issue is the
console_subscriber
does not see the tokio::spawned background task in [1]apm_layer
.Due to not being able to setup the layers in phases, I can't seem to figure out how to acheive this.
I have attempted to use a
reload::Layer
around aOption<Vec<Layer>>
to defer addingapm_layer
andlogging_layer
until after.init
but i geta none to suprising panic, since the layer is initially added as
None
which skips a bunch of needed setupI'm not sure how to work around this at this point. Its not the biggest deal, but essentially all tokio::spawn before
.init
are not visible in the tokio-console.Thanks
Beta Was this translation helpful? Give feedback.
All reactions