pub struct Observability { /* private fields */ }Expand description
Public observability facade.
Wraps the lock-free atomic counters (always present) and — in later
rollout steps — the feature-gated OpenTelemetry instrument holder.
Recording sites in transport, api, and crypto call methods on this
struct via an Arc<Observability> borrowed from PhantomListener /
PhantomSession.
Implementations§
Source§impl Observability
impl Observability
Sourcepub fn new(config: ObservabilityConfig) -> Arc<Self>
pub fn new(config: ObservabilityConfig) -> Arc<Self>
Construct a new observability handle.
Returns an Arc because the handle is shared between recording sites
(in Session, Listener, handshake code paths) and the OTel
observable callbacks.
Call once per process. When telemetry-otel is on, this
registers observable-instrument callbacks against the global OTel
meter; those callbacks are never unregistered (the meter owns them
for process life). Constructing many Observability instances would
therefore accumulate callbacks. PhantomListener / PhantomSession
each hold one shared Arc<Observability> — that is the intended
usage.
Sourcepub fn config(&self) -> &ObservabilityConfig
pub fn config(&self) -> &ObservabilityConfig
Borrow the captured configuration.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Capture a cold-path snapshot of all counters and gauges.
pub fn record_send(&self, bytes: usize, leg: LegType)
pub fn record_recv(&self, bytes: usize, leg: LegType)
pub fn record_encrypt_ns(&self, duration_ns: u64)
pub fn record_decrypt_ns(&self, duration_ns: u64)
pub fn record_rtt_us(&self, rtt_us: u64, path_id: u8)
Sourcepub fn session_opened(&self, leg: LegType)
pub fn session_opened(&self, leg: LegType)
Mark a new session as opened. Updates both the lock-free gauge and
the OTel UpDownCounter (when the telemetry-otel feature is on).
pub fn session_closed(&self, leg: LegType)
pub fn stream_opened(&self)
pub fn stream_closed(&self)
Sourcepub fn record_handshake_success(&self, duration_ns: u64)
pub fn record_handshake_success(&self, duration_ns: u64)
Record a successful handshake completion with its duration (ns).
Transitional API — step 7 introduces a labeled record_handshake
that takes (outcome, leg, cipher_suite, version) and writes to an
OTel Histogram. Until then, the duration accumulates in atomic
sum+count fields surfaced via Self::snapshot.
Sourcepub fn record_handshake_failure(&self)
pub fn record_handshake_failure(&self)
Record a handshake failure. Cause attribution (cookie / signature / transcript / KEM) lands with the labeled API in step 7.
Sourcepub fn record_handshake(
&self,
duration: Duration,
outcome: HandshakeOutcome,
leg: LegType,
cipher: AeadAlgorithm,
version: ProtocolVersion,
)
pub fn record_handshake( &self, duration: Duration, outcome: HandshakeOutcome, leg: LegType, cipher: AeadAlgorithm, version: ProtocolVersion, )
Record a handshake outcome and its latency with full OTel
attribution. The lock-free atomic counters and the OTel
Histogram ({ns}.handshake.duration) are updated together; the
histogram’s _count series — sliced by the outcome attribute —
is the canonical handshake count, so there is no separate counter.
Sourcepub fn record_path_validation(
&self,
duration: Duration,
path_id: u8,
outcome: PathValidationOutcome,
)
pub fn record_path_validation( &self, duration: Duration, path_id: u8, outcome: PathValidationOutcome, )
Record a PATH_VALIDATION exchange latency.