Skip to content

explore --metric uses wrong dataset for trace metrics #994

@sentry-junior

Description

@sentry-junior

sentry explore --metric <name> --dataset metrics cannot resolve SDK v10 trace metrics because the --metric auto-resolver queries dataset=metrics (the legacy DDM/release-health surface backed by OrganizationReleaseHealthDataEndpoint). SDK v10 Sentry.metrics.count() emits trace_metric envelope items stored in dataset=tracemetrics, which is the dataset the Sentry Explore Metrics UI uses (DiscoverDatasets.TRACEMETRICS).

Evidence

The Sentry MCP server emits Sentry.metrics.count("app.oauth.skill_granted", ...) via @sentry/cloudflare@10.35.0 with enableMetrics: true. The metric has 21K+ data points over 30 days, confirmed via direct API:

dataset=tracemetrics → sum(value,app.oauth.skill_granted,counter,none) = 21,341 ✅
dataset=metrics     → "could not be resolved" ❌

The CLI brute-forces MRI resolution against the events API with dataset=metrics, trying every (type, unit) combination. All return empty because the metric lives in tracemetrics.

Sentry source reference

The Explore Metrics UI uses DiscoverDatasets.TRACEMETRICS (static/app/views/explore/metrics/hooks/useMetricAggregatesTable.tsx) with field format sum(value, metricName, metricType, unit) against /organizations/{org}/events/.

Expected behavior

sentry explore --metric app.oauth.skill_granted --dataset metrics should resolve the metric from the tracemetrics dataset (or the --dataset metrics alias should route to tracemetrics).

Action taken on behalf of David Cramer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions