Skip to content

[Exporter.Prometheus] Refactor Prometheus serializer#7412

Draft
martincostello wants to merge 10 commits into
open-telemetry:mainfrom
martincostello:gh-7156-refactor-prometheus-serializer
Draft

[Exporter.Prometheus] Refactor Prometheus serializer#7412
martincostello wants to merge 10 commits into
open-telemetry:mainfrom
martincostello:gh-7156-refactor-prometheus-serializer

Conversation

@martincostello

@martincostello martincostello commented Jun 16, 2026

Copy link
Copy Markdown
Member

Contributes to #5725, #7155 and #7246.

Changes

  • Implement the logic for the new serializer design and wire into PrometheusCollectionManager.
  • Update the tests to call the new serializer instead of the old one.
  • Delete the old PrometheusSerializer class.
  • Improve test coverage.
  • Remove dead code.

WIP as I need to run the benchmarks and check for any clean-up.

The idea is that by splitting things out of the giant monolith we have today, text-format specific behaviours are easier to implement in future PRs.

When ready for review this will probably be easiest to review commit-by-commit (add new code, move tests, delete old code).

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 skeleton of new implementation.
Implement the logic for the new serializer design and wire into `PrometheusCollectionManager`.
Update the tests to call the new serializer instead of the old one.
Delete the old `PrometheusSerializer` class.
@github-actions github-actions Bot added pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package perf Performance related labels Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (184b1cf) to head (a68e49b).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7412      +/-   ##
==========================================
+ Coverage   89.74%   90.26%   +0.52%     
==========================================
  Files         276      279       +3     
  Lines       14623    15360     +737     
==========================================
+ Hits        13123    13865     +742     
+ Misses       1500     1495       -5     
Flag Coverage Δ
unittests-Project-Experimental 89.91% <100.00%> (+0.18%) ⬆️
unittests-Project-Stable 89.86% <100.00%> (+0.16%) ⬆️
unittests-UnstableCoreLibraries-Experimental 48.78% <100.00%> (+0.30%) ⬆️

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

Files with missing lines Coverage Δ
...ner/Internal/Shared/PrometheusCollectionManager.cs 90.20% <100.00%> (ø)
...rnal/Shared/Serialization/OpenMetricsSerializer.cs 100.00% <100.00%> (ø)
...l/Shared/Serialization/PrometheusTextSerializer.cs 100.00% <100.00%> (ø)
...ernal/Shared/Serialization/TextFormatSerializer.cs 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

- Use PascalCase and remove SA1310 suppression.
- Make suppression redundant.
- Use `///` comments.
- Remove redundant comments.
Fix typo in comment.
Add unit tests for missing patch coverage.
Remove dead code identified by Claude when trying to cover code that was identified as having no tests by codecov.io.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance related pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant