Skip to main content

Module metrics

Module metrics 

Source
Expand description

Metrics collection and daily-rotating JSONL emission.

Provides a channel-based pipeline: callers emit MetricEvent values via MetricsSender, and MetricsWriter drains the channel and appends events to a daily-rotated JSONL file under the XDG data directory (~/.local/share/code-analyze-mcp/metrics-YYYY-MM-DD.jsonl). Files older than 30 days are deleted on startup.

Structs§

MetricEvent
A single metric event emitted by a tool invocation.
MetricsSender
Sender half of the metrics channel; cloned and passed to tools for event emission.
MetricsWriter
Receiver half of the metrics channel; drains events and writes them to daily-rotated JSONL files.

Functions§

current_date_str
Returns the current UTC date as a string in YYYY-MM-DD format.
error_code_to_type
Maps an MCP error code to a short string representation for metrics.
path_component_count
Counts the number of path segments in a file path.
unix_ms
Returns the current UNIX timestamp in milliseconds.