From a5577e0abe7d4369d1347c5ca8712d02ce26235f Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:58:18 +0000 Subject: [PATCH] Address PR comments --- exporters/prometheus/confg_test.go | 23 +++++++++++------------ exporters/prometheus/config.go | 4 ++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/exporters/prometheus/confg_test.go b/exporters/prometheus/confg_test.go index 1705c86ae89..52bccff2587 100644 --- a/exporters/prometheus/confg_test.go +++ b/exporters/prometheus/confg_test.go @@ -19,6 +19,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" + "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/aggregation" "go.opentelemetry.io/otel/sdk/metric/view" @@ -85,28 +86,26 @@ func TestConfigManualReaderOptions(t *testing.T) { aggregationSelector := func(view.InstrumentKind) aggregation.Aggregation { return nil } testCases := []struct { - name string - config config - wantOption []metric.ManualReaderOption + name string + config config + wantOptionCount int }{ { - name: "Default", - config: config{}, - wantOption: []metric.ManualReaderOption{}, + name: "Default", + config: config{}, + wantOptionCount: 0, }, { - name: "WithAggregationSelector", - config: config{aggregation: aggregationSelector}, - wantOption: []metric.ManualReaderOption{ - metric.WithAggregationSelector(aggregationSelector), - }, + name: "WithAggregationSelector", + config: config{aggregation: aggregationSelector}, + wantOptionCount: 1, }, } for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { opts := tt.config.manualReaderOptions() - assert.Len(t, opts, len(tt.wantOption)) + assert.Len(t, opts, tt.wantOptionCount) }) } } diff --git a/exporters/prometheus/config.go b/exporters/prometheus/config.go index ff959434c8d..e70dade501d 100644 --- a/exporters/prometheus/config.go +++ b/exporters/prometheus/config.go @@ -16,6 +16,7 @@ package prometheus // import "go.opentelemetry.io/otel/exporters/prometheus" import ( "github.com/prometheus/client_golang/prometheus" + "go.opentelemetry.io/otel/sdk/metric" ) @@ -68,6 +69,9 @@ func WithRegisterer(reg prometheus.Registerer) Option { }) } +// WithAggregationSelector configure the Aggregation Selector the exporter will +// use. If no AggregationSelector is provided the DefaultAggregationSelector is +// used. func WithAggregationSelector(agg metric.AggregationSelector) Option { return optionFunc(func(cfg config) config { cfg.aggregation = agg