Skip to content

feat(ext/telemetry): support array values in OTEL attributes#32748

Merged
bartlomieju merged 5 commits intodenoland:mainfrom
bartlomieju:feat/otel-array-attributes
Mar 16, 2026
Merged

feat(ext/telemetry): support array values in OTEL attributes#32748
bartlomieju merged 5 commits intodenoland:mainfrom
bartlomieju:feat/otel-array-attributes

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju commented Mar 15, 2026

  • Implements homogeneous array support for OTEL attributes (string[], number[], boolean[], bigint[])
  • Fills in the existing TODO in the attr_raw! macro in ext/telemetry/lib.rs
  • Non-homogeneous elements are silently skipped (consistent with existing drop behavior)

Closes #27552

Closes denoland#27552

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ributes

# Conflicts:
#	tests/specs/cli/otel_basic/__test__.jsonc
@bartlomieju bartlomieju requested a review from crowlKats March 15, 2026 13:20
Copy link
Copy Markdown
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes OpenTelemetry attribute handling to silently skip array elements that don't match the detected type (based on first element). This causes data loss for mixed-type arrays without any warning, and the pre-allocated vector capacity will be larger than needed. While empty arrays being typed as String is a minor concern, the silent data loss in mixed-type arrays could lead to hard-to-debug production issues.

[MEDIUM] ext/telemetry/lib.rs:1241: Silent element skipping in array attribute processing. When iterating array elements, if try_cast fails for an element (e.g., mixed-type arrays like ['a', 1, 'b']), the element is silently skipped. This causes the resulting array to have fewer elements than the input, potentially causing data loss without any warning. The pre-allocated Vec::with_capacity(len) will also be larger than the actual elements pushed.

Suggestion: Consider either: (1) returning None for the entire array if any element doesn't match the expected type, (2) logging a warning when elements are skipped, or (3) documenting this behavior explicitly. The OpenTelemetry spec requires homogeneous arrays, so rejecting the entire array might be the most correct approach.

bartlomieju and others added 2 commits March 16, 2026 15:28
Resolve conflict in otel_basic __test__.jsonc — keep both
array_attributes and console_time test entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that when an array attribute contains mixed types, the type
is determined by the first element and mismatched elements are silently
dropped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju merged commit f0e7923 into denoland:main Mar 16, 2026
112 checks passed
@bartlomieju bartlomieju deleted the feat/otel-array-attributes branch March 16, 2026 18:39
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.

Add support for arrays in OTEL attributes

3 participants