From 288f5dbac1a6f3f69a80951af78e4a15fe8f6c9d Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Sat, 1 Jun 2024 06:35:42 -0700 Subject: [PATCH] [chore] make generate (#33328) This file needed regeneration --------- Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> Co-authored-by: Dan Jaglowski --- exporter/prometheusremotewriteexporter/go.mod | 2 +- .../internal/metadata/generated_telemetry.go | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/exporter/prometheusremotewriteexporter/go.mod b/exporter/prometheusremotewriteexporter/go.mod index c6c69abc2781..6b95198e28f7 100644 --- a/exporter/prometheusremotewriteexporter/go.mod +++ b/exporter/prometheusremotewriteexporter/go.mod @@ -18,6 +18,7 @@ require ( go.opentelemetry.io/collector/config/confighttp v0.101.1-0.20240529223953-eaab76e46d38 go.opentelemetry.io/collector/config/configopaque v1.8.1-0.20240529223953-eaab76e46d38 go.opentelemetry.io/collector/config/configretry v0.101.1-0.20240529223953-eaab76e46d38 + go.opentelemetry.io/collector/config/configtelemetry v0.101.1-0.20240529223953-eaab76e46d38 go.opentelemetry.io/collector/config/configtls v0.101.1-0.20240529223953-eaab76e46d38 go.opentelemetry.io/collector/confmap v0.101.1-0.20240529223953-eaab76e46d38 go.opentelemetry.io/collector/consumer v0.101.1-0.20240529223953-eaab76e46d38 @@ -65,7 +66,6 @@ require ( go.opentelemetry.io/collector v0.101.1-0.20240529223953-eaab76e46d38 // indirect go.opentelemetry.io/collector/config/configauth v0.101.1-0.20240529223953-eaab76e46d38 // indirect go.opentelemetry.io/collector/config/configcompression v1.8.1-0.20240529223953-eaab76e46d38 // indirect - go.opentelemetry.io/collector/config/configtelemetry v0.101.1-0.20240529223953-eaab76e46d38 // indirect go.opentelemetry.io/collector/config/internal v0.101.1-0.20240529223953-eaab76e46d38 // indirect go.opentelemetry.io/collector/extension v0.101.1-0.20240529223953-eaab76e46d38 // indirect go.opentelemetry.io/collector/extension/auth v0.101.1-0.20240529223953-eaab76e46d38 // indirect diff --git a/exporter/prometheusremotewriteexporter/internal/metadata/generated_telemetry.go b/exporter/prometheusremotewriteexporter/internal/metadata/generated_telemetry.go index bb4540e77242..2dc39557ca01 100644 --- a/exporter/prometheusremotewriteexporter/internal/metadata/generated_telemetry.go +++ b/exporter/prometheusremotewriteexporter/internal/metadata/generated_telemetry.go @@ -5,9 +5,12 @@ package metadata import ( "errors" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/trace" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configtelemetry" ) func Meter(settings component.TelemetrySettings) metric.Meter { @@ -23,20 +26,35 @@ func Tracer(settings component.TelemetrySettings) trace.Tracer { type TelemetryBuilder struct { ExporterPrometheusremotewriteFailedTranslations metric.Int64Counter ExporterPrometheusremotewriteTranslatedTimeSeries metric.Int64Counter + level configtelemetry.Level } // telemetryBuilderOption applies changes to default builder. type telemetryBuilderOption func(*TelemetryBuilder) +// WithLevel sets the current telemetry level for the component. +func WithLevel(lvl configtelemetry.Level) telemetryBuilderOption { + return func(builder *TelemetryBuilder) { + builder.level = lvl + } +} + // NewTelemetryBuilder provides a struct with methods to update all internal telemetry // for a component func NewTelemetryBuilder(settings component.TelemetrySettings, options ...telemetryBuilderOption) (*TelemetryBuilder, error) { - builder := TelemetryBuilder{} + builder := TelemetryBuilder{level: configtelemetry.LevelBasic} for _, op := range options { op(&builder) } - var err, errs error - meter := Meter(settings) + var ( + err, errs error + meter metric.Meter + ) + if builder.level >= configtelemetry.LevelBasic { + meter = Meter(settings) + } else { + meter = noop.Meter{} + } builder.ExporterPrometheusremotewriteFailedTranslations, err = meter.Int64Counter( "exporter_prometheusremotewrite_failed_translations", metric.WithDescription("Number of translation operations that failed to translate metrics from Otel to Prometheus"),