[Instana] Use System.Text.Json#4293
Conversation
- Add support for configuring with options class. - Add `net8.0` and `net10.0` TFMs. - Use modern C# features. - Support batch export limit configuration and apply limits. - Remove sync-over-async. - Add support for custom `HttpClient` creation. - Remove redundant code.
- Fix InstanaExporterTests. - Update README. - Extend assertions to verify JSON payloads. - Remove redundant code. - Remove redundant mocks. - Fix some StyleCop warnings.
Fix most StyleCop warnings and remove unused constants.
Add tests for TracerProviderBuilder extensions.
- Write literal `true` string instead of computing it. - Fix-up comments. - Add TODO to remove manual JSON serialization.
Use System.Text.Json in tests instead.
Add CHANGELOG entry for TFM additions.
- Suppress `CA5399`. - Update CHANGELOG with PR number. - Tweak some XML documentation.
Move the suppression to the right place.
Address most Copilot code review comments.
Address more Copilot feedback.
Address final piece of Copilot review feedback.
The batch exporter already runs a background task to export, so use that rather than have another one just to use async.
Move entry to Unreleased.
Use System.Text.Json to serialize spans.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4293 +/- ##
==========================================
- Coverage 75.91% 75.83% -0.09%
==========================================
Files 466 466
Lines 18549 18475 -74
==========================================
- Hits 14081 14010 -71
+ Misses 4468 4465 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Add changelog entry for changes.
There was a problem hiding this comment.
Pull request overview
This PR updates the Instana exporter to use System.Text.Json/Utf8JsonWriter for span payload serialization, improving JSON correctness (escaping) and aligning with the broader move away from manual JSON building.
Changes:
- Replace manual JSON string writing with
Utf8JsonWriter-based serialization for Instana spans and bundle payloads. - Add/adjust unit tests to validate correct JSON encoding of quotes and newlines in exported span fields.
- Add conditional
System.Text.Jsonpackage reference for TFMs belownet8.0and record the change in the exporter changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Exporter.Instana.Tests/InstanaSpanSerializerTests.cs | Switch test serialization path to Utf8JsonWriter and continue validating round-trip JSON deserialization. |
| test/OpenTelemetry.Exporter.Instana.Tests/InstanaExporterTests.cs | Add test coverage ensuring exporter JSON payload correctly encodes quotes/newlines and event/tag content. |
| src/OpenTelemetry.Exporter.Instana/OpenTelemetry.Exporter.Instana.csproj | Add conditional System.Text.Json reference for non-net8.0+ TFMs. |
| src/OpenTelemetry.Exporter.Instana/Implementation/Transport.cs | Serialize the bundle request body using Utf8JsonWriter instead of manual string writing. |
| src/OpenTelemetry.Exporter.Instana/Implementation/InstanaSpanSerializer.cs | Rework span serialization to Utf8JsonWriter to ensure safe string encoding. |
| src/OpenTelemetry.Exporter.Instana/CHANGELOG.md | Document the serializer change under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Match version used elswhere in the repo. - Fix some formatting.
Address review feedback.
Builds on top of #4153.
Changes
Use System.Text.Json to serialize spans.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)