Skip to content

feat(core): Global Attributes API#5148

Merged
adinauer merged 29 commits intomainfrom
feat/global-attributes-api
Mar 4, 2026
Merged

feat(core): Global Attributes API#5148
adinauer merged 29 commits intomainfrom
feat/global-attributes-api

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 3, 2026

📜 Description

Collection branch for individual PRs to implement Global Attributes API, i.e. adding attributes to Scope which are then auto applied to logs and metrics (more in the future).

PR Stack (Global Attributes):

  1. #5118 — Add scope-level attributes API
  2. #5120 — Wire scope attributes into LoggerApi and MetricsApi
  3. #5121 — Showcase scope attributes in Spring Boot 4 samples
  4. #5122 — Detect integer attribute type correctly for all integer Number subtypes
  5. #5124 — Support collections and arrays in log attribute type inference

💡 Motivation and Context

Closes #5084

💚 How did you test it?

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

adinauer and others added 20 commits February 26, 2026 10:49
Add setAttribute, setAttributes, removeAttribute, and getAttributes
to IScope/IScopes/Sentry so users can set attributes on the scope
that are automatically included in logs and metrics events.

Also refactor type inference logic into SentryAttributeType.inferFrom
and add SentryLogEventAttributeValue.fromAttribute factory method,
removing duplicate getType helpers from LoggerApi and MetricsApi.

Co-Authored-By: Claude <noreply@anthropic.com>
Move factory method extractions (SentryAttributeType.inferFrom,
SentryLogEventAttributeValue.fromAttribute) and LoggerApi/MetricsApi
scope attribute integration to a separate stacked PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract factory methods SentryAttributeType.inferFrom and
SentryLogEventAttributeValue.fromAttribute to reduce duplication.
Apply scope attributes to log and metric events automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Sentry.setAttribute() calls to PersonController and
MetricController across all Spring Boot 4 sample variants to
demonstrate scope attributes being auto-attached to logs and metrics.

Add e2e test assertions and TestHelper methods to verify scope
attributes appear on captured log and metric events.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 7189bdc.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ubtypes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add arrayAttribute and named array attribute usage to the four
attribute tests in ScopesTest (log, count metric, distribution metric,
gauge metric) to verify the factory method works end-to-end.

Co-Authored-By: Claude <noreply@anthropic.com>
feat(core): [Global Attributes 1] Add scope-level attributes API
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 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 ✨

  • (core) Global Attributes API by adinauer in #5148
  • (options) Add support for SENTRY_SAMPLE_RATE environment variable / sample-rate property by adinauer in #5112
  • (otel) Create sentry-opentelemetry-otlp module for combining OpenTelemetry SDK OTLP export with Sentry SDK by adinauer in #5100
  • (screenshot) Add screenshot masking using view hierarchy by romtsn in #5077
  • Made ManifestMetaDataReader read the DIST by bitsandfoxes in #5107

Bug Fixes 🐛

  • (android) Remove AndroidRuntimeManager to prevent ANRs during SDK init by romtsn in #5127
  • (gestures) Use peekDecorView to not force view hierarchy construction by romtsn in #5134
  • (init) Reduce allocations and bytecode instructions during Sentry.init by romtsn in #5135
  • (transport) Handle HTTP 413 with actionable log and use send_error for HTTP errors by adinauer in #5115
  • Trim DSN string before URI parsing by adinauer in #5113
  • Safe unregister SystemEventsBroadcastReceiver by kollesnica1337 in #5106

Internal Changes 🔧

Deps

  • Bump getsentry/craft from 2.21.7 to 2.23.1 by dependabot in #5129
  • Update Native SDK to v0.13.1 by github-actions in #5104
  • Bump actions/upload-artifact from 6 to 7 by dependabot in #5130
  • Bump actions/download-artifact from 7 to 8 by dependabot in #5132
  • Bump gradle/actions from 5.0.1 to 5.0.2 by dependabot in #5131
  • Bump github/codeql-action from 4.32.2 to 4.32.4 by dependabot in #5109
  • Bump getsentry/craft from 2.21.2 to 2.21.7 by dependabot in #5110

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b5de18d

adinauer added 3 commits March 3, 2026 15:40
…metrics

feat(core): [Global Attributes 2]Wire scope attributes into LoggerApi and MetricsApi
feat(samples): [Global Attributes 3] Showcase scope attributes in Spring Boot 4 sample
…tection

feat(core): [Global Attributes 4] Detect integer attribute type correctly for all integer Number subtypes
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 326.36 ms 363.21 ms 36.85 ms
Size 1.58 MiB 2.29 MiB 722.92 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
91bb874 314.47 ms 440.00 ms 125.53 ms
dba088c 333.98 ms 381.16 ms 47.18 ms
d15471f 310.66 ms 368.19 ms 57.53 ms
bbc35bb 298.53 ms 372.17 ms 73.64 ms
d15471f 307.28 ms 381.85 ms 74.57 ms
ad8da22 362.98 ms 453.94 ms 90.96 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
96449e8 361.30 ms 423.39 ms 62.09 ms
27d7cf8 309.43 ms 364.27 ms 54.85 ms
91bb874 311.00 ms 363.47 ms 52.47 ms

App size

Revision Plain With Sentry Diff
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
ad8da22 1.58 MiB 2.29 MiB 719.83 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
96449e8 1.58 MiB 2.11 MiB 539.35 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB

Previous results on branch: feat/global-attributes-api

Startup times

Revision Plain With Sentry Diff
10972bd 311.40 ms 357.10 ms 45.71 ms

App size

Revision Plain With Sentry Diff
10972bd 1.58 MiB 2.29 MiB 722.92 KiB

adinauer and others added 3 commits March 3, 2026 17:57
feat(core): [Global Attributes 5] Support collections and arrays in log attributes
The arrayAttribute() factory only accepted Collection<?>, but
inferFrom() also handles native Java arrays. Add an Object[] overload
so users can pass object arrays like String[] directly without
falling back to the untyped named() method.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer adinauer enabled auto-merge (squash) March 4, 2026 08:22
Copy link

@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.

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

@adinauer adinauer merged commit 4b1510b into main Mar 4, 2026
64 of 65 checks passed
@adinauer adinauer deleted the feat/global-attributes-api branch March 4, 2026 08:56
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.

Global Attributes API

2 participants