Skip to main content

HookObserver

Trait HookObserver 

Source
pub trait HookObserver<K: Kind>:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn event_dropped(
        &self,
        _hook: &str,
        _event: &str,
        _kind: K,
        _loss: Loss,
        _detail: &str,
    ) { ... }
    fn events_abandoned(&self, _hook: &str, _dropped: usize) { ... }
    fn delivery_outcomes_unknown(&self, _hook: &str, _count: usize) { ... }
    fn event_unrenderable(&self, _reason: &str) { ... }
}
Expand description

Where this crate reports its own failures.

A trait rather than a concrete sink because two applications count and log differently, and neither should have to adopt the other’s observability model to reuse the delivery machinery. Every method has a default, so an application that wants none of it implements nothing.

Implementations are called from the dispatcher task and must not block.

Nothing reported here may be fed back into Hooks::deliver: a dead endpoint would then generate failure events addressed to the dead endpoint.

Generic over the application’s Kind rather than taking a rendered string, so an application that already has a typed event vocabulary keeps it when reporting a failure against one.

Provided Methods§

Source

fn event_dropped( &self, _hook: &str, _event: &str, _kind: K, _loss: Loss, _detail: &str, )

An event will not be attempted again. detail is an HTTP status or a transport error, and event is the CloudEvents id a consumer would quote.

Source

fn events_abandoned(&self, _hook: &str, _dropped: usize)

Queued events were abandoned at the shutdown drain deadline.

Source

fn delivery_outcomes_unknown(&self, _hook: &str, _count: usize)

Deliveries were in flight when the drain deadline passed, so they may have reached the endpoint before being cancelled. Unknown rather than dropped.

Source

fn event_unrenderable(&self, _reason: &str)

An event could not be turned into bytes at all.

A fault in this process rather than in delivery, so it names no hook: nothing was addressed yet when it failed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§