tracing/tracing-core/tests/common/mod.rs
Ole Schönburg 944abacb2d
core: Remove default impl of Collect::current_span (#1268)
- Removes the default implementation.
- Makes tracing_core::span::Current::unknown public so that implementers
of Collect can use it if they didn't implement current_span() before.
- Copy the old default implementation to all implementers of Collect.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2021-06-21 12:14:44 -04:00

36 lines
1.1 KiB
Rust

use tracing_core::{collect::Collect, metadata::Metadata, span, Event};
pub struct TestCollectorA;
impl Collect for TestCollectorA {
fn enabled(&self, _: &Metadata<'_>) -> bool {
true
}
fn new_span(&self, _: &span::Attributes<'_>) -> span::Id {
span::Id::from_u64(1)
}
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
fn event(&self, _: &Event<'_>) {}
fn enter(&self, _: &span::Id) {}
fn exit(&self, _: &span::Id) {}
fn current_span(&self) -> span::Current {
span::Current::unknown()
}
}
pub struct TestCollectorB;
impl Collect for TestCollectorB {
fn enabled(&self, _: &Metadata<'_>) -> bool {
true
}
fn new_span(&self, _: &span::Attributes<'_>) -> span::Id {
span::Id::from_u64(1)
}
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
fn event(&self, _: &Event<'_>) {}
fn enter(&self, _: &span::Id) {}
fn exit(&self, _: &span::Id) {}
fn current_span(&self) -> span::Current {
span::Current::unknown()
}
}