Skip to content

feat(browser): Track measure detail as span attributes #16240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

AbhiPrasad
Copy link
Member

resolves #16237

The SDK automatically instruments the performance.measure API, but doesn't support detail, which is the way you can attach arbitrary data to performance.measure. Given you can see details in browser dev-tools, we should probably support it in the same way in Sentry.

https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure

detail docs: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure/detail

Detail is completely arbitrary, so we have to take care before parsing it. I have added tests accordingly.

@AbhiPrasad AbhiPrasad requested a review from a team May 8, 2025 23:56
@AbhiPrasad AbhiPrasad self-assigned this May 8, 2025
@AbhiPrasad AbhiPrasad requested review from mydea and andreiborza and removed request for a team May 8, 2025 23:56
Copy link

codecov bot commented May 9, 2025

❌ We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.

Copy link
Contributor

github-actions bot commented May 9, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.35 KB - -
@sentry/browser - with treeshaking flags 23.19 KB - -
@sentry/browser (incl. Tracing) 37.34 KB +0.26% +96 B 🔺
@sentry/browser (incl. Tracing, Replay) 74.56 KB +0.12% +90 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.43 KB +0.13% +87 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 79.21 KB +0.12% +91 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 91.03 KB +0.11% +100 B 🔺
@sentry/browser (incl. Feedback) 39.75 KB - -
@sentry/browser (incl. sendFeedback) 27.98 KB - -
@sentry/browser (incl. FeedbackAsync) 32.74 KB - -
@sentry/react 25.16 KB - -
@sentry/react (incl. Tracing) 39.33 KB +0.23% +92 B 🔺
@sentry/vue 27.63 KB - -
@sentry/vue (incl. Tracing) 39.09 KB +0.23% +88 B 🔺
@sentry/svelte 23.38 KB - -
CDN Bundle 24.55 KB - -
CDN Bundle (incl. Tracing) 37.46 KB +0.47% +176 B 🔺
CDN Bundle (incl. Tracing, Replay) 72.41 KB +0.11% +77 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 77.74 KB +0.14% +106 B 🔺
CDN Bundle - uncompressed 71.62 KB - -
CDN Bundle (incl. Tracing) - uncompressed 110.7 KB +0.33% +367 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 221.99 KB +0.17% +367 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 234.51 KB +0.16% +367 B 🔺
@sentry/nextjs (client) 40.94 KB +0.24% +98 B 🔺
@sentry/sveltekit (client) 37.83 KB +0.26% +97 B 🔺
@sentry/node 151.37 KB - -
@sentry/node - without tracing 95.77 KB +0.01% +1 B 🔺
@sentry/aws-serverless 120.16 KB - -

View base workflow run

attributes[`sentry.browser.measure.detail.${key}`] = value as SpanAttributeValue;
} else {
try {
// This is user defined so we can't guarantee it's serializable
Copy link
Member

Choose a reason for hiding this comment

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

l: Can we instead just wrap the whole block inside of if (entry.detail) in a try-catch, maybe slightly less redundant?

// https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#detail
if (entry.detail) {
// Handle detail as an object
if (typeof entry.detail === 'object') {
Copy link

Choose a reason for hiding this comment

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

I would also ask to support arrays of primitives, here and as object props 🙏

Listing some things in spans is very useful, and SpanAttributeValue supports this.

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.

Enrich attributes of Spans created from PerformanceMeasure events
3 participants