Skip to main content

InitBuilder

Struct InitBuilder 

Source
pub struct InitBuilder { /* private fields */ }
Expand description

Builder returned by init_for_service. Configure the service, preset, and any per-tier sink overrides; finish with Self::install.

Implementations§

Source§

impl InitBuilder

Source

pub fn instance(self, id: impl Into<String>) -> Self

Override the instance identity (hostname, pod id, VM id). When unset, OTEL_SERVICE_INSTANCE_ID env is consulted, then empty.

Source

pub fn config_path(self, path: impl Into<PathBuf>) -> Self

Load EventsConfig from path. YAML root must parse as EventsConfig — typos surface with the keys-hint from EventsConfig::from_yaml_str.

Source

pub fn config(self, cfg: EventsConfig) -> Self

Supply an EventsConfig directly — bypasses config_path. Useful when the consumer already owns the config struct.

Source

pub fn preset(self, preset: ServicePreset) -> Self

Select a preset (default: ServicePreset::Dev).

Source

pub fn shutdown_budget(self, budget: Duration) -> Self

Override the default shutdown drain budget (default 250 ms).

Source

pub fn with_panic_hook(self, enabled: bool) -> Self

Disable the panic hook (installed by default).

Source

pub fn with_sighup_reload(self, enabled: bool) -> Self

Spawn a SIGHUP handler that re-parses config_path and calls StandardObserver::reload_config. Only takes effect when config_path is set. Unix-only.

Source

pub fn with_sink_for(self, tier: Tier, sink: Arc<dyn Sink>) -> Self

Attach an additional sink for tier. Called before Self::install; composes on top of the chosen preset. To fan out to multiple sinks on the same tier, construct a obs_core::FanOutSink and pass it here.

Source

pub fn sink_fallback(self, sink: Arc<dyn Sink>) -> Self

Override the fallback sink (the sink tiers without a specific binding route to). When unset, defaults to StdoutSink::default for Dev, none for Production, and unused for InMemory.

Source

pub async fn install(self) -> Result<InitGuard, InitError>

Build the observer, install it, install the panic hook (when enabled), install the tracing bridge (when configured), spawn the SIGHUP task (when configured), and return an RAII guard that drains the queue on drop.

§Errors

Returns anyhow::Error when the config file cannot be read, when parsing / validation fails, when the observer builder rejects the config, or when the tracing bridge has already been installed.

Trait Implementations§

Source§

impl Debug for InitBuilder

Source§

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

Formats the value using the given formatter. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.