Skip to content

ref(core): Type metric units with MetricUnit - #23304

Draft
logaretm wants to merge 1 commit into
developfrom
awad/type-metric-units
Draft

ref(core): Type metric units with MetricUnit#23304
logaretm wants to merge 1 commit into
developfrom
awad/type-metric-units

Conversation

@logaretm

@logaretm logaretm commented Aug 11, 2026

Copy link
Copy Markdown
Member

Types the unit field on the experimental metrics API (MetricOptions, Metric, SerializedMetric) instead of leaving it as a bare string.

Adds a MetricUnit type that matches the metric unit vocabulary from the develop docs. It reuses the existing LiteralUnion helper so the canonical units get autocomplete while arbitrary strings still pass through, which the spec requires ("SDKs MUST NOT restrict unit values").

I deliberately did not reuse MeasurementUnit here: it carries a NoneUnit ('' | 'none') that is a leftover from the old transaction-measurement system and is not a valid metric unit. A unitless metric omits the field rather than sending 'none', so MetricUnit drops that category and otherwise mirrors the attribute unit set.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.29 kB +1.54% +457 B 🔺
@sentry/browser - with treeshaking flags 28.47 kB +1.57% +439 B 🔺
@sentry/browser (incl. Tracing) 48.54 kB +2.74% +1.29 kB 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.56 kB +2.73% +1.29 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 51.44 kB -1.09% -562 B 🔽
@sentry/browser (incl. Tracing, Replay) 87.95 kB +1.57% +1.36 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB +1.78% +1.35 kB 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.66 kB +1.51% +1.38 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.36 kB +1.36% +1.41 kB 🔺
@sentry/browser (incl. Feedback) 47.61 kB +1.02% +480 B 🔺
@sentry/browser (incl. sendFeedback) 35.11 kB +1.29% +446 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.26 kB +1.23% +486 B 🔺
@sentry/browser (incl. Metrics) 31.28 kB +1.21% +371 B 🔺
@sentry/browser (incl. Logs) 31.53 kB +1.25% +389 B 🔺
@sentry/browser (incl. Metrics & Logs) 32.2 kB +1.23% +390 B 🔺
@sentry/react 32.09 kB +1.46% +461 B 🔺
@sentry/react (incl. Tracing) 50.73 kB +2.48% +1.23 kB 🔺
@sentry/vue 35.34 kB +1.21% +420 B 🔺
@sentry/vue (incl. Tracing) 50.5 kB +2.57% +1.26 kB 🔺
@sentry/svelte 30.31 kB +1.52% +451 B 🔺
CDN Bundle 31.59 kB -0.89% -282 B 🔽
CDN Bundle (incl. Tracing) 48.87 kB +2.81% +1.33 kB 🔺
CDN Bundle (incl. Logs, Metrics) 33.8 kB +1.19% +395 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 50.83 kB +3.85% +1.88 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.34 kB +2.19% +1.59 kB 🔺
CDN Bundle (incl. Tracing, Replay) 86.46 kB +1.5% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.33 kB +2.12% +1.83 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.17 kB +1.28% +1.16 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.14 kB +1.99% +1.83 kB 🔺
CDN Bundle - uncompressed 93.77 kB -0.9% -844 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 146.66 kB +3.2% +4.55 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.17 kB +0.95% +935 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.46 kB +4.36% +6.36 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.1 kB +2.31% +5.16 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.92 kB +1.74% +4.54 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.7 kB +2.4% +6.36 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.61 kB +1.65% +4.53 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.38 kB +2.28% +6.35 kB 🔺
@sentry/nextjs (client) 53.29 kB +2.33% +1.21 kB 🔺
@sentry/sveltekit (client) 48.96 kB +2.62% +1.25 kB 🔺
@sentry/core/server 65.44 kB -0.14% -88 B 🔽
@sentry/core/browser 51.8 kB -0.17% -86 B 🔽
@sentry/node 117.98 kB -1.88% -2.25 kB 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.09 kB -1.91% -1.6 kB 🔽
@sentry/aws-serverless 91.5 kB -0.93% -858 B 🔽
@sentry/cloudflare (withSentry) - minified 214.1 kB -2.09% -4.55 kB 🔽
@sentry/cloudflare (withSentry) 528.64 kB -1.9% -10.21 kB 🔽
@sentry/browser - with treeshaking flags tracing without tracing 26.8 kB added added

View base workflow run

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.

1 participant