Skip to main content

RecorderBuilder

Struct RecorderBuilder 

Source
pub struct RecorderBuilder<M: BufferMode = Disk> { /* private fields */ }
Expand description

Builder for a runtime-agnostic Recorder. See recorder.

Implementations§

Source§

impl<M: BufferMode> RecorderBuilder<M>

Source

pub fn source(self, source: impl Source + 'static) -> Self

Register a Source drained by the flush thread each cycle.

Source

pub fn source_names(&self) -> impl Iterator<Item = &str> + '_

Names of the registered sources, in registration order.

Source

pub fn writer_boot_id(&self) -> Option<&str>

The writer’s per-process namespace boot id, or None before set_namespace has run.

Source

pub fn segment_metadata( self, entries: impl IntoIterator<Item = (String, String)>, ) -> Self

Static metadata written into every rotated segment header. Merged across calls (and across the tokio layer); on a key collision the later value wins.

§Examples
use dial9_core::buffer::MemoryBuffer;
use dial9_core::recorder::recorder;

let recorder = recorder(MemoryBuffer::new(1024 * 1024)?)
    .segment_metadata([("service".into(), "checkout".into())])
    .segment_metadata([("environment".into(), "production".into())])
    .segment_metadata([("service".into(), "payments".into())])
    .build();

// Metadata is merged across calls. The third call overrides `service`
// from the first, so its value is `payments`.
Source

pub fn metrics_sink(self, sink: BoxEntrySink) -> Self

Metrics sink for the flush (and, with pipeline, worker) threads. Defaults to discarding flush metrics.

Source

pub fn build(self) -> Recorder

Start the recorder and begin recording.

Chain paused beforehand to build without recording, then start it later with Recorder::enable.

Yields a disabled recorder when the writer could not be created (see recorder_or_disabled); the sources and pipeline configured on the way here are never started.

Source

pub fn paused(self) -> Self

Build without recording. Recorder::enable starts it later.

Use for a recorder that should exist but stay quiet until something turns it on; for permanently-off telemetry prefer recorder_disabled, which allocates no writer at all.

Source§

impl<M: BufferMode> RecorderBuilder<M>

Source

pub fn pipe(self, processor: impl SegmentProcessor + 'static) -> Self

Available on crate feature pipeline only.

Append a segment processor (compress, symbolize, upload, write-back), replacing dial9’s default pipeline with your own stages.

Source

pub fn processors(self, processors: Vec<Box<dyn SegmentProcessor>>) -> Self

Available on crate feature pipeline only.

Set the full processor pipeline at once, replacing dial9’s default and anything added with pipe. Use this when you already have a built list, or pipe to append incrementally.

Source

pub fn terminal_processor( self, processor: impl SegmentProcessor + 'static, ) -> Self

Available on crate feature pipeline only.

Replace write-back as the last stage of the default pipeline, so sealed segments are shipped elsewhere instead of written back to disk. This also makes processing meaningful even with no other stage, so the worker still runs.

Ignored when a custom pipeline is set. The S3 uploader is wired up this way.

Source

pub fn worker_poll_interval(self, interval: Duration) -> Self

Available on crate feature pipeline only.

How often the background worker polls for sealed segments.

Source

pub fn trigger(self, trigger: DumpRx) -> Self

Available on crate feature pipeline only.

Trigger receiver switching the worker into on-demand dump mode; see crate::dump. None keeps continuous mode.

Source

pub fn with_dump_trigger<F>(self, configure: F) -> Self
where F: FnOnce(&mut DumpTriggerConfig),

Available on crate feature pipeline only.

Enable on-demand dump mode: the background worker runs the pipeline only when a dump is requested through the DumpTrigger, reachable from any recording thread via Dial9Handle::dump_trigger. Pass |_| {} for the default, or |t| { t.debounce(window); } to coalesce bursts.

Trait Implementations§

Source§

impl<M: BufferMode> Debug for RecorderBuilder<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: BufferMode> RecorderSourceExt for RecorderBuilder<M>

Source§

fn source(self, source: impl Source + 'static) -> Self

Register a Source with the underlying recording recorder.
Source§

fn on_recording_start( self, hook: impl FnOnce(&Dial9Handle) + Send + 'static, ) -> Self

Register a hook run once, with the live Dial9Handle, when the recorder starts recording.
Source§

fn on_recording_thread_start<F, T>(self, hook: F) -> Self
where F: Fn() -> T + Send + Sync + 'static, T: FnOnce() + Send + 'static,

Register a hook run on each of dial9’s own threads (the flush thread and, with pipeline, the background worker) before it starts, returning a teardown run when it stops. Defaults to a no-op.
Source§

fn with_custom_events<F>(self, config: CustomEventsConfig, callback: F) -> Self
where F: for<'a> FnMut(&mut CustomEventsContext<'a>) + Send + 'static,

Register a callback that dial9 invokes on the flush thread at the config’s interval to emit custom events. Sugar for source with a CustomEventsSource. Not tokio-coupled — works on the plain recorder and the tokio builder.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
Source§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more