Skip to content

[API] Add propagation fuzz tests and fix findings#7061

Merged
martincostello merged 14 commits intoopen-telemetry:mainfrom
martincostello:propagator-fuzz-tests
Apr 13, 2026
Merged

[API] Add propagation fuzz tests and fix findings#7061
martincostello merged 14 commits intoopen-telemetry:mainfrom
martincostello:propagator-fuzz-tests

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented Apr 11, 2026

Changes

Add fuzz tests for the propagator classes.

I thought it would be a good idea to add these after working on #7059 and #7060 due to the amount of string parsing they do.

In the process of adding the new fuzz tests, some bugs were found in the processing that have now been fixed.

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)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 99.09091% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.51%. Comparing base (888d1bf) to head (652be5f).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...enTelemetry.Extensions.Propagators/B3Propagator.cs 98.07% 1 Missing ⚠️
...lemetry.Extensions.Propagators/JaegerPropagator.cs 97.95% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7061      +/-   ##
==========================================
+ Coverage   88.29%   88.51%   +0.22%     
==========================================
  Files         270      270              
  Lines       12759    12884     +125     
==========================================
+ Hits        11265    11404     +139     
+ Misses       1494     1480      -14     
Flag Coverage Δ
unittests-Project-Experimental 88.46% <99.09%> (+0.39%) ⬆️
unittests-Project-Stable 88.13% <99.09%> (-0.04%) ⬇️
unittests-Solution 88.46% <99.09%> (+0.25%) ⬆️

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

Files with missing lines Coverage Δ
...nTelemetry.Api/Context/Propagation/B3Propagator.cs 89.07% <100.00%> (+2.75%) ⬆️
...metry.Api/Context/Propagation/BaggagePropagator.cs 88.23% <100.00%> (+2.08%) ⬆️
....Api/Context/Propagation/TraceContextPropagator.cs 93.37% <100.00%> (+2.97%) ⬆️
...lemetry.Api/Context/Propagation/TraceStateUtils.cs 91.07% <100.00%> (+6.37%) ⬆️
...enTelemetry.Extensions.Propagators/B3Propagator.cs 88.98% <98.07%> (+3.87%) ⬆️
...lemetry.Extensions.Propagators/JaegerPropagator.cs 95.28% <97.95%> (+1.25%) ⬆️

... and 8 files with indirect coverage changes

@martincostello martincostello marked this pull request as ready for review April 11, 2026 11:01
@martincostello martincostello requested a review from a team as a code owner April 11, 2026 11:01
Copilot AI review requested due to automatic review settings April 11, 2026 11:01
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

Adds a new OpenTelemetry.Api.FuzzTests test project to exercise propagation-related APIs with FsCheck-based property tests, aiming to harden string parsing and ensure stable behavior across a wide range of generated inputs.

Changes:

  • Introduce a new fuzz test project (OpenTelemetry.Api.FuzzTests) targeting the repo’s test TFMs and using FsCheck.Xunit.
  • Add property-based fuzz tests for TraceContextPropagator, BaggagePropagator, and B3Propagator, plus shared generators/helpers.
  • Include the new fuzz test project in OpenTelemetry.slnx.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/OpenTelemetry.Api.FuzzTests/OpenTelemetry.Api.FuzzTests.csproj New fuzz test project definition with FsCheck and OpenTelemetry.Api reference.
test/OpenTelemetry.Api.FuzzTests/Context/Propagation/TraceContextPropagatorFuzzTests.cs Adds property tests for trace context inject/extract round-trips and determinism.
test/OpenTelemetry.Api.FuzzTests/Context/Propagation/BaggagePropagatorFuzzTests.cs Adds property tests for baggage round-trips, size limits, and determinism.
test/OpenTelemetry.Api.FuzzTests/Context/Propagation/B3PropagatorFuzzTests.cs Adds property tests for obsolete B3 propagator (single/multi header) round-trips and determinism.
test/OpenTelemetry.Api.FuzzTests/Context/Propagation/Generators.cs Provides FsCheck generators for contexts and arbitrary header carriers.
test/OpenTelemetry.Api.FuzzTests/Context/Propagation/FuzzTestHelpers.cs Shared getter/setter delegates, carrier cloning/comparison, and allowed-exception filter.
OpenTelemetry.slnx Adds the new fuzz test project to the solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot added pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package labels Apr 11, 2026
@martincostello martincostello changed the title [API] Add propagation fuzz tests [API] Add propagation fuzz tests and fix findings Apr 13, 2026
Add fuzz tests for the propagator classes.
Fix baggage length being exceeded.
Add more tests around exceeding the maximum length.
Add entry for bug fix.
Add missing access modifier.
Reduce allocations when parsing propagation headers.
- Improve baggage, B3 and Jaeger header parsing.
- Add fuzz tests for the OpenTelemetry.Extensions.Propagators library.
- Update CHANGELOGs.
Apply manual refactoring to Copilot edits to improve readability, add more tests and use `SearchValues<T>` where available.
- Avoid LINQ.
- Use spans where possible.
Add fuzzing for previous commit.
@martincostello martincostello force-pushed the propagator-fuzz-tests branch from 324eb7b to 663c1c4 Compare April 13, 2026 09:33
@martincostello

This comment was marked as outdated.

@martincostello

This comment was marked as outdated.

Fix trace propagation not always enforcing limits.
@github-actions github-actions Bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Apr 13, 2026
Add benchmarks for `B3Propagator` and `JaegerPropagator` to use to compute impact of changes.
@github-actions github-actions Bot added the perf Performance related label Apr 13, 2026
Add missing test coverage for B3 and Jaeger.
This was referenced Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance related pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants