Commit 4b1510b
feat(core): Global Attributes API (#5148)
* feat(core): Add scope-level attributes API
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 <[email protected]>
* changelog
* ref: Split out LoggerApi/MetricsApi changes for stacked PR
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 <[email protected]>
* feat(core): Wire scope attributes into LoggerApi and MetricsApi
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 <[email protected]>
* changelog
* feat(samples): Showcase scope attributes in Spring Boot 4 samples
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 <[email protected]>
* changelog
* Revert "changelog"
This reverts commit 7189bdc.
* ref: Remove redundant comments from variant controllers
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* ref: Limit scope attributes sample to base Spring Boot 4 variant
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* fix: Detect integer attribute type correctly for all integer Number subtypes
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* changelog
* feat: Support collections and arrays in log attribute type inference
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* changelog
* use ConcurrentHashMap instead of HashMap when merging attributes
* add enabled check similar to tags
* make setAttribute and setAttributes params nullable
* test: Add coverage for arrayAttribute factory method
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 <[email protected]>
* feat: Add Object[] overload to arrayAttribute factory
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 <[email protected]>
* shape changelog
---------
Co-authored-by: Claude <[email protected]>1 parent 815e034 commit 4b1510b
31 files changed
Lines changed: 963 additions & 38 deletions
File tree
- sentry-samples/sentry-samples-spring-boot-4/src
- main/java/io/sentry/samples/spring/boot4
- test/kotlin/io/sentry/systemtest
- sentry-system-test-support
- api
- src/main/kotlin/io/sentry/systemtest/util
- sentry
- api
- src
- main/java/io/sentry
- logger
- metrics
- test
- java/io/sentry
- protocol
- resources/json
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
54 | 67 | | |
55 | 68 | | |
56 | 69 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
| 577 | + | |
| 578 | + | |
577 | 579 | | |
578 | 580 | | |
579 | 581 | | |
| |||
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
193 | 255 | | |
194 | 256 | | |
195 | 257 | | |
| |||
0 commit comments