pub struct Report {
pub total: u64,
pub unparseable: u64,
pub count_by_level: BTreeMap<String, u64>,
pub count_by_component: BTreeMap<String, u64>,
pub top_descriptions: Vec<(String, u64)>,
pub latency: Option<LatencyStats>,
}Expand description
Aggregated digest of a log stream.
Fields§
§total: u64Total parseable records seen.
unparseable: u64Records that failed to parse as canonical JSON Log.
count_by_level: BTreeMap<String, u64>Count of records grouped by level (string keys: INFO, ERROR, …).
count_by_component: BTreeMap<String, u64>Count grouped by component.
top_descriptions: Vec<(String, u64)>Top descriptions by frequency, descending. Top 10 by default.
latency: Option<LatencyStats>Latency stats (ms) extracted from the latency_ms /
http.latency_ms attribute when present. None when no
records carried such an attribute.
Implementations§
Source§impl Report
impl Report
Sourcepub fn from_lines<'a, I>(lines: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
pub fn from_lines<'a, I>(lines: I) -> Selfwhere
I: IntoIterator<Item = &'a str>,
Aggregate a stream of JSON-shaped record lines into a Report.
Lines that don’t parse as canonical JSON Log are counted as
unparseable and otherwise ignored.
Sourcepub fn from_lines_with_top<'a, I>(lines: I, top_n: usize) -> Selfwhere
I: IntoIterator<Item = &'a str>,
pub fn from_lines_with_top<'a, I>(lines: I, top_n: usize) -> Selfwhere
I: IntoIterator<Item = &'a str>,
Same as Self::from_lines but lets the caller pick how many
top descriptions to keep.
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Render the report as JSON.
§Errors
Returns serde_json::Error only if the serialiser fails,
which cannot happen for the report’s fixed shape.
Sourcepub fn error_count(&self) -> u64
pub fn error_count(&self) -> u64
Count of records at level ERROR-and-above.