feat(ext/telemetry): support array values in OTEL attributes#32748
feat(ext/telemetry): support array values in OTEL attributes#32748bartlomieju merged 5 commits intodenoland:mainfrom
Conversation
Closes denoland#27552 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ributes # Conflicts: # tests/specs/cli/otel_basic/__test__.jsonc
kajukitli
left a comment
There was a problem hiding this comment.
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.
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>
string[],number[],boolean[],bigint[])TODOin theattr_raw!macro inext/telemetry/lib.rsCloses #27552