Skip to content

Commit 66761d6

Browse files
committed
chore(exporters): remove deprecated prometheus opts, use otel translator
1 parent 4450030 commit 66761d6

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

pkg/exporters/prometheusexporter/prometheus_exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strconv"
2323

2424
"github.com/prometheus/client_golang/prometheus/promhttp"
25+
"github.com/prometheus/otlptranslator"
2526
"go.opentelemetry.io/otel/exporters/prometheus"
2627
"k8s.io/klog/v2"
2728

@@ -40,9 +41,8 @@ func NewExporterOrDie(npdo *options.NodeProblemDetectorOptions) types.Exporter {
4041

4142
// Create Prometheus exporter with options to prevent automatic suffixing
4243
promExporter, err := prometheus.New(
43-
prometheus.WithoutCounterSuffixes(), // Don't add _total suffix to counters
44-
prometheus.WithoutUnits(), // Don't add unit-based suffixes like _ratio
45-
prometheus.WithoutScopeInfo(), // Don't add otel_scope_* labels
44+
prometheus.WithTranslationStrategy(otlptranslator.NoTranslation), // Don't add suffixes or escape
45+
prometheus.WithoutScopeInfo(), // Don't add otel_scope_* labels
4646
)
4747
if err != nil {
4848
klog.Fatalf("Failed to create Prometheus exporter: %v", err)

pkg/util/otel/common_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"sync"
2222
"testing"
2323

24+
"github.com/prometheus/otlptranslator"
2425
"go.opentelemetry.io/otel/exporters/prometheus"
2526
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
2627
"go.opentelemetry.io/otel/sdk/metric/metricdata"
@@ -182,9 +183,8 @@ func TestPrometheusExporterWithoutScopeLabels(t *testing.T) {
182183

183184
// Create a Prometheus exporter with WithoutScopeInfo to remove all scope labels
184185
promExporter, err := prometheus.New(
185-
prometheus.WithoutScopeInfo(), // Remove all otel_scope_* labels
186-
prometheus.WithoutCounterSuffixes(), // Don't add _total suffix to counters
187-
prometheus.WithoutUnits(), // Don't add unit-based suffixes
186+
prometheus.WithoutScopeInfo(), // Remove all otel_scope_* labels
187+
prometheus.WithTranslationStrategy(otlptranslator.NoTranslation), // Don't add suffixes or escape
188188
)
189189
if err != nil {
190190
t.Fatalf("Failed to create Prometheus exporter: %v", err)

0 commit comments

Comments
 (0)