[Exporter.Prometheus] Add translation strategy infra#7503
[Exporter.Prometheus] Add translation strategy infra#7503martincostello wants to merge 2 commits into
Conversation
Introduce internal `PrometheusTranslationStrategy` enum and thread a metric-name suffix-suppression policy from options through to `PrometheusMetric`. Contributes to open-telemetry#7156.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7503 +/- ##
=======================================
Coverage 90.26% 90.26%
=======================================
Files 288 289 +1
Lines 15658 15687 +29
=======================================
+ Hits 14133 14160 +27
- Misses 1525 1527 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Clarify comment based on review by Claude.
There was a problem hiding this comment.
Pull request overview
Introduces internal infrastructure for Prometheus translation strategy selection and threads a “metric name suffix suppression” policy from exporter options into PrometheusMetric, enabling future configuration of name translation behavior.
Changes:
- Add internal
PrometheusTranslationStrategyenum plus extension helpers for mapping strategy → escaping scheme and suffix behavior. - Plumb
TranslationStrategyfromPrometheusExporterOptions→PrometheusExporter→PrometheusCollectionManager→PrometheusMetricto control whether unit/_totalsuffixes are appended. - Add/extend unit tests to validate suffix-suppression behavior and strategy mappings.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusTranslationStrategyTests.cs | Adds unit tests for strategy defaults and mapping behavior. |
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusMetricTests.cs | Adds test coverage for appendSuffixes: false behavior across escaping schemes and counter naming. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusTranslationStrategyExtensions.cs | Adds internal mapping helpers from translation strategy to escaping/suffix behavior. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusTranslationStrategy.cs | Introduces the internal translation strategy enum. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusMetric.cs | Implements suffix suppression in name generation and threads appendSuffixes through all name builders. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusExporterOptions.cs | Adds TranslationStrategy option with default. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusExporter.cs | Stores the configured strategy and exposes AppendSuffixes derived from it. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs | Passes exporter suffix policy into PrometheusMetric.Create. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributes to #7156
Changes
Introduce internal
PrometheusTranslationStrategyenum and thread a metric-name suffix-suppression policy from options through toPrometheusMetric.A follow-up PR will expose the option into the public API and configure how it interacts with the
Acceptheader to determine precedence.Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)