pub struct CapturingExporter {
pub spans: Mutex<Vec<SpanData>>,
}Expand description
Captures spans in memory instead of exporting them. Use in unit tests via
setup_with_exporter to prove that a span was actually recorded, not
just that its getters return the right values.
use rust_web_server::otel::{self, CapturingExporter, TracingConfig, ExporterConfig};
use std::sync::Arc;
let captured = Arc::new(CapturingExporter::new());
otel::setup_with_exporter(
TracingConfig { exporter: ExporterConfig::Discard, ..Default::default() },
Box::new(captured.clone()),
);
otel::span("db.query").end();
otel::flush();
assert_eq!(1, captured.take().len());Fields§
§spans: Mutex<Vec<SpanData>>Implementations§
Trait Implementations§
Source§impl Default for CapturingExporter
impl Default for CapturingExporter
Auto Trait Implementations§
impl !Freeze for CapturingExporter
impl RefUnwindSafe for CapturingExporter
impl Send for CapturingExporter
impl Sync for CapturingExporter
impl Unpin for CapturingExporter
impl UnsafeUnpin for CapturingExporter
impl UnwindSafe for CapturingExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more