Skip to main content

Crate rlg_report

Crate rlg_report 

Source
Expand description

Aggregation helpers for rlg log streams.

The companion rlg-report binary wires these helpers to a CLI. The library surface is exposed so dashboards / web UIs / tests can build their own front-ends on top.

use rlg_report::Report;

let lines = [
    r#"{"session_id":1,"time":"t","level":"INFO","component":"svc","description":"hi","format":"JSON","attributes":{}}"#,
    r#"{"session_id":2,"time":"t","level":"ERROR","component":"db","description":"boom","format":"JSON","attributes":{"latency_ms":120}}"#,
    r#"{"session_id":3,"time":"t","level":"ERROR","component":"db","description":"boom","format":"JSON","attributes":{"latency_ms":80}}"#,
];
let report = Report::from_lines(lines.iter().copied());
assert_eq!(report.total, 3);
assert_eq!(report.count_by_level.get("ERROR").copied(), Some(2));
assert_eq!(report.count_by_component.get("db").copied(), Some(2));
assert_eq!(report.top_descriptions[0].0, "boom");

Structsยง

LatencyStats
p50 / p95 / p99 / max latency percentiles, all in milliseconds.
Report
Aggregated digest of a log stream.