Skip to content

Commit

Permalink
Do not return agg if adding err-ed
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 29, 2022
1 parent b42f829 commit b56efb0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sdk/metric/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,17 @@ func (i *inserter[N]) Instrument(inst view.Instrument, instUnit unit.Unit) ([]in
if agg == nil { // Drop aggregator.
continue
}
// TODO (#3011): If filtering is done at the instrument level add here.
// This is where the aggregator and the view are both in scope.
aggs = append(aggs, agg)
seen[id] = struct{}{}
err = i.pipeline.addAggregator(inst.Scope, inst.Name, inst.Description, instUnit, agg)
if err != nil {
errs.append(err)
// Do not return the aggregator to be updated if the pipeline will
// never produce from it.
continue
}
// TODO (#3011): If filtering is done at the instrument level add here.
// This is where the aggregator and the view are both in scope.
aggs = append(aggs, agg)
seen[id] = struct{}{}
}

if !matched { // Apply implicit default view if no explicit matched.
Expand All @@ -232,10 +235,13 @@ func (i *inserter[N]) Instrument(inst view.Instrument, instUnit unit.Unit) ([]in
errs.append(err)
}
if a != nil {
aggs = append(aggs, a)
err = i.pipeline.addAggregator(inst.Scope, inst.Name, inst.Description, instUnit, a)
if err != nil {
// Do not return the aggregator to be updated if the pipeline
// will never produce from it.
errs.append(err)
} else {
aggs = append(aggs, a)
}
}
}
Expand Down

0 comments on commit b56efb0

Please sign in to comment.