Skip to content

feat(core): Support homogeneous primitive arrays as span attributes#20427

Draft
nicohrubec wants to merge 5 commits intodevelopfrom
nh/array-attribute-support
Draft

feat(core): Support homogeneous primitive arrays as span attributes#20427
nicohrubec wants to merge 5 commits intodevelopfrom
nh/array-attribute-support

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented Apr 21, 2026

Relay's wire contract (AttributeType enum in relay-event-schema) defines exactly five type: tags: boolean, integer, double, string, array. The SDK's AttributeTypeMap previously declared typed array variants (string[], integer[], etc.) that Relay does not recognize - these were never actually emitted because the runtime serializer only handled primitives, so array-valued attributes silently dropped.

This change:

  • Collapses the four x[] variants in AttributeTypeMap into a single array variant whose value is Array<string> | Array<number> | Array<boolean>.
  • Extends getTypedAttributeValue to auto-detect homogeneous primitive arrays and emit {type: 'array', value: [...]}.
  • Adds an isHomogeneousPrimitiveArray guard so mixed-type and nested arrays remain unsupported (dropped by default, stringified under the fallback path).
  • Updates tests to cover the new typed-array path (including empty arrays, unit preservation, and mixed-type drop/stringify).

Relay's wire contract (AttributeType enum in relay-event-schema) defines
exactly five `type:` tags: boolean, integer, double, string, array.
The SDK's AttributeTypeMap previously declared typed array variants
(`string[]`, `integer[]`, etc.) that Relay does not recognize - these
were never actually emitted because the runtime serializer only handled
primitives, so array-valued attributes silently dropped.

This change:
- Collapses the four `x[]` variants in AttributeTypeMap into a single
  `array` variant whose value is `Array<string> | Array<number> | Array<boolean>`.
- Extends getTypedAttributeValue to auto-detect homogeneous primitive
  arrays and emit `{type: 'array', value: [...]}`.
- Adds an isHomogeneousPrimitiveArray guard so mixed-type and nested
  arrays remain unsupported (dropped by default, stringified under
  the fallback path).
- Updates tests to cover the new typed-array path (including empty
  arrays, unit preservation, and mixed-type drop/stringify).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.88 kB - -
@sentry/browser - with treeshaking flags 24.35 kB - -
@sentry/browser (incl. Tracing) 43.81 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 45.56 kB +0.14% +62 B 🔺
@sentry/browser (incl. Tracing, Profiling) 48.73 kB - -
@sentry/browser (incl. Tracing, Replay) 82.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 87.67 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 99.93 kB - -
@sentry/browser (incl. Feedback) 42.7 kB - -
@sentry/browser (incl. sendFeedback) 30.55 kB - -
@sentry/browser (incl. FeedbackAsync) 35.55 kB - -
@sentry/browser (incl. Metrics) 27.22 kB +0.22% +59 B 🔺
@sentry/browser (incl. Logs) 27.36 kB +0.28% +75 B 🔺
@sentry/browser (incl. Metrics & Logs) 28.04 kB +0.22% +60 B 🔺
@sentry/react 27.62 kB - -
@sentry/react (incl. Tracing) 46.05 kB - -
@sentry/vue 30.71 kB - -
@sentry/vue (incl. Tracing) 45.62 kB - -
@sentry/svelte 25.89 kB - -
CDN Bundle 28.63 kB +0.19% +54 B 🔺
CDN Bundle (incl. Tracing) 46.14 kB +0.14% +60 B 🔺
CDN Bundle (incl. Logs, Metrics) 30.01 kB +0.18% +53 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 47.18 kB +0.13% +61 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.97 kB +0.08% +51 B 🔺
CDN Bundle (incl. Tracing, Replay) 83.19 kB +0.07% +54 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.22 kB +0.07% +53 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 88.66 kB +0.07% +55 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 89.75 kB +0.07% +59 B 🔺
CDN Bundle - uncompressed 83.78 kB +0.23% +192 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 137.81 kB +0.14% +192 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.92 kB +0.22% +192 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 141.22 kB +0.14% +192 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 211.5 kB +0.1% +192 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 255.25 kB +0.08% +192 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 258.65 kB +0.08% +192 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 268.17 kB +0.08% +192 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 271.55 kB +0.08% +192 B 🔺
@sentry/nextjs (client) 48.58 kB - -
@sentry/sveltekit (client) 44.22 kB - -
@sentry/node-core 58.08 kB +0.11% +61 B 🔺
@sentry/node 174.94 kB +0.04% +61 B 🔺
@sentry/node - without tracing 98.04 kB +0.08% +72 B 🔺
@sentry/aws-serverless 115.26 kB +0.06% +69 B 🔺

View base workflow run

nicohrubec and others added 4 commits April 21, 2026 19:28
Arrays that were previously dropped by the serializer now ship as
native array attributes (`type: 'array'`). Update the affected
integration test expectations and bump size-limit thresholds for
the five bundle scenarios whose gzipped/uncompressed sizes grew
from the new serializer logic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the size-limit increases for the five bundle scenarios that grew
from adding homogeneous primitive array support. Test expectation
updates from the previous commit stay.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Re-apply the size-limit bumps needed to account for the new
homogeneous-primitive-array detection logic. Five scenarios grew
past their thresholds:

- @sentry/browser (incl. Metrics & Logs): 28 → 29 KB
- CDN Bundle (incl. Logs, Metrics): 30 → 31 KB
- CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed: 258.5 → 259 KB
- CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed: 268 → 269 KB
- CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed: 271.5 → 272 KB

Co-Authored-By: Claude Opus 4.7 (1M context) <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