Skip to content

feat(samples): [Global Attributes 6] Showcase scope attributes in all sample modules#5149

Open
adinauer wants to merge 18 commits intomainfrom
feat/samples-scope-attributes
Open

feat(samples): [Global Attributes 6] Showcase scope attributes in all sample modules#5149
adinauer wants to merge 18 commits intomainfrom
feat/samples-scope-attributes

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 3, 2026

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 (added in #5121) to all 19 remaining sample modules with system tests.

Source files — added setAttribute calls for user.type (string), feature.version (int), and debug.enabled (boolean) before the first logger or metrics call in each sample's controller/main method.

Test files — added doesLogWithBodyHaveAttribute and doesMetricHaveAttribute assertions 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

adinauer and others added 16 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>
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>
@adinauer adinauer changed the title feat(samples): Showcase scope attributes in all sample modules feat(samples): [Global Attributes 6] Showcase scope attributes in all sample modules Mar 3, 2026
@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).


This PR will not appear in the changelog.


🤖 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 afd3c6a

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 324.20 ms 365.00 ms 40.80 ms
Size 1.58 MiB 2.29 MiB 722.91 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/samples-scope-attributes

Startup times

Revision Plain With Sentry Diff
bedf4d5 322.10 ms 354.88 ms 32.78 ms

App size

Revision Plain With Sentry Diff
bedf4d5 1.58 MiB 2.29 MiB 719.90 KiB

Base automatically changed from feat/log-attribute-array-support to feat/global-attributes-api March 3, 2026 16:57
@adinauer adinauer marked this pull request as ready for review March 4, 2026 05:19
Base automatically changed from feat/global-attributes-api to main 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.

3 participants