Skip to content

Commit

Permalink
Use AggregationSelector instead of inline func type
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Jun 17, 2022
1 parent ba5f080 commit 636ccb8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sdk/metric/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
type reader struct {
producer producer
temporalityFunc func(InstrumentKind) Temporality
aggregationFunc func(InstrumentKind) aggregation.Aggregation
aggregationFunc AggregationSelector
collectFunc func(context.Context) (export.Metrics, error)
forceFlushFunc func(context.Context) error
shutdownFunc func(context.Context) error
Expand Down
5 changes: 3 additions & 2 deletions sdk/metric/manual_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type manualReader struct {
shutdownOnce sync.Once

temporalitySelector func(InstrumentKind) Temporality
aggregationSelector func(InstrumentKind) aggregation.Aggregation
aggregationSelector AggregationSelector
}

// Compile time check the manualReader implements Reader.
Expand All @@ -46,6 +46,7 @@ func NewManualReader(opts ...ManualReaderOption) Reader {
cfg := newManualReaderConfig(opts)
return &manualReader{
temporalitySelector: cfg.temporalitySelector,
aggregationSelector: cfg.aggregationSelector,
}
}

Expand Down Expand Up @@ -110,7 +111,7 @@ func (mr *manualReader) Collect(ctx context.Context) (export.Metrics, error) {
// manualReaderConfig contains configuration options for a ManualReader.
type manualReaderConfig struct {
temporalitySelector func(InstrumentKind) Temporality
aggregationSelector func(InstrumentKind) aggregation.Aggregation
aggregationSelector AggregationSelector
}

// newManualReaderConfig returns a manualReaderConfig configured with options.
Expand Down
5 changes: 3 additions & 2 deletions sdk/metric/periodic_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type periodicReaderConfig struct {
interval time.Duration
timeout time.Duration
temporalitySelector func(InstrumentKind) Temporality
aggregationSelector func(InstrumentKind) aggregation.Aggregation
aggregationSelector AggregationSelector
}

// newPeriodicReaderConfig returns a periodicReaderConfig configured with
Expand Down Expand Up @@ -120,6 +120,7 @@ func NewPeriodicReader(exporter Exporter, options ...PeriodicReaderOption) Reade
cancel: cancel,

temporalitySelector: conf.temporalitySelector,
aggregationSelector: conf.aggregationSelector,
}

r.wg.Add(1)
Expand All @@ -140,7 +141,7 @@ type periodicReader struct {
exporter Exporter

temporalitySelector func(InstrumentKind) Temporality
aggregationSelector func(InstrumentKind) aggregation.Aggregation
aggregationSelector AggregationSelector

wg sync.WaitGroup
cancel context.CancelFunc
Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func WithAggregationSelector(selector AggregationSelector) ReaderOption {
}

type aggregationSelectorOption struct {
selector func(InstrumentKind) aggregation.Aggregation
selector AggregationSelector
}

// applyManual returns a manualReaderConfig with option applied.
Expand Down

0 comments on commit 636ccb8

Please sign in to comment.