feat: add array support for custom attributes in .NET Agent API#3456
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add comprehensive integration test classes for both .NET Framework and .NET Core - Extend test applications with new array attribute endpoints - Add RemoteServiceFixture helper methods for array testing - Update Assertions.cs to support array validation in tests - Verify arrays work in transaction traces, transaction events, and error telemetry - Test empty array filtering and null element removal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add support for string[], int[], bool[] typed arrays in test assertions - Extract array validation logic into ValidateArrayAttribute helper method - Handle JArray deserialization from JSON properly - Improve error messages with type information - Add regular attributes to empty array test endpoints to ensure transaction capture Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… support - Add array attribute endpoints to both .NET Framework and .NET Core test applications - Create integration test classes for testing array serialization end-to-end - Test string, int, and bool arrays in transaction traces and events - Verify empty arrays and null-only arrays are properly skipped - Test null filtering within arrays (nulls are excluded from serialized arrays) - Support both ASP.NET Framework (WebAPI) and ASP.NET Core applications - Add remote service fixture methods for exercising array endpoints - Fix test reliability by using transaction events for multi-endpoint scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add comprehensive integration test classes for both .NET Framework and .NET Core - Extend test applications with new array attribute endpoints - Add RemoteServiceFixture helper methods for array testing - Update Assertions.cs to support array validation in tests - Verify arrays work in transaction traces, transaction events, and error telemetry - Test empty array filtering and null element removal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add support for string[], int[], bool[] typed arrays in test assertions - Extract array validation logic into ValidateArrayAttribute helper method - Handle JArray deserialization from JSON properly - Improve error messages with type information - Add regular attributes to empty array test endpoints to ensure transaction capture Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… support - Add array attribute endpoints to both .NET Framework and .NET Core test applications - Create integration test classes for testing array serialization end-to-end - Test string, int, and bool arrays in transaction traces and events - Verify empty arrays and null-only arrays are properly skipped - Test null filtering within arrays (nulls are excluded from serialized arrays) - Support both ASP.NET Framework (WebAPI) and ASP.NET Core applications - Add remote service fixture methods for exercising array endpoints - Fix test reliability by using transaction events for multi-endpoint scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d46e9e4 to
32a626f
Compare
…b.com/newrelic/newrelic-dotnet-agent into feature/json-serializer-array-support
…ath coverage - Add tests for all numeric types: double, float, decimal, long, char - Add tests for unsigned types: ushort, uint, ulong - Add tests for signed types: short, sbyte, byte - Add tests for character and boolean arrays - Add tests for non-serializable objects to cover exception handling path - Add tests for mixed numeric types in arrays - Achieve 100% branch coverage for JsonSerializerHelpers.WriteValue() method - All 27 unit tests passing with comprehensive validation of all execution paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…est controller - Remove leftover CustomArrayErrorAttributes method that attempted to pass arrays to NoticeError() - Error attributes do not support arrays and this functionality will not be implemented - Ensures test applications only contain valid array attribute endpoints - Maintains clean separation between AddCustomAttribute (supports arrays) and NoticeError (does not) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jaffinito
reviewed
Feb 20, 2026
…lizerHelpers - Revert unnecessary ReSharper refactor that introduced inconsistent variable naming - Use discard pattern (_) consistently across all switch cases - Maintain original value parameter usage for cleaner, more consistent code - Addresses review feedback about variable naming inconsistencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
|
✅ Review comments addressed: Reverted JsonSerializerHelpers switch cases to use discard pattern (_) as originally implemented, fixing the inconsistent variable naming from the ReSharper refactor. |
jaffinito
approved these changes
Feb 24, 2026
jaffinito
pushed a commit
that referenced
this pull request
Mar 2, 2026
* feat: add array support to JsonSerializerHelpers with null filtering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add integration tests for array custom attributes - Add comprehensive integration test classes for both .NET Framework and .NET Core - Extend test applications with new array attribute endpoints - Add RemoteServiceFixture helper methods for array testing - Update Assertions.cs to support array validation in tests - Verify arrays work in transaction traces, transaction events, and error telemetry - Test empty array filtering and null element removal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: Minor refactoring and cleanup * fix: improve array validation in integration test assertions - Add support for string[], int[], bool[] typed arrays in test assertions - Extract array validation logic into ValidateArrayAttribute helper method - Handle JArray deserialization from JSON properly - Improve error messages with type information - Add regular attributes to empty array test endpoints to ensure transaction capture Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add comprehensive integration tests for custom attributes array support - Add array attribute endpoints to both .NET Framework and .NET Core test applications - Create integration test classes for testing array serialization end-to-end - Test string, int, and bool arrays in transaction traces and events - Verify empty arrays and null-only arrays are properly skipped - Test null filtering within arrays (nulls are excluded from serialized arrays) - Support both ASP.NET Framework (WebAPI) and ASP.NET Core applications - Add remote service fixture methods for exercising array endpoints - Fix test reliability by using transaction events for multi-endpoint scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add array support to JsonSerializerHelpers with null filtering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add integration tests for array custom attributes - Add comprehensive integration test classes for both .NET Framework and .NET Core - Extend test applications with new array attribute endpoints - Add RemoteServiceFixture helper methods for array testing - Update Assertions.cs to support array validation in tests - Verify arrays work in transaction traces, transaction events, and error telemetry - Test empty array filtering and null element removal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: Minor refactoring and cleanup * fix: improve array validation in integration test assertions - Add support for string[], int[], bool[] typed arrays in test assertions - Extract array validation logic into ValidateArrayAttribute helper method - Handle JArray deserialization from JSON properly - Improve error messages with type information - Add regular attributes to empty array test endpoints to ensure transaction capture Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add comprehensive integration tests for custom attributes array support - Add array attribute endpoints to both .NET Framework and .NET Core test applications - Create integration test classes for testing array serialization end-to-end - Test string, int, and bool arrays in transaction traces and events - Verify empty arrays and null-only arrays are properly skipped - Test null filtering within arrays (nulls are excluded from serialized arrays) - Support both ASP.NET Framework (WebAPI) and ASP.NET Core applications - Add remote service fixture methods for exercising array endpoints - Fix test reliability by using transaction events for multi-endpoint scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: enhance JsonSerializerHelpers test coverage for complete code path coverage - Add tests for all numeric types: double, float, decimal, long, char - Add tests for unsigned types: ushort, uint, ulong - Add tests for signed types: short, sbyte, byte - Add tests for character and boolean arrays - Add tests for non-serializable objects to cover exception handling path - Add tests for mixed numeric types in arrays - Achieve 100% branch coverage for JsonSerializerHelpers.WriteValue() method - All 27 unit tests passing with comprehensive validation of all execution paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * cleanup: remove CustomArrayErrorAttributes method from ASP.NET Core test controller - Remove leftover CustomArrayErrorAttributes method that attempted to pass arrays to NoticeError() - Error attributes do not support arrays and this functionality will not be implemented - Ensures test applications only contain valid array attribute endpoints - Maintains clean separation between AddCustomAttribute (supports arrays) and NoticeError (does not) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: revert to discard pattern for switch case variables in JsonSerializerHelpers - Revert unnecessary ReSharper refactor that introduced inconsistent variable naming - Use discard pattern (_) consistently across all switch cases - Maintain original value parameter usage for cleaner, more consistent code - Addresses review feedback about variable naming inconsistencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3456 +/- ##
==========================================
+ Coverage 81.64% 81.68% +0.04%
==========================================
Files 508 508
Lines 33944 33963 +19
Branches 3999 4003 +4
==========================================
+ Hits 27712 27743 +31
+ Misses 5273 5264 -9
+ Partials 959 956 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Mar 23, 2026
This was referenced Mar 25, 2026
This was referenced Apr 1, 2026
tippmar-nr
added a commit
that referenced
this pull request
Apr 9, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive array support for custom attributes in the New Relic .NET Agent API, allowing developers to pass array values to
AddCustomAttribute()that are properly serialized as JSON arrays.Changes Made
Core Implementation
JsonSerializerHelpers.cs:IEnumerabletypes (arrays, lists, etc.)WriteValuemethod for all value typesComprehensive Testing
Unit Tests (
Core.UnitTest)JsonSerializerHelpersTestscovering all array scenariosIntegration Tests
CustomArrayAttributes- Tests string, int, bool arraysCustomEmptyArrayAttributes- Tests empty/null-only array handlingCustomArrayWithNulls- Tests null filtering within arraysAPI Usage
Developers can now use array values with the New Relic API:
Behavior
["red", "green", "blue"]["first", null, "third"]→["first", "third"]IEnumerableTesting Results
Verified correct behavior in the New Relic UI:

Backward Compatibility
This feature enables developers to provide richer telemetry data by including array-based custom attributes that are properly structured and queryable in New Relic.