Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Structured logging façade over tracing + tracing-subscriber.

Entry point for the red binary and any embedder that wants RedDB to manage logging on its behalf. Sets up two layers:

  • stderr — pretty (TTY) or JSON (piped/CI) formatted logs
  • file — optional daily-rotating file in log_dir, non-blocking writer backed by tracing-appender

A background janitor purges rotated files older than rotation_keep_days every hour.

The returned Option<TelemetryGuard> must live for the process lifetime — dropping it flushes the non-blocking buffer so no log lines are lost on graceful shutdown.

Modules§

admin_intent_log
Intent log for long-running admin operations.
janitor
Log-file retention janitor.
operator_event
Operator-grade event bus for high-severity system conditions.
operator_event_router
Config-driven per-variant routing for OperatorEvent.
slow_query_logger
Dedicated slow-query sink — writes structured JSON lines to red-slow.log.
span
Span helpers that pull connection / transaction / tenant / auth context out of the runtime thread-locals and attach them to a tracing::Span. Any log emitted while the span is entered picks up these fields automatically — the caller never has to pass conn_id / xid / tenant as parameters down through the call graph.

Structs§

TelemetryConfig
TelemetryGuard
Opaque handle that keeps the non-blocking log writers alive. Drop at process exit to flush the buffered records for stderr AND the rotating file sink. Both writers run on their own dedicated background threads — the hot path only pushes onto an MPSC channel, never touches stdio syscalls directly.

Enums§

LogFormat
Stdio / file output format. Pretty renders human-readable coloured lines; Json emits NDJSON suitable for Loki / ELK / Datadog.

Functions§

init
Install the global tracing subscriber. Idempotent: if another subscriber is already registered (e.g. an embedder set up its own), we silently return None and let the caller proceed.