Skip to main content

machi_obs/
lib.rs

1//! Observability spine for the Machi kernel.
2//!
3//! - Stable **metric series** names and record helpers ([`metrics`])
4//! - Re-export of **span / field** catalogue from [`machi_protocol`]
5//! - **Redaction** helpers so hosts never log secrets by accident
6//!
7//! Production hosts inject a real [`MetricsSink`] (Prometheus / OTEL adapters
8//! live behind optional features in later phases). The kernel only depends on
9//! the trait surface.
10
11#![forbid(unsafe_code)]
12
13pub mod metrics;
14pub mod prometheus;
15pub mod recording;
16pub mod redact;
17
18// Span contract lives in protocol so pure crates can name spans without pulling
19// metrics. Re-export for a single import path in hosts.
20pub use machi_protocol::observability::{
21    SPAN_COMPACT, SPAN_SAMPLE, SPAN_SESSION, SPAN_SPAWN, SPAN_TOOL, SPAN_TOOL_BATCH, SPAN_TURN,
22    SPAN_WORKFLOW, SPAN_WORKFLOW_HOST, field, required_span_names, span_catalogue_snapshot,
23};
24pub use metrics::{
25    METRIC_COMPACTIONS_TOTAL, METRIC_SAMPLE_DURATION_MS, METRIC_SPAWNS_TOTAL, METRIC_TOKENS_TOTAL,
26    METRIC_TOOL_CALLS_TOTAL, METRIC_TOOL_DURATION_MS, METRIC_TURN_DURATION_MS, METRIC_TURN_STEPS,
27    METRIC_TURNS_TOTAL, METRIC_WORKFLOW_AGENTS_TOTAL, METRIC_WORKFLOW_RUNS_TOTAL, MetricsSink,
28    NoopMetrics, SharedMetrics, emit_catalogue_smoke, metric_catalogue_snapshot, record_compaction,
29    record_sample, record_spawn, record_tool_call, record_turn, record_workflow_agents,
30    record_workflow_run, required_metric_names,
31};
32pub use prometheus::PrometheusRecorder;
33pub use recording::{CounterEvent, GaugeEvent, HistogramEvent, RecordingMetrics};
34pub use redact::{REDACTED, looks_like_secret_key, redact_key_value, redact_map};