You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Comments in the metrics SDK (#399)
* Comments from walkthrough * Update
This commit is contained in:
		
				
					committed by
					
						 rghetia
						rghetia
					
				
			
			
				
	
			
			
			
						parent
						
							225b466428
						
					
				
				
					commit
					11f67cea8e
				
			| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user