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
impl InitBuilder
Sourcepub fn instance(self, id: impl Into<String>) -> Self
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.
Sourcepub fn config_path(self, path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn config(self, cfg: EventsConfig) -> Self
pub fn config(self, cfg: EventsConfig) -> Self
Supply an EventsConfig directly — bypasses config_path.
Useful when the consumer already owns the config struct.
Sourcepub fn preset(self, preset: ServicePreset) -> Self
pub fn preset(self, preset: ServicePreset) -> Self
Select a preset (default: ServicePreset::Dev).
Sourcepub fn shutdown_budget(self, budget: Duration) -> Self
pub fn shutdown_budget(self, budget: Duration) -> Self
Override the default shutdown drain budget (default 250 ms).
Sourcepub fn with_panic_hook(self, enabled: bool) -> Self
pub fn with_panic_hook(self, enabled: bool) -> Self
Disable the panic hook (installed by default).
Sourcepub fn with_sighup_reload(self, enabled: bool) -> Self
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.
Sourcepub fn with_sink_for(self, tier: Tier, sink: Arc<dyn Sink>) -> Self
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.
Sourcepub fn sink_fallback(self, sink: Arc<dyn Sink>) -> Self
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.
Sourcepub async fn install(self) -> Result<InitGuard, InitError>
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.