Skip to content

Commit

Permalink
update selector
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Feb 21, 2020
1 parent 75f3c3e commit 7fec05b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions sdk/metric/selector/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (selectorInexpensive) AggregatorFor(descriptor *export.Descriptor) export.A
switch descriptor.MetricKind() {
case export.GaugeKind:
return gauge.New()
case export.ObserverKind:
fallthrough
case export.MeasureKind:
return minmaxsumcount.New(descriptor)
default:
Expand All @@ -81,6 +83,8 @@ func (s selectorSketch) AggregatorFor(descriptor *export.Descriptor) export.Aggr
switch descriptor.MetricKind() {
case export.GaugeKind:
return gauge.New()
case export.ObserverKind:
fallthrough
case export.MeasureKind:
return ddsketch.New(s.config, descriptor)
default:
Expand All @@ -92,6 +96,8 @@ func (selectorExact) AggregatorFor(descriptor *export.Descriptor) export.Aggrega
switch descriptor.MetricKind() {
case export.GaugeKind:
return gauge.New()
case export.ObserverKind:
fallthrough
case export.MeasureKind:
return array.New()
default:
Expand Down
9 changes: 3 additions & 6 deletions sdk/metric/selector/simple/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (
"go.opentelemetry.io/otel/sdk/metric/aggregator/ddsketch"
"go.opentelemetry.io/otel/sdk/metric/aggregator/gauge"
"go.opentelemetry.io/otel/sdk/metric/aggregator/minmaxsumcount"
"go.opentelemetry.io/otel/sdk/metric/aggregator/observerarray"
"go.opentelemetry.io/otel/sdk/metric/aggregator/observerddsketch"
"go.opentelemetry.io/otel/sdk/metric/aggregator/observermmsc"
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
)

Expand All @@ -44,21 +41,21 @@ func TestInexpensiveMeasure(t *testing.T) {
require.NotPanics(t, func() { _ = inex.AggregatorFor(testGaugeDesc).(*gauge.Aggregator) })
require.NotPanics(t, func() { _ = inex.AggregatorFor(testCounterDesc).(*counter.Aggregator) })
require.NotPanics(t, func() { _ = inex.AggregatorFor(testMeasureDesc).(*minmaxsumcount.Aggregator) })
require.NotPanics(t, func() { _ = inex.AggregatorFor(testObserverDesc).(*observermmsc.Aggregator) })
require.NotPanics(t, func() { _ = inex.AggregatorFor(testObserverDesc).(*minmaxsumcount.Aggregator) })
}

func TestSketchMeasure(t *testing.T) {
sk := simple.NewWithSketchMeasure(ddsketch.NewDefaultConfig())
require.NotPanics(t, func() { _ = sk.AggregatorFor(testGaugeDesc).(*gauge.Aggregator) })
require.NotPanics(t, func() { _ = sk.AggregatorFor(testCounterDesc).(*counter.Aggregator) })
require.NotPanics(t, func() { _ = sk.AggregatorFor(testMeasureDesc).(*ddsketch.Aggregator) })
require.NotPanics(t, func() { _ = sk.AggregatorFor(testObserverDesc).(*observerddsketch.Aggregator) })
require.NotPanics(t, func() { _ = sk.AggregatorFor(testObserverDesc).(*ddsketch.Aggregator) })
}

func TestExactMeasure(t *testing.T) {
ex := simple.NewWithExactMeasure()
require.NotPanics(t, func() { _ = ex.AggregatorFor(testGaugeDesc).(*gauge.Aggregator) })
require.NotPanics(t, func() { _ = ex.AggregatorFor(testCounterDesc).(*counter.Aggregator) })
require.NotPanics(t, func() { _ = ex.AggregatorFor(testMeasureDesc).(*array.Aggregator) })
require.NotPanics(t, func() { _ = ex.AggregatorFor(testObserverDesc).(*observerarray.Aggregator) })
require.NotPanics(t, func() { _ = ex.AggregatorFor(testObserverDesc).(*array.Aggregator) })
}

0 comments on commit 7fec05b

Please sign in to comment.