UAT: MetricsEmitter does not actually emit metrics to any persistent store — metrics are lost after process exit #5839

Open
opened 2026-04-09 10:33:21 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Observability — Metrics Persistence
Milestone: v3.6.0 (M7)
Severity: Priority/Backlog — metrics are ephemeral and not queryable

What Was Tested

The MetricsEmitter and MetricEntry persistence path were inspected against the specification's metrics requirements.

Expected Behavior (from spec)

The specification states:

A dedicated metrics framework must collect performance data, including histograms, counters, and gauges for key operations.
There are 14 specific metric keys defined for tracking things like tool execution latency and plan phase duration.

Metrics should be:

  1. Collected during plan execution
  2. Persisted for later querying/analysis
  3. Exportable in Prometheus format

Actual Behavior

The MetricsEmitter.emit() method only writes metrics as structured log entries via structlog:

def emit(self, entry: MetricEntry) -> None:
    ...
    logger.info("metric.recorded", **log_data)

This means:

  1. Metrics are only written to the log file (if logging is configured)
  2. Metrics are not persisted to the database — there is no metrics table in the SQLite schema
  3. Metrics are not queryable after the fact
  4. Metrics are not aggregated — each emission is a separate log line with no rollup
  5. The TraceService.compute_metrics() creates MetricEntry objects but they are never passed to MetricsEmitter.emit()

The MetricEntry model is well-defined with all 14 metric keys, but the pipeline from metric creation → emission → persistence → query is broken at the emission step.

Code Location

  • src/cleveragents/infrastructure/observability/metrics_emitter.pyemit() only logs
  • src/cleveragents/application/services/trace_service.pycompute_metrics() creates entries but doesn't emit them
  • src/cleveragents/infrastructure/database/models.py — no metrics table exists

Impact

  • Plan execution metrics (latency, cost, token counts) are not queryable
  • Performance regression analysis is impossible without a persistent metrics store
  • The 14 defined OperationalMetricKey values are effectively unused in production
  • MetricsEmitter.emit_batch() returns a count but the data is only in logs

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area**: Observability — Metrics Persistence **Milestone**: v3.6.0 (M7) **Severity**: Priority/Backlog — metrics are ephemeral and not queryable ### What Was Tested The `MetricsEmitter` and `MetricEntry` persistence path were inspected against the specification's metrics requirements. ### Expected Behavior (from spec) The specification states: > A dedicated metrics framework must collect performance data, including histograms, counters, and gauges for key operations. > There are 14 specific metric keys defined for tracking things like tool execution latency and plan phase duration. Metrics should be: 1. Collected during plan execution 2. Persisted for later querying/analysis 3. Exportable in Prometheus format ### Actual Behavior The `MetricsEmitter.emit()` method only writes metrics as structured log entries via `structlog`: ```python def emit(self, entry: MetricEntry) -> None: ... logger.info("metric.recorded", **log_data) ``` This means: 1. Metrics are only written to the log file (if logging is configured) 2. Metrics are **not persisted to the database** — there is no `metrics` table in the SQLite schema 3. Metrics are **not queryable** after the fact 4. Metrics are **not aggregated** — each emission is a separate log line with no rollup 5. The `TraceService.compute_metrics()` creates `MetricEntry` objects but they are never passed to `MetricsEmitter.emit()` The `MetricEntry` model is well-defined with all 14 metric keys, but the pipeline from metric creation → emission → persistence → query is broken at the emission step. ### Code Location - `src/cleveragents/infrastructure/observability/metrics_emitter.py` — `emit()` only logs - `src/cleveragents/application/services/trace_service.py` — `compute_metrics()` creates entries but doesn't emit them - `src/cleveragents/infrastructure/database/models.py` — no `metrics` table exists ### Impact - Plan execution metrics (latency, cost, token counts) are not queryable - Performance regression analysis is impossible without a persistent metrics store - The 14 defined `OperationalMetricKey` values are effectively unused in production - `MetricsEmitter.emit_batch()` returns a count but the data is only in logs --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.6.0 milestone 2026-04-09 13:21:26 +00:00
Author
Owner

Milestone compliance fix applied:

  • Assigned to milestone: v3.6.0 (Advanced Concepts & Deferred Features)
  • Reason: Issue is State/Verified but had no milestone. Issue body explicitly states "Milestone: v3.6.0 (M7)" — metrics persistence belongs to v3.6.0 scope.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Milestone compliance fix applied: - Assigned to milestone: **v3.6.0** (Advanced Concepts & Deferred Features) - Reason: Issue is `State/Verified` but had no milestone. Issue body explicitly states "Milestone: v3.6.0 (M7)" — metrics persistence belongs to v3.6.0 scope. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#5839
No description provided.