pub struct ChainedSink { /* private fields */ }Expand description
Forwards each emit to every sink in the chain, synchronously and in registration order.
Use a chain when one emit must reach multiple transports or telemetry destinations. A slow child sink delays later children and the caller.
§Examples
use std::sync::Arc;
use spectra_core::{ChainedSink, RecordingSink, SpectraSink};
let first = Arc::new(RecordingSink::new());
let second = Arc::new(RecordingSink::new());
let chain = ChainedSink::new()
.push(Arc::clone(&first) as Arc<dyn SpectraSink>)
.push(Arc::clone(&second) as Arc<dyn SpectraSink>);
chain.record_counter("cache_hits", &[("region", "us")], 1);
assert_eq!(first.counters().len(), 1);
assert_eq!(second.counters().len(), 1);Implementations§
Source§impl ChainedSink
impl ChainedSink
Sourcepub fn new() -> ChainedSink
pub fn new() -> ChainedSink
Creates an empty sink chain.
Sourcepub fn push(self, sink: Arc<dyn SpectraSink>) -> ChainedSink
pub fn push(self, sink: Arc<dyn SpectraSink>) -> ChainedSink
Appends a sink to the end of the chain.
Trait Implementations§
Source§impl Default for ChainedSink
impl Default for ChainedSink
Source§fn default() -> ChainedSink
fn default() -> ChainedSink
Returns the “default value” for a type. Read more
Source§impl SpectraSink for ChainedSink
impl SpectraSink for ChainedSink
Auto Trait Implementations§
impl !RefUnwindSafe for ChainedSink
impl !UnwindSafe for ChainedSink
impl Freeze for ChainedSink
impl Send for ChainedSink
impl Sync for ChainedSink
impl Unpin for ChainedSink
impl UnsafeUnpin for ChainedSink
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