Skip to main content

TransportObserver

Trait TransportObserver 

Source
pub trait TransportObserver: Send + Sync {
    // Required method
    fn on_event(&self, key: &str, event: TransportEvent);
}

Required Methods§

Source

fn on_event(&self, key: &str, event: TransportEvent)

Called synchronously on the request path, from the task that owns the call, and — for Started — while that attempt’s semaphore permit is held. The contract:

  • Do not block, await or sleep. Copy what you need into your own state and return. Time spent in Started is time the client’s parallelism budget is not doing work; time spent in any other event delays the call that reported it.
  • Do not call back into the client (execute, execute_with, breaker_state). The call path is holding client state.
  • Started pairs with exactly one terminal event — Succeeded, Failed or Cancelled — per attempt, including for a fail-fast rejection, which emits a synthetic Started followed by Failed { ms: 0 } whose error has kind_name() == "breaker_open". Those two never touched the network; filter them out of request-rate figures.
  • BreakerOpened repeats on every failed probe, with a longer cooldown each time and no intervening BreakerClosed. Treat it as “open until now + cooldown” — set the deadline, do not count the events.
  • ms covers building, sending and reading the response head. It excludes waiting for a breaker cooldown, a rate-limit token, a semaphore permit, a retry back-off, and the auth round trip.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§