pub struct TracingHandle {
pub(crate) flush_tx: Option<Sender<Sender<()>>>,
pub(crate) stdout_writer: IndicatifWriter<Stdout>,
pub(crate) stderr_writer: IndicatifWriter<Stderr>,
}
Fields§
§flush_tx: Option<Sender<Sender<()>>>
A channel that can be sent to whenever traces/metrics should be flushed. Once flushing is finished, the sent oneshot::Sender will get triggered.
stdout_writer: IndicatifWriter<Stdout>
§stderr_writer: IndicatifWriter<Stderr>
Implementations§
source§impl TracingHandle
impl TracingHandle
sourcepub fn get_stdout_writer(&self) -> IndicatifWriter<Stdout>
pub fn get_stdout_writer(&self) -> IndicatifWriter<Stdout>
Returns a writer for std::io::Stdout that ensures its output will not be clobbered by active progress bars.
Instead of println!(...)
prefer writeln!(handle.get_stdout_writer(), ...)
sourcepub fn get_stderr_writer(&self) -> IndicatifWriter<Stderr>
pub fn get_stderr_writer(&self) -> IndicatifWriter<Stderr>
Returns a writer for std::io::Stderr that ensures its output will not be clobbered by active progress bars.
Instead of println!(...)
prefer writeln!(handle.get_stderr_writer(), ...)
.
sourcepub async fn flush(&self) -> Result<(), Error>
pub async fn flush(&self) -> Result<(), Error>
This will flush possible attached tracing providers, e.g. otlp exported, if enabled. If there is none enabled this will result in a noop.
It will wait until the flush is complete.
sourcepub async fn shutdown(&self) -> Result<(), Error>
pub async fn shutdown(&self) -> Result<(), Error>
This will flush all all attached tracing providers and will wait until the flush is completed. If no tracing providers like otlp are attached then this will be a noop.
This should only be called on a regular shutdown. If you correctly need to shutdown tracing on ctrl_c use force_shutdown otherwise you will get otlp errors.
sourcepub async fn force_shutdown(&self) -> Result<(), Error>
pub async fn force_shutdown(&self) -> Result<(), Error>
This will flush all all attached tracing providers and will wait until the flush is completed. After this it will do some other necessary cleanup. If no tracing providers like otlp are attached then this will be a noop.
This should only be used if the tool received an ctrl_c otherwise you will get otlp errors. If you need to shutdown tracing on a regular exit, you should use the shutdown method.
Trait Implementations§
source§impl Clone for TracingHandle
impl Clone for TracingHandle
source§fn clone(&self) -> TracingHandle
fn clone(&self) -> TracingHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for TracingHandle
impl RefUnwindSafe for TracingHandle
impl Send for TracingHandle
impl Sync for TracingHandle
impl Unpin for TracingHandle
impl UnwindSafe for TracingHandle
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request