Struct opentracingrust::utils::ReporterThread
[−]
[src]
pub struct ReporterThread { /* fields omitted */ }
A basic span reporter backed by a background thread.
The reporter spawns a thread that loops until stopped and waits for FinishedSpan
s.
Every time a finished span is received the ReporterFn
closure is called with it.
The ReporterFn
closure is responsible for shipping the received spans.
The ReporterThread
also supports clean shutdown of the receiver thread.
When ReporterThread::stop
is called or an instance is dropped:
- The calling thread is paused for the
stop_delay
duration. This allows the reporter thread to process anyFinishedSpan
s still in the channel. - The background thread is informend to shutdown and the calling thread joins it.
- As soon as any
FinishedSpan
is processed or receiving times out the thread is stopped. Receiving spans times out every 50 milliseconds.
Methods
impl ReporterThread
[src]
fn new<ReporterFn>(
receiver: SpanReceiver,
reporter: ReporterFn
) -> ReporterThread where
ReporterFn: FnMut(FinishedSpan) + Send + 'static,
[src]
receiver: SpanReceiver,
reporter: ReporterFn
) -> ReporterThread where
ReporterFn: FnMut(FinishedSpan) + Send + 'static,
Creates a new reporter waiting for spans on the receiver
.
The reporter starts with a spawned thread and runs until stopped or dropped.
fn new_with_duration<ReporterFn>(
receiver: SpanReceiver,
stop_delay: Duration,
reporter: ReporterFn
) -> ReporterThread where
ReporterFn: FnMut(FinishedSpan) + Send + 'static,
[src]
receiver: SpanReceiver,
stop_delay: Duration,
reporter: ReporterFn
) -> ReporterThread where
ReporterFn: FnMut(FinishedSpan) + Send + 'static,
Version of new
that also sets the stop_delay
.
fn stop_delay(&mut self, stop_delay: Duration)
[src]
Updates the stop_delay
for when the thread is stopped.
fn stop(&mut self)
[src]
Stops the background thread and joins it.