Skip to main content

ff_observability/
lib.rs

1//! FlowFabric observability — OTEL metrics registry + typed handles.
2//!
3//! This crate is the single place that touches OpenTelemetry / Prometheus.
4//! Consumers (`ff-server`, `ff-engine`, `ff-scheduler`) take an optional dep
5//! on `ff-observability` behind their own `observability` feature; enabling
6//! the consumer-feature transitively enables `ff-observability/enabled`.
7//!
8//! ## Feature model
9//!
10//! * `enabled` **off** (default) — all types compile to zero-cost no-op
11//!   shims. No OTEL / Prometheus crates in the dep tree. Call sites use
12//!   the same `Metrics::new()` entry point as the real backend; every
13//!   instrument method is a no-op.
14//! * `enabled` **on** — real OTEL `MeterProvider` + Prometheus exporter.
15//!   `Metrics::new()` registers all instruments; [`Metrics::render`]
16//!   returns the text-exposition body for `/metrics`.
17//!
18//! Call sites under both features use **identical call shape** — that's
19//! the whole point of the indirection. If the shim ever grew a feature
20//! skew we'd lose the "same source compiles both ways" guarantee.
21
22#![forbid(unsafe_code)]
23
24#[cfg(feature = "enabled")]
25mod real;
26#[cfg(not(feature = "enabled"))]
27mod shim;
28
29#[cfg(feature = "enabled")]
30pub use real::Metrics;
31#[cfg(not(feature = "enabled"))]
32pub use shim::Metrics;