feat(core): [Global Attributes 5] Support collections and arrays in log attributes#5124
feat(core): [Global Attributes 5] Support collections and arrays in log attributes#5124adinauer wants to merge 2 commits intofix/attribute-integer-type-detectionfrom
Conversation
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
Bug Fixes 🐛
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
|
|
PR Stack (Global Attributes):
|
Performance metrics 🚀
|
|
@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.
| public static @NotNull SentryAttribute arrayAttribute( | ||
| final @NotNull String name, final @Nullable Collection<?> value) { | ||
| return new SentryAttribute(name, SentryAttributeType.ARRAY, value); | ||
| } |
There was a problem hiding this comment.
New arrayAttribute factory method is entirely unused and untested
Low Severity
The new arrayAttribute() factory method is never called anywhere in the codebase — not in production code and not in any tests. Every other sibling factory method (booleanAttribute, integerAttribute, doubleAttribute, stringAttribute) has test coverage and production usage, but arrayAttribute has none. This also means the method's behavior (e.g., correctly setting SentryAttributeType.ARRAY) is unverified.


📜 Description
Adds
ARRAYtype 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"viatoString().Changes:
ARRAYenum value toSentryAttributeTypeinferFrom()to detectCollectionand array typesarrayAttribute()factory method toSentryAttributeThis 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?
SentryAttributeTypeTestcoveringList<String>,List<Integer>,Set<Boolean>,String[],int[], empty list, and mixed-type listSentryLogsSerializationTestwith array attribute round-trip (serialize + deserialize)📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Stacked on #5075 (
fix/attribute-integer-type-detection).