1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-05 15:05:51 +02:00

Comments in the metrics SDK (#399)

* Comments from walkthrough

* Update
This commit is contained in:
Joshua MacDonald 2019-12-23 16:38:35 -08:00 committed by rghetia
parent 225b466428
commit 11f67cea8e
3 changed files with 12 additions and 1 deletions

View File

@ -115,6 +115,8 @@ func (b *Batcher) Process(_ context.Context, record export.Record) error {
}
rag, ok := b.aggCheckpoint[key]
if ok {
// Combine the input aggregator with the current
// checkpoint state.
return rag.Aggregator().Merge(agg, desc)
}
// If this Batcher is stateful, create a copy of the
@ -123,6 +125,8 @@ func (b *Batcher) Process(_ context.Context, record export.Record) error {
// again, overwriting the long-lived state.
if b.stateful {
tmp := agg
// Note: the call to AggregatorFor() followed by Merge
// is effectively a Clone() operation.
agg = b.AggregatorFor(desc)
if err := agg.Merge(tmp, desc); err != nil {
return err

View File

@ -64,6 +64,11 @@ func (b *Batcher) Process(_ context.Context, record export.Record) error {
agg := record.Aggregator()
value, ok := b.batchMap[key]
if ok {
// Note: The call to Merge here combines only
// identical records. It is required even for a
// stateless Batcher because such identical records
// may arise in the Meter implementation due to race
// conditions.
return value.aggregator.Merge(agg, desc)
}
// If this Batcher is stateful, create a copy of the
@ -72,6 +77,8 @@ func (b *Batcher) Process(_ context.Context, record export.Record) error {
// again, overwriting the long-lived state.
if b.stateful {
tmp := agg
// Note: the call to AggregatorFor() followed by Merge
// is effectively a Clone() operation.
agg = b.AggregatorFor(desc)
if err := agg.Merge(tmp, desc); err != nil {
return err

View File

@ -108,7 +108,7 @@ func (c *Controller) SetErrorHandler(errorHandler sdk.ErrorHandler) {
// Meter returns a named Meter, satisifying the metric.Provider
// interface.
func (c *Controller) Meter(name string) metric.Meter {
func (c *Controller) Meter(_ string) metric.Meter {
return c.sdk
}