Skip to content

Commit f028ab8

Browse files
committed
fix(prometheus): drop target_info from scrape output
1 parent 2b0d66a commit f028ab8

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

pkg/exporters/prometheusexporter/prometheus_exporter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func newExporterAndHandler() (*otelprometheus.Exporter, http.Handler, error) {
4747
otelprometheus.WithRegisterer(reg), // Use a dedicated registry
4848
otelprometheus.WithTranslationStrategy(otlptranslator.NoTranslation), // Don't add suffixes or escape
4949
otelprometheus.WithoutScopeInfo(), // Don't add otel_scope_* labels
50+
otelprometheus.WithoutTargetInfo(), // Don't emit target_info with resource attributes
5051
)
5152
if err != nil {
5253
return nil, nil, err

pkg/exporters/prometheusexporter/prometheus_exporter_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ func TestScrapeExcludesDefaultCollectors(t *testing.T) {
8989
t.Errorf("Expected scrape output to contain recorded metric %q, got:\n%s", "test_problem_counter", output)
9090
}
9191

92-
// The default Go runtime / process collectors must NOT be present.
93-
for _, unwanted := range []string{"go_goroutines", "process_cpu_seconds_total"} {
92+
// The default Go runtime / process collectors and the target_info metric
93+
// (which would expose the shared OTel resource attributes) must NOT be
94+
// present.
95+
for _, unwanted := range []string{"go_goroutines", "process_cpu_seconds_total", "target_info"} {
9496
if strings.Contains(output, unwanted) {
95-
t.Errorf("Expected scrape output to NOT contain default collector metric %q, got:\n%s", unwanted, output)
97+
t.Errorf("Expected scrape output to NOT contain metric %q, got:\n%s", unwanted, output)
9698
}
9799
}
98100
}

0 commit comments

Comments
 (0)