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 
			
		
		
		
	Rename handle to bound instrument (@sircelsius) (#400)
* Rename metric Handle to Bound Instrument * Rename metric Handle to Bound Instrument * Rename metric Handle to Bound Instrument * chore(meter): renamed from *BoundInstrument to Bound*, renamed AcquireBoundInstrument to Bind * chore(meter): renamed Release to Unbind * Self feedback in doc.go * Rename confusing method name Co-authored-by: Marc Bramaud <sircelsius@users.noreply.github.com>
This commit is contained in:
		| @@ -149,7 +149,7 @@ func BenchmarkAcquireNewHandle(b *testing.B) { | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		cnt.AcquireHandle(labels[i]) | ||||
| 		cnt.Bind(labels[i]) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -161,13 +161,13 @@ func BenchmarkAcquireExistingHandle(b *testing.B) { | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		labels[i] = fix.sdk.Labels(labelSets[i]...) | ||||
| 		cnt.AcquireHandle(labels[i]).Release() | ||||
| 		cnt.Bind(labels[i]).Unbind() | ||||
| 	} | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		cnt.AcquireHandle(labels[i]) | ||||
| 		cnt.Bind(labels[i]) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -179,13 +179,13 @@ func BenchmarkAcquireReleaseExistingHandle(b *testing.B) { | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		labels[i] = fix.sdk.Labels(labelSets[i]...) | ||||
| 		cnt.AcquireHandle(labels[i]).Release() | ||||
| 		cnt.Bind(labels[i]).Unbind() | ||||
| 	} | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		cnt.AcquireHandle(labels[i]).Release() | ||||
| 		cnt.Bind(labels[i]).Unbind() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -209,7 +209,7 @@ func BenchmarkInt64CounterHandleAdd(b *testing.B) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	cnt := fix.sdk.NewInt64Counter("int64.counter") | ||||
| 	handle := cnt.AcquireHandle(labs) | ||||
| 	handle := cnt.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| @@ -236,7 +236,7 @@ func BenchmarkFloat64CounterHandleAdd(b *testing.B) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	cnt := fix.sdk.NewFloat64Counter("float64.counter") | ||||
| 	handle := cnt.AcquireHandle(labs) | ||||
| 	handle := cnt.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| @@ -265,7 +265,7 @@ func BenchmarkInt64GaugeHandleAdd(b *testing.B) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	gau := fix.sdk.NewInt64Gauge("int64.gauge") | ||||
| 	handle := gau.AcquireHandle(labs) | ||||
| 	handle := gau.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| @@ -292,7 +292,7 @@ func BenchmarkFloat64GaugeHandleAdd(b *testing.B) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	gau := fix.sdk.NewFloat64Gauge("float64.gauge") | ||||
| 	handle := gau.AcquireHandle(labs) | ||||
| 	handle := gau.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| @@ -321,7 +321,7 @@ func benchmarkInt64MeasureHandleAdd(b *testing.B, name string) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	mea := fix.sdk.NewInt64Measure(name) | ||||
| 	handle := mea.AcquireHandle(labs) | ||||
| 	handle := mea.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
| @@ -348,7 +348,7 @@ func benchmarkFloat64MeasureHandleAdd(b *testing.B, name string) { | ||||
| 	fix := newFixture(b) | ||||
| 	labs := fix.sdk.Labels(makeLabels(1)...) | ||||
| 	mea := fix.sdk.NewFloat64Measure(name) | ||||
| 	handle := mea.AcquireHandle(labs) | ||||
| 	handle := mea.Bind(labs) | ||||
|  | ||||
| 	b.ResetTimer() | ||||
|  | ||||
|   | ||||
| @@ -76,7 +76,7 @@ func TestMonotoneGauge(t *testing.T) { | ||||
|  | ||||
| 	gauge := sdk.NewInt64Gauge("my.gauge.name", metric.WithMonotonic(true)) | ||||
|  | ||||
| 	handle := gauge.AcquireHandle(sdk.Labels(key.String("a", "b"))) | ||||
| 	handle := gauge.Bind(sdk.Labels(key.String("a", "b"))) | ||||
|  | ||||
| 	require.Nil(t, batcher.currentTime) | ||||
| 	require.Nil(t, batcher.currentValue) | ||||
|   | ||||
| @@ -148,10 +148,10 @@ type ( | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	_ api.Meter          = &SDK{} | ||||
| 	_ api.LabelSet       = &labels{} | ||||
| 	_ api.InstrumentImpl = &instrument{} | ||||
| 	_ api.HandleImpl     = &record{} | ||||
| 	_ api.Meter               = &SDK{} | ||||
| 	_ api.LabelSet            = &labels{} | ||||
| 	_ api.InstrumentImpl      = &instrument{} | ||||
| 	_ api.BoundInstrumentImpl = &record{} | ||||
|  | ||||
| 	// hazardRecord is used as a pointer value that indicates the | ||||
| 	// value is not included in any list.  (`nil` would be | ||||
| @@ -205,7 +205,7 @@ func (i *instrument) acquireHandle(ls *labels) *record { | ||||
| 	return rec | ||||
| } | ||||
|  | ||||
| func (i *instrument) AcquireHandle(ls api.LabelSet) api.HandleImpl { | ||||
| func (i *instrument) Bind(ls api.LabelSet) api.BoundInstrumentImpl { | ||||
| 	labs := i.meter.labsFor(ls) | ||||
| 	return i.acquireHandle(labs) | ||||
| } | ||||
| @@ -213,7 +213,7 @@ func (i *instrument) AcquireHandle(ls api.LabelSet) api.HandleImpl { | ||||
| func (i *instrument) RecordOne(ctx context.Context, number core.Number, ls api.LabelSet) { | ||||
| 	ourLs := i.meter.labsFor(ls) | ||||
| 	h := i.acquireHandle(ourLs) | ||||
| 	defer h.Release() | ||||
| 	defer h.Unbind() | ||||
| 	h.RecordOne(ctx, number) | ||||
| } | ||||
|  | ||||
| @@ -465,7 +465,7 @@ func (r *record) RecordOne(ctx context.Context, number core.Number) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *record) Release() { | ||||
| func (r *record) Unbind() { | ||||
| 	for { | ||||
| 		collected := atomic.LoadInt64(&r.collectedEpoch) | ||||
| 		modified := atomic.LoadInt64(&r.modifiedEpoch) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user