pub struct SelfEventBuilder { /* private fields */ }Expand description
Fluent builder for runtime-style self-events.
Sinks, middleware, and tok’s own init paths emit labels-only
self-events (ObsConfigReloaded, ObsBatchSinkUploaded, …). The
plain obs_core::self_event helper returns a bare envelope that
the caller mutates; the builder wraps that in a fluent chain for
call sites that set two or more labels.
use obs_kit::SelfEventBuilder;
use obs_kit::{Severity, Tier};
SelfEventBuilder::new("mylib.v1.WorkerRestart", Tier::Log, Severity::Warn)
.label("reason", "timeout")
.label("worker_id", "42")
.emit();Implementations§
Source§impl SelfEventBuilder
impl SelfEventBuilder
Sourcepub fn new(full_name: &str, tier: Tier, sev: Severity) -> Self
pub fn new(full_name: &str, tier: Tier, sev: Severity) -> Self
Start a new builder with the given full_name, tier, and
sev. sampling_reason is set to SAMPLING_REASON_RUNTIME
and ts_ns to the current wall-clock via
obs_core::self_event.
Sourcepub fn label(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn label(self, key: impl Into<String>, value: impl Into<String>) -> Self
Insert (or replace) a label.
Sourcepub fn labels<I, K, V>(self, iter: I) -> Self
pub fn labels<I, K, V>(self, iter: I) -> Self
Extend the envelope with an iterator of (key, value) pairs.
Useful when the labels come from a pre-built
BTreeMap/HashMap.
Sourcepub fn build(self) -> ObsEnvelope
pub fn build(self) -> ObsEnvelope
Return the built envelope without emitting. Useful for tests and for call sites that want to attach a payload before handing the envelope to a sink manually.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SelfEventBuilder
impl RefUnwindSafe for SelfEventBuilder
impl Send for SelfEventBuilder
impl Sync for SelfEventBuilder
impl Unpin for SelfEventBuilder
impl UnsafeUnpin for SelfEventBuilder
impl UnwindSafe for SelfEventBuilder
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> 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