Skip to content

Conversation

BiagioFesta
Copy link

Motivation

tracing::Event seems quite stable to return a &'static Metadata<'static>; thus, in the MakeWriter we could relax lifetime constrains so it would be easier to implement aSelf::Writer which requires a reference to the meta

@BiagioFesta BiagioFesta requested review from hawkw and a team as code owners September 7, 2025 22:21
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata for events produced by the tracing-log adapter cannot have the 'static lifetime, as log::Records have a generic lifetime. Therefore, this change would make tracing_subscriber::fmt incompatible with tracing-log.

Unfortunately, I don't think we can make this change for that reason. Sorry! Depending on what you need &'static Metadata for, there might be another solution where we can provide the make_writer_for with static metadata when it is coming from a tracing macro via a separate method, with a default implementation that calls into the generic-lifetime version.

@BiagioFesta
Copy link
Author

Thanks for the clarification! Yeah, I probably should have checked the tracing-log integration first before submitting the PR. The change seemed straightforward so I thought I'd open a PR to get some initial feedback.

I'm currently looking at the code from my phone while on the train (so I might be missing something :D), but doesn't dispatch_record end up creating a static metadata anyway?

In any case, what I'm actually trying to do is create a Writer that can hold a reference to the event's metadata

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 this pull request may close these issues.

2 participants