Struct Recorder
pub struct Recorder { /* private fields */ }dial9 only.Expand description
Owns the recording state: the Dial9Handle, the flush thread, and (with
the pipeline feature) the background worker.
This is an RAII guard: dropping it flushes remaining events, seals the final
segment, and stops the worker. For a bounded drain of the background worker
(symbolize, compress, upload) call graceful_shutdown
instead.
Implementations§
§impl Recorder
impl Recorder
pub fn handle(&self) -> &Dial9Handle
pub fn handle(&self) -> &Dial9Handle
The recording handle for this recorder.
pub fn install_global_handle(&self) -> Result<(), InstallGlobalHandleError>
pub fn install_global_handle(&self) -> Result<(), InstallGlobalHandleError>
Publish this recorder’s handle as the process-global one.
When set, Dial9Handle::current resolves on every thread in the
process. When not set, it resolves only on threads a runtime integration
has installed a handle on.
Returns InstallGlobalHandleError and changes nothing if another handle
is already installed: two live globals would split one process’s events
across two traces. A recorder clears its own when it stops, so a later
install succeeds.
use dial9_core::buffer::MemoryBuffer;
use dial9_core::handle::Dial9Handle;
use dial9_core::recorder::recorder;
use dial9_trace_format::TraceEvent;
#[derive(TraceEvent)]
struct Tick {
#[traceevent(timestamp)]
timestamp_ns: u64,
}
let rec = recorder(MemoryBuffer::new(1 << 20)?).build();
rec.install_global_handle()?;
std::thread::spawn(|| {
// reachable here, with no handle plumbed in
Dial9Handle::current().record_event(Tick { timestamp_ns: 0 });
});pub fn start_time(&self) -> Option<u64>
pub fn start_time(&self) -> Option<u64>
Monotonic start time of the recorder in nanoseconds.
pub fn enable(&self)
pub fn enable(&self)
Enable recording.
pub fn disable(&self)
pub fn disable(&self)
Disable recording.
pub fn graceful_shutdown(self, timeout: Duration)
pub fn graceful_shutdown(self, timeout: Duration)
Flush remaining events, seal the final segment, and (with pipeline)
wait for the background worker to drain within timeout.
Call this after any runtime that owns worker threads has been dropped, so
their thread-local buffers have already been flushed. Consumes the
recorder so Drop becomes a no-op.
Failures during draining are logged.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Recorder
impl !RefUnwindSafe for Recorder
impl !UnwindSafe for Recorder
impl Send for Recorder
impl Sync for Recorder
impl Unpin for Recorder
impl UnsafeUnpin for Recorder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more