1mod console;
14mod global;
15mod noop;
16
17#[cfg(feature = "recording")]
18mod recording;
19
20pub use console::ConsoleOpsLog;
21pub use global::{install_ops_log, ops_log, ops_log_from_env};
22pub use noop::NoOpsLog;
23
24#[cfg(feature = "recording")]
25pub use recording::{RecordedCounter, RecordedEvent, RecordedGauge, RecordingOpsLog};
26
27pub trait OpsLog: Send + Sync {
29 fn record_counter(&self, name: &str, labels: &[(&str, &str)], value: f64);
31
32 fn record_gauge(&self, name: &str, labels: &[(&str, &str)], value: f64);
34
35 fn log_event(&self, name: &str, payload: &serde_json::Value);
37}
38
39#[cfg(test)]
40mod tests {
41 use super::{ConsoleOpsLog, NoOpsLog, OpsLog};
42
43 #[test]
44 fn noop_ops_log_is_silent() {
45 let log = NoOpsLog;
46 log.record_counter("c", &[], 1.0);
47 log.record_gauge("g", &[], 2.0);
48 log.log_event("e", &serde_json::json!({}));
49 }
50
51 #[test]
52 fn console_ops_log_does_not_panic() {
53 let log = ConsoleOpsLog;
54 log.record_counter("photon_publishes", &[("topic", "t")], 1.0);
55 }
56}