Skip to content

Sentry - store trace metrics instead of showing them as an empty event - #355

Open
temp wants to merge 1 commit into
buggregator:masterfrom
temp:feature/sentry-trace-metrics
Open

temp wants to merge 1 commit into
buggregator:masterfrom
temp:feature/sentry-trace-metrics

Conversation

@temp

@temp temp commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

Sentry trace metrics (\Sentry\traceMetrics() in the PHP SDK 4.x, Sentry.metrics in the JavaScript SDK) arrive as envelope items of type trace_metric. Buggregator didn't know the type, so the fallback turned the item into a feed card — the empty "Something went wrong" event from #347.

This is a minimal implementation that stores them and lists them:

  • trace_metric items are stored in a new sentry_metrics table (name, type, value, unit, attributes, timestamp, trace/span id), migration 2024_01_01_000027
  • like logs, transactions and spans they stay out of the event feed
  • GET /api/sentry/metrics lists them newest first, filterable by name, type (counter, gauge, distribution) and trace_id, paginated like /api/sentry/logs
  • /api/sentry/counts reports metrics, DELETE /api/sentry/all clears the table

No aggregation (sums, percentiles, charts) yet — a list was enough to make them visible.

The UI for it is buggregator/frontend#293: a Metrics tab next to Logs.

Checklist

  • Closes Ignore / implement sentry metrics #347
  • Tested
    • Unit tests added (storage, envelope handling with and without a database, list, filters, counts)
    • Tested manually: a local build with the frontend embedded, fed with gauges, a counter and a distribution from the Sentry PHP SDK 4.31.0 — all stored, listed by the API, no feed event

🤖 Generated with Claude Code

Envelope items of type trace_metric (Sentry PHP SDK 4.x traceMetrics(),
JavaScript SDK metrics) fell through to the fallback that turns the first
valid JSON item into a feed card, which showed up as an empty
"Something went wrong" event.

They are now stored in sentry_metrics, kept out of the event feed like logs,
transactions and spans, listed under GET /api/sentry/metrics (filters: name,
type, trace_id), counted in /api/sentry/counts and cleared with the other
Sentry tables.

Closes buggregator#347

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore / implement sentry metrics

1 participant