feat(core): [Global Attributes 2] Wire scope attributes into LoggerApi and MetricsApi#5120
Conversation
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>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Core
Other
Bug Fixes 🐛
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- [Global Attributes 2] Wire scope attributes into LoggerApi and MetricsApi ([#5120](https://github.com/getsentry/sentry-java/pull/5120))If none of the above apply, you can opt out of this check by adding |
Performance metrics 🚀
|
|
PR Stack (Global Attributes):
|
|
@sentry review |
|
cursor review |
There was a problem hiding this comment.
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.
| <meta-data android:name="io.sentry.screenshot.mask-all-text" android:value="true" /> | ||
| <meta-data android:name="io.sentry.screenshot.mask-all-images" android:value="true" /> | ||
| ``` | ||
| >>>>>>> feat/global-attributes-api |
There was a problem hiding this comment.
Unresolved Git Merge Conflict in Changelog
Medium Severity
CHANGELOG.md contains unresolved git merge conflict markers (<<<<<<<, =======, >>>>>>>). These markers were accidentally committed and will appear verbatim in the published changelog, making it malformed and confusing to readers. Both conflict sides need to be manually reconciled and the markers removed before merging.


Note
Stacked on #5118
📜 Description
Wire scope-level attributes into
LoggerApiandMetricsApiso they are automatically included in log and metric events. Also extracts duplicated type-inference logic into reusable factory methods:SentryAttributeType.inferFrom(Object)— infers the attribute type from a valueSentryLogEventAttributeValue.fromAttribute(SentryAttribute)— creates an attribute value from aSentryAttribute, inferring the type if not explicitly setBoth
LoggerApiandMetricsApinow read scope attributes viagetCombinedScopeView().getAttributes()and include them as the base set of attributes on every log/metric event (user-provided attributes take precedence).💡 Motivation and Context
With scope-level attributes added in #5118, this PR completes the integration by ensuring those attributes flow through to logs and metrics automatically. The factory method extraction removes duplicated
getType()methods that existed in bothLoggerApiandMetricsApi.💚 How did you test it?
LoggerApiandMetricsApicontinue to pass📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
main