Skip to content

fix: Complete array attribute serialization for all payload types#3531

Merged
tippmar-nr merged 5 commits intomainfrom
fix/array-attribute-serialization
Apr 10, 2026
Merged

fix: Complete array attribute serialization for all payload types#3531
tippmar-nr merged 5 commits intomainfrom
fix/array-attribute-serialization

Conversation

@tippmar-nr
Copy link
Copy Markdown
Member

@tippmar-nr tippmar-nr commented Apr 9, 2026

Description

PR #3456 added array serialization in JsonSerializerHelpers but missed two code paths:

  1. GenericConverter (AttributeDefinition.cs): No IEnumerable case — arrays fell through to ToString(), producing garbage like System.Int32[] in transaction traces and events.
  2. AttributeValue.SetValue (Segments/AttributeValue.cs): The protobuf-backed AttributeValue for span events had no IEnumerable handling — arrays fell through to TypeCode.ObjectToString()→ garbage strings.

Changes

  • GenericConverter: Added IEnumerable case with recursive element conversion and null filtering
  • Segments/AttributeValue: Added _arrayValue field and IEnumerable handling in SetValue; updated Value getter to return array data
  • Unit tests: GenericConverterTests (11 new), EventWireModelSerializerTests (5 new)
  • Composite tests: Updated Assertions.HaveSameValue for IEnumerable element-wise comparison; added SpanCustomAttributes_WithArrays test
  • Integration tests: Array attribute assertions for transaction traces, transaction events, and span events

Fixes #3530

tippmar-nr and others added 4 commits April 9, 2026 12:55
PR #3456 added array serialization in JsonSerializerHelpers but missed two code paths:

1. GenericConverter in AttributeDefinition.cs - arrays fell through to ToString(), producing garbage strings like 'System.Int32[]' in transaction traces and events.

2. AttributeValue.SetValue in Segments/AttributeValue.cs - the protobuf-backed AttributeValue used by SpanAttributeValueCollection had no IEnumerable handling, so arrays fell through to TypeCode.Object -> ToString() in span events.

Fixes both converters and adds unit tests (GenericConverter, SpanEventWireModel) and integration tests (transaction trace, transaction event, and span event assertions).

Co-authored-by: GitHub Copilot <copilot@github.com>
Co-authored-by: GitHub Copilot <copilot@github.com>
@tippmar-nr tippmar-nr marked this pull request as ready for review April 9, 2026 20:05
@tippmar-nr tippmar-nr requested a review from a team as a code owner April 9, 2026 20:05
Comment thread src/Agent/NewRelic/Agent/Core/Segments/AttributeValue.cs
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.78%. Comparing base (3e94fb9) to head (400ede0).

Files with missing lines Patch % Lines
...ent/NewRelic/Agent/Core/Segments/AttributeValue.cs 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3531      +/-   ##
==========================================
- Coverage   81.79%   81.78%   -0.02%     
==========================================
  Files         508      508              
  Lines       34345    34365      +20     
  Branches     4061     4067       +6     
==========================================
+ Hits        28092    28104      +12     
- Misses       5285     5290       +5     
- Partials      968      971       +3     
Flag Coverage Δ
Agent 82.76% <95.00%> (-0.02%) ⬇️
Profiler 71.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...Relic/Agent/Core/Attributes/AttributeDefinition.cs 88.21% <100.00%> (+0.48%) ⬆️
...ent/NewRelic/Agent/Core/Segments/AttributeValue.cs 76.66% <88.88%> (+1.35%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/Agent/NewRelic/Agent/Core/Segments/AttributeValue.cs
@tippmar-nr tippmar-nr merged commit 62bdb44 into main Apr 10, 2026
122 checks passed
@tippmar-nr tippmar-nr deleted the fix/array-attribute-serialization branch April 10, 2026 17:16
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.

Custom array attributes serialized incorrectly in span events and transaction traces

3 participants