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
//! Task-local Spectra emit buffer.
//!
//! Batches `try_record_*` / `try_log_event` emits during a unit of work and replays
//! them through the installed [`SpectraSink`](crate::SpectraSink) off the hot path.
//! Two entry points share one task-local buffer and differ only by drain timing:
//!
//! - [`request_scope`] (web): buffer everything, hand the records back so the caller
//! drains them on a spawned task after the response is sent.
//! - [`worker_scope`] (background workers): buffer everything, then drain
//! inline (blocking post-processing) before the worker picks up the next job.
//!
//! ## Prefer `*_now` → L2 for web and scripts
//!
//! For Spectra’s primary web and Write Now story, **do not rely on** [`request_scope`].
//! Prefer `try_record_*_now` / generated helpers, which enqueue into the L2
//! async persist sink immediately. That way emits already queued survive mid-request
//! failure or panic.
//!
//! **Warning:** [`request_scope`] discards undrained buffered emits if the handler panics
//! or returns without calling [`drain`]. That is incompatible with “log failures too.”
//! Keep `request_scope` only for niche hosts that intentionally want discard-until-drain.
//!
//! ## Defaults (embedded profile)
//!
//! `SPECTRA_REQUEST_BUFFER`, `SPECTRA_JOB_BUFFER`, and `SPECTRA_COUNTER_AGGREGATE` default
//! **on** unless explicitly set to `0`/`false`/`no`.
//!
//! Each record captures its wall-clock timestamp at emit time (push); [`drain`] sets a
//! thread-local override ([`current_emit_ts`]) so downstream writers stamp the emit time
//! rather than the (later) flush time.
pub use ;
pub use ;
pub use ;
pub use BufferedEmit;
pub use ;