Expand description
§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
MetricsRegistrythat holds pre-allocated per-flow metrics. - Manages the event channel and diagnostic event buffer.
- Provides
FlowObserverhandles 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.
Re-exports§
pub use bench::BenchmarkReport;pub use collector::FlowObserver;pub use collector::ObservabilityCollector;pub use config::ObservabilityConfig;pub use events::DiagnosticEvent;pub use events::EventCategory;pub use events::EventPayload;pub use metrics::Counter;pub use metrics::FlowMetricsSnapshot;pub use metrics::Gauge;pub use metrics::Histogram;pub use metrics::HistogramSnapshot;pub use metrics::MetricsRegistry;pub use metrics::LATENCY_BUCKETS_NS;pub use metrics::SIZE_BUCKETS_BYTES;pub use tracer::CompactSpanRecord;pub use tracer::FlowTraceContext;pub use tracer::Sampler;pub use tracer::SamplingDecision;pub use tracer::SpanRingBuffer;pub use tracer::TraceFlags;
Modules§
- bench
- Benchmarking integration.
- collector
- Central observability collector.
- config
- Observability configuration types.
- events
- Diagnostic event subsystem.
- export
- Export subsystem: channel, JSON, and OTLP exporters.
- metrics
- Metrics subsystem: counters, histograms, gauges, and the metric registry.
- tracer
- Tracing subsystem: context, sampling, and span ring buffers.