Skip to content

feat(core): [Global Attributes 2]Wire scope attributes into LoggerApi and MetricsApi#5120

Open
adinauer wants to merge 2 commits intofeat/scope-attributesfrom
feat/scope-attributes-logger-metrics
Open

feat(core): [Global Attributes 2]Wire scope attributes into LoggerApi and MetricsApi#5120
adinauer wants to merge 2 commits intofeat/scope-attributesfrom
feat/scope-attributes-logger-metrics

Conversation

@adinauer
Copy link
Member

Note

Stacked on #5118

📜 Description

Wire scope-level attributes into LoggerApi and MetricsApi so 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 value
  • SentryLogEventAttributeValue.fromAttribute(SentryAttribute) — creates an attribute value from a SentryAttribute, inferring the type if not explicitly set

Both LoggerApi and MetricsApi now read scope attributes via getCombinedScopeView().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 both LoggerApi and MetricsApi.

💚 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

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>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 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 2]Wire scope attributes into LoggerApi and MetricsApi by adinauer in #5120
  • [Global Attributes 1] Add scope-level attributes API by adinauer in #5118

Bug Fixes 🐛

  • Safe unregister SystemEventsBroadcastReceiver by kollesnica1337 in #5106

Internal Changes 🔧

Deps

  • 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 Feb 26, 2026

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

Generated by 🚫 dangerJS against d535d44

@github-actions
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 321.85 ms 379.12 ms 57.27 ms
Size 1.58 MiB 2.29 MiB 719.89 KiB

Baseline results on branch: feat/scope-attributes

Startup times

Revision Plain With Sentry Diff
a1f07e7 405.02 ms 512.88 ms 107.86 ms
18e7c7e 306.83 ms 365.31 ms 58.47 ms

App size

Revision Plain With Sentry Diff
a1f07e7 1.58 MiB 2.29 MiB 719.88 KiB
18e7c7e 1.58 MiB 2.29 MiB 719.89 KiB

@adinauer adinauer changed the title feat(core): Wire scope attributes into LoggerApi and MetricsApi feat(core): [Global Attributes 2]Wire scope attributes into LoggerApi and MetricsApi Feb 26, 2026
@adinauer
Copy link
Member Author

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

@adinauer
Copy link
Member Author

@sentry review

@adinauer
Copy link
Member Author

cursor review

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

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.

1 participant