Skip to content

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

Merged
adinauer merged 3 commits intofeat/global-attributes-apifrom
feat/log-attribute-array-support
Mar 3, 2026
Merged

feat(core): [Global Attributes 5] Support collections and arrays in log attributes#5124
adinauer merged 3 commits intofeat/global-attributes-apifrom
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 1] Add scope-level attributes API by adinauer in #5118
  • [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

Other

  • (otel) Create sentry-opentelemetry-otlp module for combining OpenTelemetry SDK OTLP export with Sentry SDK by adinauer in #5100
  • (screenshot) Add screenshot masking using view hierarchy by romtsn in #5077

Bug Fixes 🐛

  • (android) Remove AndroidRuntimeManager to prevent ANRs during SDK init by romtsn in #5127
  • (gestures) Use peekDecorView to not force view hierarchy construction by romtsn in #5134
  • (init) Reduce allocations and bytecode instructions during Sentry.init by romtsn in #5135
  • (transport) Handle HTTP 413 with actionable log and use send_error for HTTP errors by adinauer in #5115
  • Trim DSN string before URI parsing by adinauer in #5113
  • Safe unregister SystemEventsBroadcastReceiver by kollesnica1337 in #5106

Internal Changes 🔧

Deps

  • Bump getsentry/craft from 2.21.7 to 2.23.1 by dependabot in #5129
  • Update Native SDK to v0.13.1 by github-actions in #5104
  • Bump actions/upload-artifact from 6 to 7 by dependabot in #5130
  • Bump actions/download-artifact from 7 to 8 by dependabot in #5132
  • Bump gradle/actions from 5.0.1 to 5.0.2 by dependabot in #5131
  • 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 307.83 ms 371.40 ms 63.57 ms
Size 1.58 MiB 2.29 MiB 719.89 KiB

Previous results on branch: feat/log-attribute-array-support

Startup times

Revision Plain With Sentry Diff
db2b29b 335.76 ms 414.16 ms 78.41 ms
c884e9b 278.00 ms 337.16 ms 59.16 ms

App size

Revision Plain With Sentry Diff
db2b29b 1.58 MiB 2.29 MiB 719.89 KiB
c884e9b 1.58 MiB 2.29 MiB 719.88 KiB

@adinauer
Copy link
Member Author

@sentry review

@adinauer
Copy link
Member Author

cursor review

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

@adinauer adinauer force-pushed the feat/log-attribute-array-support branch from 9da8135 to 8e61d4d Compare March 3, 2026 14:25
Base automatically changed from fix/attribute-integer-type-detection to feat/global-attributes-api March 3, 2026 14:51
@adinauer adinauer merged commit 3e35f04 into feat/global-attributes-api Mar 3, 2026
121 checks passed
@adinauer adinauer deleted the feat/log-attribute-array-support branch March 3, 2026 16:57
@adinauer adinauer mentioned this pull request Mar 4, 2026
8 tasks
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.

2 participants