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

Span control in MakeWriter<'_> #3194

Open
feelingnothing opened this issue Jan 15, 2025 · 0 comments
Open

Span control in MakeWriter<'_> #3194

feelingnothing opened this issue Jan 15, 2025 · 0 comments

Comments

@feelingnothing
Copy link

Feature Request

Crates

tracing-subcriber

Motivation

For the moment only metadata available in the MakeWriter is event's metadata, which is very limited. A basic use-case of creating different writers for each span with certain value specified is impossible.
I don't think my use-case is very niche. I have a tonic service that creates workers, each with unique id. I want to store a log for each bot separate.
The most logical solution for that came to mind is to create a worker-wide span with its id in the span and open/drop (a handle) based on span's lifetime. Create/open a file and write to it.
Now this is a motivation part. There is no API to either get access to span's data at all.

Proposal

Add on_span_enter, on_exit and Context<'_, S> to the MakeWriter trait.

Alternatives

Can't find one, FmtContext's constructor being behind private does not let me format my own fields in the record.

Comments

This is my code that's trying to circumvent this: https://gist.github.com/feelingnothing/2db9cc4734aece2d3fdaa2601d53b8a8

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

No branches or pull requests

1 participant