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

Make tracing_subscriber::span::{Data, Store, etc} public #505

Closed
anp opened this issue Jan 3, 2020 · 3 comments · Fixed by #566
Closed

Make tracing_subscriber::span::{Data, Store, etc} public #505

anp opened this issue Jan 3, 2020 · 3 comments · Fixed by #566

Comments

@anp
Copy link
Contributor

anp commented Jan 3, 2020

Feature Request

Crates

tracing-subscriber

Motivation

I'm implementing a Subscriber similar to Formatter in many ways and would like to reuse the span allocation it makes use of in span::Store.

Proposal

Is it safe to expose these types as directly usable? That would probably be my preference to avoid having to implement my own slab/locking/etc setup.

Alternatives

Is it possible to imagine a version of the crate where all I/O is done in layers separately from the span and metadata management?

Maybe Subscriber could be blanket impl'd for structs that implement some smaller trait, named something like Storage?

@davidbarsky
Copy link
Member

@anp If I'm not mistaken, the LookupSpan trait + Registry struct should address your issue. However, you'd implement a Layer instead of Subscriber. Here's a basic one done by @tobz: https://github.com/metrics-rs/metrics-tracing-test/blob/master/src/layer.rs.

@anp
Copy link
Contributor Author

anp commented Jan 3, 2020

Huzzah! I think this is perfect actually, I would like all of my code to live in layers and to have the subscriber just act as the registry.

I'm tempted to rephrase this as a docs/tutorial request but I'm not well-versed enough in the subscriber crate yet to know where would be the best place.

@davidbarsky
Copy link
Member

@anp you're right, this does need to be documented and it's not yet documented. it really does.

@hawkw hawkw closed this as completed in #566 Feb 4, 2020
hawkw added a commit that referenced this issue Feb 4, 2020
Depends on #564 

This commit adds a new section to the `Layer` docs on how `Layer`s and
`Subscriber`s are composed. Additionally, it updates the docs to prefer
the use of `SubscriberExt::with` over `Layer::with_subscriber`.

Additionally, I've fixed how `SubscriberExt::with` is implemented, so
that `Layer`s may use `with_subscriber` as a callback for composition.

Closes  #452
Closes #505 (IMO)
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.

2 participants