Skip to main content

Observability

Struct Observability 

Source
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

Source

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.

Source

pub fn config(&self) -> &ObservabilityConfig

Borrow the captured configuration.

Source

pub fn snapshot(&self) -> MetricsSnapshot

Capture a cold-path snapshot of all counters and gauges.

Source

pub fn record_send(&self, bytes: usize, leg: LegType)

Source

pub fn record_recv(&self, bytes: usize, leg: LegType)

Source

pub fn record_encrypt_ns(&self, duration_ns: u64)

Source

pub fn record_decrypt_ns(&self, duration_ns: u64)

Source

pub fn record_rtt_us(&self, rtt_us: u64, path_id: u8)

Source

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).

Source

pub fn session_closed(&self, leg: LegType)

Source

pub fn stream_opened(&self)

Source

pub fn stream_closed(&self)

Source

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.

Source

pub fn record_handshake_failure(&self)

Record a handshake failure. Cause attribution (cookie / signature / transcript / KEM) lands with the labeled API in step 7.

Source

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.

Source

pub fn record_path_validation( &self, duration: Duration, path_id: u8, outcome: PathValidationOutcome, )

Record a PATH_VALIDATION exchange latency.

Source

pub fn record_resumption(&self, mode: ResumptionMode, accepted: bool)

Source

pub fn record_replay_rejected(&self, reason: ReplayReason)

Source

pub fn record_aead_failure(&self, leg: LegType, algorithm: AeadAlgorithm)

Source

pub fn record_unencrypted_dropped(&self, leg: LegType)

Source

pub fn record_path_migration(&self, from: u8, to: u8)

Source

pub fn record_pow(&self, outcome: PowOutcome, difficulty: u8)

Source

pub fn record_early_data(&self, outcome: EarlyDataOutcome)

Source

pub fn record_rekey(&self, direction: Direction)

Source

pub fn record_fallback( &self, from_leg: LegType, to_leg: LegType, reason: FallbackReason, )

Trait Implementations§

Source§

impl Debug for Observability

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more