diff --git a/config/metric.go b/config/metric.go index acc86de3f7e..fb2dd23905c 100644 --- a/config/metric.go +++ b/config/metric.go @@ -297,28 +297,6 @@ func newIncludeExcludeFilter(lists *IncludeExclude) (attribute.Filter, error) { }, nil } -func prometheusReaderOpts(prometheusConfig *Prometheus) ([]otelprom.Option, error) { - var opts []otelprom.Option - if prometheusConfig.WithoutScopeInfo != nil && *prometheusConfig.WithoutScopeInfo { - opts = append(opts, otelprom.WithoutScopeInfo()) - } - if prometheusConfig.WithoutTypeSuffix != nil && *prometheusConfig.WithoutTypeSuffix { - opts = append(opts, otelprom.WithoutCounterSuffixes()) - } - if prometheusConfig.WithoutUnits != nil && *prometheusConfig.WithoutUnits { - opts = append(opts, otelprom.WithoutUnits()) - } - if prometheusConfig.WithResourceConstantLabels != nil { - f, err := newIncludeExcludeFilter(prometheusConfig.WithResourceConstantLabels) - if err != nil { - return nil, err - } - opts = append(opts, otelprom.WithResourceAsConstantLabels(f)) - } - - return opts, nil -} - func prometheusReader(ctx context.Context, prometheusConfig *Prometheus) (sdkmetric.Reader, error) { if prometheusConfig.Host == nil { return nil, fmt.Errorf("host must be specified") @@ -368,6 +346,28 @@ func prometheusReader(ctx context.Context, prometheusConfig *Prometheus) (sdkmet return readerWithServer{reader, &server}, nil } +func prometheusReaderOpts(prometheusConfig *Prometheus) ([]otelprom.Option, error) { + var opts []otelprom.Option + if prometheusConfig.WithoutScopeInfo != nil && *prometheusConfig.WithoutScopeInfo { + opts = append(opts, otelprom.WithoutScopeInfo()) + } + if prometheusConfig.WithoutTypeSuffix != nil && *prometheusConfig.WithoutTypeSuffix { + opts = append(opts, otelprom.WithoutCounterSuffixes()) + } + if prometheusConfig.WithoutUnits != nil && *prometheusConfig.WithoutUnits { + opts = append(opts, otelprom.WithoutUnits()) + } + if prometheusConfig.WithResourceConstantLabels != nil { + f, err := newIncludeExcludeFilter(prometheusConfig.WithResourceConstantLabels) + if err != nil { + return nil, err + } + opts = append(opts, otelprom.WithResourceAsConstantLabels(f)) + } + + return opts, nil +} + type readerWithServer struct { sdkmetric.Reader server *http.Server