Skip to content

Commit

Permalink
Remove validation of agg in manual_reader selector opt
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Aug 11, 2023
1 parent ccc016b commit 8b9a108
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions sdk/metric/manual_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,7 @@ func (t temporalitySelectorOption) applyManual(mrc manualReaderConfig) manualRea
// this option is not used, the reader will use the DefaultAggregationSelector
// or the aggregation explicitly passed for a view matching an instrument.
func WithAggregationSelector(selector AggregationSelector) ManualReaderOption {
// Deep copy and validate before using.
wrapped := func(ik InstrumentKind) Aggregation {
a := selector(ik)
if a == nil {
return nil
}
cpA := a.copy()
if err := cpA.err(); err != nil {
cpA = DefaultAggregationSelector(ik)
global.Error(
err, "using default aggregation instead",
"aggregation", a,
"replacement", cpA,
)
}
return cpA
}

return aggregationSelectorOption{selector: wrapped}
return aggregationSelectorOption{selector: selector}
}

type aggregationSelectorOption struct {
Expand Down

0 comments on commit 8b9a108

Please sign in to comment.