From 91bbe8ccee50833b05f73764699fd6a6fca8814a Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Fri, 30 Aug 2024 09:36:19 -0700 Subject: [PATCH] prevent prom remote write test from testing underlying library instrumentation Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- .../prometheusremotewriteexporter/exporter_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index 00c0ba318ffe..2f7cd44a65dd 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -23,6 +23,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configretry" + "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" @@ -30,6 +31,8 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/sdk/metric/metricdata" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" @@ -734,6 +737,15 @@ func Test_PushMetrics(t *testing.T) { } tel := setupTestTelemetry() set := tel.NewSettings() + mp := set.LeveledMeterProvider(configtelemetry.LevelBasic) + set.LeveledMeterProvider = func(level configtelemetry.Level) metric.MeterProvider { + // detailed level enables otelhttp client instrumentation which we + // dont want to test here + if level == configtelemetry.LevelDetailed { + return noop.MeterProvider{} + } + return mp + } set.BuildInfo = buildInfo prwe, nErr := newPRWExporter(cfg, set)