Skip to content
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

Add a way to dynamically set the span event configuration in a fmt::Layer #2957

Closed
lpraneis opened this issue Apr 26, 2024 · 0 comments · Fixed by #2962
Closed

Add a way to dynamically set the span event configuration in a fmt::Layer #2957

lpraneis opened this issue Apr 26, 2024 · 0 comments · Fixed by #2962

Comments

@lpraneis
Copy link
Contributor

Feature Request

Crates

tracing-subscriber

Motivation

I'm currently using reload::Layer with a Filtered layer to activate different tracing levels for various modules dynamically. However, it's not currently possible to modify the currently span event configuration since with_span_events can only be set when creating the layer. Due to #1629 , I'm not able to completely reload the layer.

The fmt::Layer has a few methods to mutably change aspects of the layer, namely writer_mut and set_ansi.
It seems like adding a set_span_events method in a similar vein to set_ansi would make sense?

The downside to this approach is that a span configuration could be changed mid-span, causing a CLOSE for an already entered span to not be emitted. I think this is acceptable, however, due to the reload layer already having the flexibility to change the underlying layer/writer/filter, but this will just need to be clear in docs.

I'm happy to implement this if the API makes sense! :)

Proposal

Add a new set_span_events method to tracing_subscriber::fmt::Layer

fn set_span_events(&mut self, kind: FmtSpan)

Alternatives

Alternative ways to approach this would be to fix #1629. The workarounds present in that issue are not applicable to my use-case as it removes the abilities for other layers to do filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant