Skip to content

feat(core): [Global Attributes 5] Support collections and arrays in log attributes#5124

Open
adinauer wants to merge 3 commits intofix/attribute-integer-type-detectionfrom
feat/log-attribute-array-support
Open

feat(core): [Global Attributes 5] Support collections and arrays in log attributes#5124
adinauer wants to merge 3 commits intofix/attribute-integer-type-detectionfrom
feat/log-attribute-array-support

Conversation

@adinauer
Copy link
Member

📜 Description

Adds ARRAY type support for log attribute type inference. Collections (List, Set, etc.) and arrays passed as attribute values are now correctly typed as "array" instead of falling through to "string" via toString().

Changes:

  • Add ARRAY enum value to SentryAttributeType
  • Update inferFrom() to detect Collection and array types
  • Add arrayAttribute() factory method to SentryAttribute
  • Add serialization test fixtures for array attributes

This follows the Python SDK's approach of using "array" as the attribute type for homogeneous collections.

💡 Motivation and Context

Fixes #5074 — Collections passed as log attribute values were being converted to strings, losing their structure. The serialization layer (JsonObjectSerializer) already handles Collections and arrays as JSON arrays, so only the type enum and inference needed updating.

💚 How did you test it?

  • Added 7 unit tests in SentryAttributeTypeTest covering List<String>, List<Integer>, Set<Boolean>, String[], int[], empty list, and mixed-type list
  • Updated SentryLogsSerializationTest with array attribute round-trip (serialize + deserialize)

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Stacked on #5075 (fix/attribute-integer-type-detection).

adinauer and others added 2 commits February 26, 2026 14:41
@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 5] Support collections and arrays in log attributes by adinauer in #5124
  • [Global Attributes 4] Detect integer attribute type correctly for all integer Number subtypes by adinauer in #5122
  • [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 8e61d4d

@adinauer adinauer changed the title feat: Support collections and arrays in log attributes feat(core): [Global Attributes 5] Support collections and arrays in log attributes 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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 278.00 ms 337.16 ms 59.16 ms
Size 1.58 MiB 2.29 MiB 719.88 KiB

@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.

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.

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