feat(samples): [Global Attributes 6] Showcase scope attributes in all sample modules#5149
Open
feat(samples): [Global Attributes 6] Showcase scope attributes in all sample modules#5149
Conversation
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>
Add Sentry.setAttribute() calls to all sample source files and corresponding attribute assertions to all system tests. This extends the scope attributes showcase from sentry-samples-spring-boot-4 to all 19 remaining sample modules with system tests. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Contributor
|
Contributor
Performance metrics 🚀
|
| 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 |
Base automatically changed from
feat/log-attribute-array-support
to
feat/global-attributes-api
March 3, 2026 16:57
alexander-alderman-webb
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
Sentry.setAttribute()calls to all sample source files and corresponding attribute assertions to all system tests. This extends the scope attributes showcase fromsentry-samples-spring-boot-4(added in #5121) to all 19 remaining sample modules with system tests.Source files — added
setAttributecalls foruser.type(string),feature.version(int), anddebug.enabled(boolean) before the first logger or metrics call in each sample's controller/main method.Test files — added
doesLogWithBodyHaveAttributeanddoesMetricHaveAttributeassertions to verify the attributes are present on logs and metrics received by the mock Sentry server.66 files changed across 19 modules (14 Spring, 2 console, 3 logger).
#skip-changelog