torvyn-observability
Tracing, metrics, diagnostics, and runtime inspection for the Torvyn reactive streaming runtime.
This crate provides the observability subsystem defined in HLI Doc 05.
It implements the EventSink trait from
torvyn-types for hot-path recording and manages three internal
subsystems:
- Metrics: Pre-allocated counters, histograms, and gauges scoped per flow, component, and stream.
- Tracing: Trace context propagation, sampling, and span ring buffers for retroactive export.
- Events: Structured diagnostic events for lifecycle, performance, error, security, and resource state transitions.
Architecture
The [ObservabilityCollector] is the central orchestrator. It:
- Implements
EventSinkfor the reactor, resource manager, and host lifecycle manager. - Owns the [
MetricsRegistry] that holds pre-allocated per-flow metrics. - Manages the event channel and diagnostic event buffer.
- Provides [
FlowObserver] handles to the reactor for per-flow recording.
Observability Levels
| Level | Overhead | What's collected |
|---|---|---|
| Off | 0 | Nothing |
| Production | < 500ns/element | Counters, histograms, sampled traces |
| Diagnostic | < 2μs/element | All of Production + per-element spans, events |
Level switching is atomic and does not require restarting flows.