1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! # Event subscribers
//!
//! A subscriber receives best-effort runtime events for logs, metrics, alerts, or other integrations. Implement [`Subscribe`] to add one.
//!
//! ## Threading and backpressure
//!
//! ```text
//! runtime publishers
//! ▼
//! bounded shared event bus (may drop old events on lag)
//! ▼
//! internal listener
//! ├──► bounded queue A ──────► blocking pool ──► A.on_event()
//! └──► bounded queue B ──────► blocking pool ──► B.on_event()
//! ```
//!
//! Publishing never waits for subscriber code.
//! Each subscriber has its own bounded queue; one slow subscriber does not fill another subscriber's queue.
//!
//! Its events can still be dropped.
//! Callbacks run one at a time per subscriber on Tokio's blocking pool, in queue order.
//!
//! There are two places where events can be lost:
//!
//! - the shared event bus, if its listener falls behind;
//! - one subscriber queue, if that subscriber falls behind.
//!
//! Taskvisor reports drops and callback panics as diagnostic events when it can.
//! Those diagnostic events are also best-effort.
//! During shutdown, all subscriber queues share the configured drain deadline.
//!
//! See [`Event`](crate::Event) for the data model and [`Subscribe`] for the full callback contract.
pub use Subscribe;
pub use SubscriberSet;
pub use LogWriter;
pub use TracingBridge;