Skip to content

fix(perf): correct metrics_recorded count and close SQLite handle on error in _store_metric - #1360

Merged
groupthinking merged 3 commits into
mainfrom
perf-metrics_recorded-overcounts-non-numeric-samples-grv-308-efbc
Aug 29, 2026
Merged

fix(perf): correct metrics_recorded count and close SQLite handle on error in _store_metric#1360
groupthinking merged 3 commits into
mainfrom
perf-metrics_recorded-overcounts-non-numeric-samples-grv-308-efbc

Conversation

@groupthinking

Copy link
Copy Markdown
Owner

Canonical issue

Closes #1352

Outcome

POST /api/v1/performance/report now returns the number of samples actually persisted (len(samples)) instead of the number of metric keys submitted, so reports mixing numeric and non-numeric values no longer overcount. The legacy _store_metric now delegates to the batched _store_metrics with a one-element list, inheriting its try/finally so an exception mid-write no longer leaks the SQLite connection.

Scope

Risk

  • Risk level: low
  • Failure mode: clients relying on the old (incorrect) submitted-key count would see a lower metrics_recorded value for mixed reports.
  • Rollback: revert the single commit.

Verification

At head cbb020f1ef3555a8e842d572651b4c00e347ee68:

  • Focused tests — pytest tests/unit/test_v1_router_extended.py -k performance: 7 passed, including the new test_performance_report_counts_only_persisted_samples.
  • Smoke test — _store_metric exercised against a temp SQLite DB; the row is written through the batched path.
  • Required CI
  • Review threads resolved

Production evidence

Not applicable — backend-only bug fix, covered by unit tests.

Agent handoff

  • One canonical issue is linked
  • No competing PR implements the same issue
  • Acceptance criteria are satisfied
  • Required checks pass on the current head
  • Human decision is requested only for product, security, irreversible infrastructure, or production approval

Agent provenance

…rror

metrics_recorded in the performance-report ingest now returns len(samples)
(rows actually written) instead of len(metrics) (keys submitted), so reports
mixing numeric and non-numeric values no longer overcount.

The legacy _store_metric now delegates to the batched _store_metrics with a
one-element list, gaining its try/finally so an exception between connect
and close no longer leaks the SQLite handle.

Generated with [Linear](https://linear.app/myxstack/issue/GRV-308/perf-metrics-recorded-overcounts-non-numeric-samples-legacy-store#agent-session-6d3cc388)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@linear-code

linear-code Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

GRV-308

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Ready Ready Preview, v0 Aug 29, 2026 7:54am

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 782507e9-8f44-45dc-955d-b4de88649a98


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA dda8fd5.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions github-actions Bot added the python label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Agent Completion Truth Gate: BLOCKED

Reasons: invalid_payload

Machine-readable verdict
{
  "details": {
    "collection_errors": [
      "linked_issue_not_agent_task",
      "missing_intent_snapshot",
      "missing_agent_run_id",
      "missing_agent_login"
    ],
    "invalid_fields": [
      "policy.agent_login",
      "policy.run_id"
    ]
  },
  "reasons": [
    "invalid_payload"
  ],
  "verdict": "blocked"
}

Workflow evidence

@groupthinking
groupthinking merged commit 3432e2f into main Aug 29, 2026
16 of 24 checks passed
@groupthinking
groupthinking deleted the perf-metrics_recorded-overcounts-non-numeric-samples-grv-308-efbc branch August 29, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: metrics_recorded overcounts non-numeric samples; legacy _store_metric lacks try/finally

1 participant