Skip to content

Feat(spotlight): metrics support#1265

Open
Shubhdeep12 wants to merge 9 commits intomainfrom
feat/metrics-v0
Open

Feat(spotlight): metrics support#1265
Shubhdeep12 wants to merge 9 commits intomainfrom
feat/metrics-v0

Conversation

@Shubhdeep12
Copy link
Copy Markdown
Collaborator

@Shubhdeep12 Shubhdeep12 commented Jan 25, 2026

#1145

reference: https://develop.sentry.dev/sdk/telemetry/metrics/

  1. Metrics UI with aggregation and grouping
    • metrics list grouped by name with expandable sections
    • aggregations: sum, avg, min, max, count
    • oercentiles (P50, P90, P95, P99) for gauge and distribution types
    • detail side panel with full information
  2. Server-side metrics processing and formatting
    • parser support for Sentry metric envelopes (trace_metric items)
    • formatters for human, JSON, logfmt, and markdown
  3. MCP tool integration
    • query_metrics tool for filtering by name, type, trace ID, and time window
    • returns all metrics when called without filters
  4. E2E tests for metrics UI
  5. Fixtures for metrics and connected trace
Screen.Recording.2026-01-25.at.10.40.19.PM.mov

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 25, 2026

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

Project Deployment Actions Updated (UTC)
spotlightjs Ready Ready Preview, Comment Apr 21, 2026 10:32am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 25, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (spotlight) Metrics support by Shubhdeep12 in #1265

Internal Changes 🔧

Deps

  • Bump hono from 4.12.8 to 4.12.14 by dependabot in #1292
  • Bump astro from 5.15.9 to 5.18.1 by dependabot in #1285
  • Bump yaml from 2.8.1 to 2.8.3 by dependabot in #1283

Deps Dev

  • Bump electron from 35.7.5 to 39.8.5 by dependabot in #1289
  • Bump happy-dom from 20.8.8 to 20.8.9 by dependabot in #1287
  • Bump happy-dom from 20.0.2 to 20.8.8 by dependabot in #1286

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 25, 2026

Codecov Results 📊

❌ Patch coverage is 50.58%. Project has 1476 uncovered lines.
❌ Project coverage is 75.18%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
packages/spotlight/src/server/mcp/mcp.ts 48.39% ⚠️ 64 Missing
packages/spotlight/src/server/mcp/tools/metrics.ts 16.22% ⚠️ 62 Missing
packages/spotlight/src/server/parser/helpers.ts 71.43% ⚠️ 2 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    76.31%    75.18%    -1.13%
==========================================
  Files           47        48        +1
  Lines         5690      5946      +256
  Branches       611       611         —
==========================================
+ Hits          4342      4470      +128
- Misses        1348      1476      +128
- Partials         5         5         —

Generated by Codecov Action

@Shubhdeep12 Shubhdeep12 changed the title Feat: metrics Feat(spotlight): metrics support Jan 25, 2026
Comment thread packages/spotlight/src/ui/telemetry/components/metrics/MetricDetail.tsx Outdated
Comment thread packages/spotlight/src/ui/telemetry/utils/metrics.ts
Comment thread packages/spotlight/src/ui/telemetry/store/slices/metricsSlice.ts
Comment thread packages/spotlight/src/ui/telemetry/components/metrics/MetricsList.tsx Outdated
Comment thread packages/spotlight/src/server/mcp/tools/metrics.ts
@MathurAditya724
Copy link
Copy Markdown
Member

This looks awesome 🤩

<span className="text-primary-400">P95:</span>
<span className="text-primary-200 ml-1">{getFormattedNumber(percentiles.get(95) ?? 0)}</span>
</div>
</>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P99 percentile calculated but not displayed in UI

High Severity

The calculatePercentiles call at line 69 explicitly calculates P99 alongside P50, P90, and P95. However, the AggregateSummary component only renders P50, P90, and P95 - omitting P99 entirely. The PR description explicitly lists "percentiles (P50, P90, P95, P99)" as a feature, making this a missing functionality bug.

Additional Locations (1)

Fix in Cursor Fix in Web

for (const [key, attr] of Object.entries(metric.attributes)) {
data[`attr.${key}`] = attr.value;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent null/undefined handling across metric formatters

Low Severity

The human formatter defensively checks attr.value !== undefined && attr.value !== null before including attribute values, but the logfmt and md formatters access attr.value directly without any null/undefined guards. If an attribute has a missing or null value, logfmt will include undefined values in the output, and md will render literal "undefined" or "null" strings in the markdown table.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread packages/spotlight/src/server/formatters/human/metrics.ts

const metricsWithName = newMetricsByName.get(metric.name) || [];
metricsWithName.push(metric);
newMetricsByName.set(metric.name, metricsWithName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State mutation via shared array reference in metrics store

Medium Severity

The metricsByName Map is shallow-copied with new Map(metricsByName), but its array values maintain the same references. When newMetricsByName.get(metric.name) returns an existing array, calling push on it mutates the original array that's still referenced by the previous state. This violates immutability principles and can cause stale state issues, incorrect memoization, or React components not re-rendering when they should.

Fix in Cursor Fix in Web

@willhoney7
Copy link
Copy Markdown

this would be great! just started looking into leveraging metrics for our app but not being able to see them in spotlight atm is a bummer

@etodanik
Copy link
Copy Markdown

What's missing for this to land? Super eager to have this.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 4 total unresolved issues (including 3 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f483f7b. Configure here.

}
}
}
}, [metricId, metricGroups]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infinite render loop when viewing metric details

High Severity

When metricId is set (user clicks a metric sample), this useEffect causes an infinite render loop. allMetrics is computed directly in the render body via getMetrics() which calls Array.from(...), producing a new array reference every render. This makes the useMemo for allGroups and metricGroups recalculate every render (new references). Since metricGroups is in the effect's dependency array, the effect fires every render. It then calls setExpandedSections with new Set(...) which always creates a new reference, triggering another re-render — repeating the cycle indefinitely.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f483f7b. Configure here.

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.

4 participants