Skip to main content

Crate obs_core

Crate obs_core 

Source
Expand description

Runtime engine for the obs SDK — the spine that user code emits into.

Phase-3 surface (specs/91-impl-plan.md tasks 3.1–3.15):

  • callsiteObsCallsite, atomic-Interest cache (spec 11 § 2).
  • observer — three-tier resolution + per-tier worker pool + StandardObserver (spec 11 §§ 3, 4 + 6.4).
  • registry — schema registry + ScrubbedEnvelope (spec 14).
  • envelope — envelope builder + projection helpers (spec 11 § 5).
  • scopeobs::scope! / obs::context! runtime support (spec 13 §§ 2, 3, 6).
  • instrumentedInstrumented<F> future adapter and Instrument / WithObserver traits (spec 13 § 3).
  • sampling — head sampler (spec 13 § 6).
  • filter — EnvFilter-shaped obs::Filter (spec 13 § 7).
  • audit_spool — AUDIT-tier disk spool (spec 11 § 6.4).
  • panic_hookinstall_panic_hook (spec 11 § 6.1).
  • span_traceobs::SpanTrace (spec 13 § 9).
  • sink — sink trait + writers (spec 20).

Re-exports§

pub use callsite::ObsCallsite;
pub use codegen_helpers::BuildableTo;
pub use codegen_helpers::EnumCount;
pub use codegen_helpers::FieldCapture;
pub use codegen_helpers::SpanCtx;
pub use codegen_helpers::SpanFrame;
pub use config::EventsConfig;
pub use config::SamplingConfig;
pub use config_watcher::ConfigWatcher;
pub use config_watcher::DEFAULT_DEBOUNCE;
pub use emit::Emit;
pub use envelope::Envelope;
pub use envelope::EventSchema;
pub use envelope::FieldMeta;
pub use envelope::FieldRole;
pub use filter::Filter;
pub use instrumented::Instrument;
pub use instrumented::Instrumented;
pub use instrumented::WithObserver;
pub use metric::MetricEmitter;
pub use metric::NoopMetricEmitter;
pub use observer::BuildError;
pub use observer::InMemoryHandle;
pub use observer::InMemoryObserver;
pub use observer::NoopObserver;
pub use observer::Observer;
pub use observer::StandardObserver;
pub use observer::StandardObserverBuilder;
pub use observer::ThreadObserverGuard;
pub use observer::WeakObserver;
pub use observer::WorkerCounters;
pub use observer::install_observer;
pub use observer::install_observer_arc;
pub use observer::observer;
pub use observer::observer_weak;
pub use observer::with_observer_task;
pub use observer::with_observer_task_sync;
pub use observer::with_observer_thread_local;
pub use observer::with_test_observer;
pub use panic_hook::install_panic_hook;
pub use propagator::ObsTraceCtx;
pub use propagator::W3cPropagator;
pub use propagator::extract_w3c;
pub use propagator::fresh_span_id;
pub use propagator::fresh_trace_id;
pub use propagator::inject_w3c;
pub use propagator::status_class;
pub use registry::ArrowEventSchema;
pub use registry::ArrowField;
pub use registry::ArrowLeafType;
pub use registry::ArrowSchemaModel;
pub use registry::ArrowStructBuilder;
pub use registry::CallsiteRecord;
pub use registry::CallsiteSource;
pub use registry::DecodeError;
pub use registry::ENVELOPE_COLUMNS;
pub use registry::EVENT_SCHEMAS;
pub use registry::EventSchemaErased;
pub use registry::ObsCallsiteRegistry;
pub use registry::OtelAttributeView;
pub use registry::OtlpValue;
pub use registry::SchemaRegistry;
pub use registry::ScrubError;
pub use registry::ScrubbedEnvelope;
pub use registry::callsite_id;
pub use registry::render_payload_json;
pub use registry::scrub_payload;
pub use resource::ResourceAttrs;
pub use sampling::SamplingDecision;
pub use sampling::decide as sample_decide;
pub use scope::ScopeField;
pub use scope::ScopeFrame;
pub use scope::ScopeFrameBuilder;
pub use scope::ScopeGuard;
pub use scope::ScopeKind;
pub use sink::FanOutSink;
pub use sink::FormatterStyle;
pub use sink::InMemorySink;
pub use sink::LevelSplitWriter;
pub use sink::MakeWriter;
pub use sink::NdjsonFileSink;
pub use sink::NonBlockingWriter;
pub use sink::NoopSink;
pub use sink::RollingFileWriter;
pub use sink::RollingFileWriterBuilder;
pub use sink::RollingPolicy;
pub use sink::Sink;
pub use sink::StderrWriter;
pub use sink::StdoutSink;
pub use sink::StdoutWriter;
pub use sink::TeeWriter;
pub use sink::WorkerGuard;
pub use span_trace::SpanTrace;

Modules§

audit_spool
AUDIT spool — binary length-prefixed envelope file with CRC32C tail integrity. Spec 11 § 6.4.
callsite
ObsCallsite and the atomic Interest cache.
codegen_helpers
Auxiliary trait surface — the small set of cross-cutting traits the codegen and the bridge use to talk to the runtime without dragging the whole event type into every consumer. Spec 12 § 3.6.
config
EventsConfig — runtime-tunable configuration loaded from obs.yaml and exposed via ArcSwap for live reload. Spec 15 + spec 93 P0-9.
config_watcher
notify-driven file watcher for obs.yaml reload. Spec 15 § 5.3 / spec 93 P0-9.
emit
Emit blanket trait — provides .emit() / .emit_at(sev) on every type that implements EventSchema.
envelope
Envelope construction and projection helpers.
filter
obs::Filter — EnvFilter-shaped DSL ported from tracing-subscriber::filter::env.
forensic
Per-callsite rate limiter used by the obs::forensic! macro.
instrumented
Instrumented<F> — async scope + observer adapter.
metric
MetricEmitter — visitor implemented by metric sinks. Spec 12 § 3.6.
observer
Three-tier observer resolution + the Observer trait.
panic_hook
install_panic_hook — emits one ObsPanicked event then calls Observer::shutdown_blocking(2s) so the inflight sinks have a chance to flush before the prior hook (potentially panic = abort) takes the process down.
propagator
W3C Trace Context propagation. Spec 20 § 2.6 / spec 40 § 1.
registry
Schema registry — EventSchemaErased object-safe trait, the linkme-collected EVENT_SCHEMAS distributed slice, the runtime SchemaRegistry, and the ScrubbedEnvelope worker→sink handoff.
resource
ResourceAttrs — workspace-shared resource attribute set held by the observer. Spec 20 § 2.1 / spec 94 § 2.7 / P1-E.
sampling
Head sampler — per (full_name, sev) rate decision.
scope
obs::scope! and obs::context! runtime support — task-local / thread-local stacks of ScopeFrames, the tail-on-error ring buffer, and the auto-fill machinery used by EventSchema::project.
self_events_public
Public re-exports for self-event helpers consumed by sinks/middleware that emit them on behalf of the runtime (e.g. OTLP trace sink emits ObsSpanPairOrphaned after pair_timeout). Spec 93 P1-2 + P1-7.
sink
Sinks consume ScrubbedEnvelope and ship it to a destination (stdout, NDJSON file, OTLP, ClickHouse, etc.).
span_trace
obs::SpanTrace — capture the active scope/span ancestry for attaching to error types.
wire
Wire-format helpers for obs.

Structs§

ObsBatch
ObsEnvelope

Enums§

Cardinality
Classification
FieldKind
MetricKind
SamplingReason
Severity
Tier

Constants§

ENVELOPE_FORMAT_VER
Wire-format version of the ObsEnvelope / ObsBatch shape.

Functions§

cap_external_string
Cap an external string at max_bytes (UTF-8-safe boundary), append the …<truncated:N> suffix when the input was clipped, and emit one ObsLabelOversized self-event for telemetry. Returns the (possibly truncated) string. Spec 95 § 3.10 / P2-AH.
now_ns
Wall-clock timestamp in nanoseconds since the Unix epoch, saturated at u64::MAX.
self_event
Build a labels-only self-event envelope with sampling_reason = SAMPLING_REASON_RUNTIME and the current wall-clock ts_ns.