Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MadVikingGod committed Oct 18, 2022
1 parent 256fe58 commit a5577e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 11 additions & 12 deletions exporters/prometheus/confg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
})
}
}
4 changes: 4 additions & 0 deletions exporters/prometheus/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a5577e0

Please sign in to comment.