Skip to content

[Instana] Use System.Text.Json#4293

Merged
martincostello merged 21 commits intoopen-telemetry:mainfrom
martincostello:instana-use-system.text.json
Apr 27, 2026
Merged

[Instana] Use System.Text.Json#4293
martincostello merged 21 commits intoopen-telemetry:mainfrom
martincostello:instana-use-system.text.json

Conversation

@martincostello
Copy link
Copy Markdown
Member

Builds on top of #4153.

Changes

Use System.Text.Json to serialize spans.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

- 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.
@github-actions github-actions Bot added comp:exporter.influxdb Things related to OpenTelemetry.Exporter.InfluxDB comp:exporter.instana Things related to OpenTelemetry.Instrumentation.Instana labels Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 96.61017% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.83%. Comparing base (077386e) to head (82389a5).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...er.Instana/Implementation/InstanaSpanSerializer.cs 95.55% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests-Exporter.Instana 92.00% <96.61%> (+0.10%) ⬆️
unittests-Resources.Azure 88.31% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)

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

Files with missing lines Coverage Δ
...metry.Exporter.Instana/Implementation/Transport.cs 90.62% <100.00%> (+1.56%) ⬆️
...er.Instana/Implementation/InstanaSpanSerializer.cs 91.25% <95.55%> (-0.61%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the comp:exporter.influxdb Things related to OpenTelemetry.Exporter.InfluxDB label Apr 27, 2026
Comment thread src/OpenTelemetry.Exporter.Instana/OpenTelemetry.Exporter.Instana.csproj Outdated
Add changelog entry for changes.
@martincostello martincostello marked this pull request as ready for review April 27, 2026 10:39
@martincostello martincostello requested a review from a team as a code owner April 27, 2026 10:39
Copilot AI review requested due to automatic review settings April 27, 2026 10:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.Json package reference for TFMs below net8.0 and 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.

Comment thread src/OpenTelemetry.Exporter.Instana/Implementation/Transport.cs Outdated
Comment thread test/OpenTelemetry.Exporter.Instana.Tests/InstanaSpanSerializerTests.cs Outdated
- Match version used elswhere in the repo.
- Fix some formatting.
@github-actions github-actions Bot added comp:resources.azure Things related to OpenTelemetry.Resources.Azure comp:resources.gcp Things related to OpenTelemetry.Resources.Gcp labels Apr 27, 2026
Address review feedback.
@martincostello martincostello added this pull request to the merge queue Apr 27, 2026
Merged via the queue into open-telemetry:main with commit 4127cc6 Apr 27, 2026
83 checks passed
@martincostello martincostello deleted the instana-use-system.text.json branch April 27, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:exporter.instana Things related to OpenTelemetry.Instrumentation.Instana comp:resources.azure Things related to OpenTelemetry.Resources.Azure comp:resources.gcp Things related to OpenTelemetry.Resources.Gcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants