Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Nov 11, 2025

This PR adds scope.setAttribute, scope.setAttributes and scope.removeAttribute methods, as specified in our develop docs.

This intial PR only enables setting the attributes as well as the usual scope data operations (clone(), update(), clear(), getSpanData()). These attributes are not yet applied to any of the telemetry we eventually want them to apply to. I'll take care of this in a follow-up PR.

closes #18140

ref https://linear.app/getsentry/project/implement-global-attributes-api-javascript-02c3c74184fc/issues

Copy link
Member Author

@Lms24 Lms24 Nov 11, 2025

Choose a reason for hiding this comment

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

In contrast to logs and metrics attribute definitions and helper functions, this one already handles array attributes. My thinking is, we introduce this here then unify logs, metrics (+ spans eventually) to use the types and APIs here. While we'll have to change the used types for logs and metrics, I don't think this is breaking as theoretically logs and metrics support subsets of the attribute value types specified here.

@Lms24 Lms24 force-pushed the lms/feat-core-scope-setAttributes branch from 3209923 to c94bcd6 Compare November 11, 2025 12:32
@Lms24 Lms24 self-assigned this Nov 11, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 11, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.84 kB +0.94% +231 B 🔺
@sentry/browser - with treeshaking flags 23.32 kB +0.99% +228 B 🔺
@sentry/browser (incl. Tracing) 41.47 kB +0.51% +210 B 🔺
@sentry/browser (incl. Tracing, Profiling) 45.75 kB +0.48% +215 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.94 kB +0.28% +219 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.61 kB +0.3% +207 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 84.61 kB +0.24% +195 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 96.8 kB +0.23% +217 B 🔺
@sentry/browser (incl. Feedback) 41.51 kB +0.57% +235 B 🔺
@sentry/browser (incl. sendFeedback) 29.5 kB +0.79% +229 B 🔺
@sentry/browser (incl. FeedbackAsync) 34.43 kB +0.68% +232 B 🔺
@sentry/react 26.51 kB +0.86% +225 B 🔺
@sentry/react (incl. Tracing) 43.43 kB +0.5% +213 B 🔺
@sentry/vue 29.31 kB +0.78% +225 B 🔺
@sentry/vue (incl. Tracing) 43.24 kB +0.5% +211 B 🔺
@sentry/svelte 24.85 kB +0.94% +231 B 🔺
CDN Bundle 27.05 kB +0.57% +152 B 🔺
CDN Bundle (incl. Tracing) 42 kB +0.48% +197 B 🔺
CDN Bundle (incl. Tracing, Replay) 78.52 kB +0.25% +192 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 84 kB +0.24% +197 B 🔺
CDN Bundle - uncompressed 79.78 kB +1.2% +945 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 124.88 kB +0.72% +884 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.91 kB +0.37% +884 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 253.68 kB +0.35% +884 B 🔺
@sentry/nextjs (client) 45.57 kB +0.51% +227 B 🔺
@sentry/sveltekit (client) 41.85 kB +0.5% +207 B 🔺
@sentry/node-core 51 kB +0.37% +184 B 🔺
@sentry/node 158.08 kB +0.06% +91 B 🔺
@sentry/node - without tracing 92.87 kB +0.21% +187 B 🔺
@sentry/aws-serverless 106.64 kB +0.18% +191 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Nov 11, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,157 - 8,878 +3%
GET With Sentry 1,308 14% 1,400 -7%
GET With Sentry (error only) 6,030 66% 6,141 -2%
POST Baseline 1,165 - 1,215 -4%
POST With Sentry 492 42% 533 -8%
POST With Sentry (error only) 1,023 88% 1,069 -4%
MYSQL Baseline 3,223 - 3,315 -3%
MYSQL With Sentry 416 13% 530 -22%
MYSQL With Sentry (error only) 2,606 81% 2,718 -4%

View base workflow run

@Lms24 Lms24 changed the title feat(core): Add Scope::setAttribute(s) APIs feat(core): Add scope attribute APIs Nov 11, 2025
@Lms24 Lms24 marked this pull request as ready for review November 11, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add attribute APIs to Scope class

2 participants