diff --git a/api/metric/async.go b/api/metric/async.go index d721dffef..831e1af02 100644 --- a/api/metric/async.go +++ b/api/metric/async.go @@ -40,18 +40,18 @@ type Observation struct { instrument AsyncImpl } -// Int64ObserverCallback is a type of callback that integral +// Int64ObserverFunc is a type of callback that integral // observers run. -type Int64ObserverCallback func(context.Context, Int64ObserverResult) +type Int64ObserverFunc func(context.Context, Int64ObserverResult) -// Float64ObserverCallback is a type of callback that floating point +// Float64ObserverFunc is a type of callback that floating point // observers run. -type Float64ObserverCallback func(context.Context, Float64ObserverResult) +type Float64ObserverFunc func(context.Context, Float64ObserverResult) -// BatchObserverCallback is a callback argument for use with any +// BatchObserverFunc is a callback argument for use with any // Observer instrument that will be reported as a batch of // observations. -type BatchObserverCallback func(context.Context, BatchObserverResult) +type BatchObserverFunc func(context.Context, BatchObserverResult) // Int64ObserverResult is passed to an observer callback to capture // observations for one asynchronous integer metric instrument. @@ -60,7 +60,7 @@ type Int64ObserverResult struct { function func([]kv.KeyValue, ...Observation) } -// Float64ObserverResult is passed to an observer callback to capture +// Float64ObserverResult is passed to an observer callback to captureGetHookFunc // observations for one asynchronous floating point metric instrument. type Float64ObserverResult struct { instrument AsyncImpl @@ -129,36 +129,36 @@ type AsyncBatchRunner interface { AsyncRunner } -var _ AsyncSingleRunner = (*Int64ObserverCallback)(nil) -var _ AsyncSingleRunner = (*Float64ObserverCallback)(nil) -var _ AsyncBatchRunner = (*BatchObserverCallback)(nil) +var _ AsyncSingleRunner = (*Int64ObserverFunc)(nil) +var _ AsyncSingleRunner = (*Float64ObserverFunc)(nil) +var _ AsyncBatchRunner = (*BatchObserverFunc)(nil) // newInt64AsyncRunner returns a single-observer callback for integer Observer instruments. -func newInt64AsyncRunner(c Int64ObserverCallback) AsyncSingleRunner { +func newInt64AsyncRunner(c Int64ObserverFunc) AsyncSingleRunner { return &c } // newFloat64AsyncRunner returns a single-observer callback for floating point Observer instruments. -func newFloat64AsyncRunner(c Float64ObserverCallback) AsyncSingleRunner { +func newFloat64AsyncRunner(c Float64ObserverFunc) AsyncSingleRunner { return &c } // newBatchAsyncRunner returns a batch-observer callback use with multiple Observer instruments. -func newBatchAsyncRunner(c BatchObserverCallback) AsyncBatchRunner { +func newBatchAsyncRunner(c BatchObserverFunc) AsyncBatchRunner { return &c } // AnyRunner implements AsyncRunner. -func (*Int64ObserverCallback) AnyRunner() {} +func (*Int64ObserverFunc) AnyRunner() {} // AnyRunner implements AsyncRunner. -func (*Float64ObserverCallback) AnyRunner() {} +func (*Float64ObserverFunc) AnyRunner() {} // AnyRunner implements AsyncRunner. -func (*BatchObserverCallback) AnyRunner() {} +func (*BatchObserverFunc) AnyRunner() {} // Run implements AsyncSingleRunner. -func (i *Int64ObserverCallback) Run(ctx context.Context, impl AsyncImpl, function func([]kv.KeyValue, ...Observation)) { +func (i *Int64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]kv.KeyValue, ...Observation)) { (*i)(ctx, Int64ObserverResult{ instrument: impl, function: function, @@ -166,7 +166,7 @@ func (i *Int64ObserverCallback) Run(ctx context.Context, impl AsyncImpl, functio } // Run implements AsyncSingleRunner. -func (f *Float64ObserverCallback) Run(ctx context.Context, impl AsyncImpl, function func([]kv.KeyValue, ...Observation)) { +func (f *Float64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]kv.KeyValue, ...Observation)) { (*f)(ctx, Float64ObserverResult{ instrument: impl, function: function, @@ -174,7 +174,7 @@ func (f *Float64ObserverCallback) Run(ctx context.Context, impl AsyncImpl, funct } // Run implements AsyncBatchRunner. -func (b *BatchObserverCallback) Run(ctx context.Context, function func([]kv.KeyValue, ...Observation)) { +func (b *BatchObserverFunc) Run(ctx context.Context, function func([]kv.KeyValue, ...Observation)) { (*b)(ctx, BatchObserverResult{ function: function, }) diff --git a/api/metric/meter.go b/api/metric/meter.go index eacfb68a4..cec2c7215 100644 --- a/api/metric/meter.go +++ b/api/metric/meter.go @@ -61,7 +61,7 @@ func (m Meter) RecordBatch(ctx context.Context, ls []kv.KeyValue, ms ...Measurem // NewBatchObserver creates a new BatchObserver that supports // making batches of observations for multiple instruments. -func (m Meter) NewBatchObserver(callback BatchObserverCallback) BatchObserver { +func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver { return BatchObserver{ meter: m, runner: newBatchAsyncRunner(callback), @@ -126,7 +126,7 @@ func (m Meter) NewFloat64ValueRecorder(name string, opts ...InstrumentOption) (F // with the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverCallback, opts ...InstrumentOption) (Int64ValueObserver, error) { +func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64ValueObserver, error) { if callback == nil { return wrapInt64ValueObserverInstrument(NoopAsync{}, nil) } @@ -139,7 +139,7 @@ func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverCallback // the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverCallback, opts ...InstrumentOption) (Float64ValueObserver, error) { +func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64ValueObserver, error) { if callback == nil { return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil) } @@ -152,7 +152,7 @@ func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverCall // with the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverCallback, opts ...InstrumentOption) (Int64SumObserver, error) { +func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64SumObserver, error) { if callback == nil { return wrapInt64SumObserverInstrument(NoopAsync{}, nil) } @@ -165,7 +165,7 @@ func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverCallback, // the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverCallback, opts ...InstrumentOption) (Float64SumObserver, error) { +func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64SumObserver, error) { if callback == nil { return wrapFloat64SumObserverInstrument(NoopAsync{}, nil) } @@ -178,7 +178,7 @@ func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverCallba // with the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverCallback, opts ...InstrumentOption) (Int64UpDownSumObserver, error) { +func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownSumObserver, error) { if callback == nil { return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil) } @@ -191,7 +191,7 @@ func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverCall // the given name, running a given callback, and customized with // options. May return an error if the name is invalid (e.g., empty) // or improperly registered (e.g., duplicate registration). -func (m Meter) NewFloat64UpDownSumObserver(name string, callback Float64ObserverCallback, opts ...InstrumentOption) (Float64UpDownSumObserver, error) { +func (m Meter) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownSumObserver, error) { if callback == nil { return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil) } diff --git a/api/metric/must.go b/api/metric/must.go index 13c40a87b..c88e050a3 100644 --- a/api/metric/must.go +++ b/api/metric/must.go @@ -95,7 +95,7 @@ func (mm MeterMust) NewFloat64ValueRecorder(name string, mos ...InstrumentOption // NewInt64ValueObserver calls `Meter.NewInt64ValueObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewInt64ValueObserver(name string, callback Int64ObserverCallback, oos ...InstrumentOption) Int64ValueObserver { +func (mm MeterMust) NewInt64ValueObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64ValueObserver { if inst, err := mm.meter.NewInt64ValueObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -105,7 +105,7 @@ func (mm MeterMust) NewInt64ValueObserver(name string, callback Int64ObserverCal // NewFloat64ValueObserver calls `Meter.NewFloat64ValueObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewFloat64ValueObserver(name string, callback Float64ObserverCallback, oos ...InstrumentOption) Float64ValueObserver { +func (mm MeterMust) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64ValueObserver { if inst, err := mm.meter.NewFloat64ValueObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -115,7 +115,7 @@ func (mm MeterMust) NewFloat64ValueObserver(name string, callback Float64Observe // NewInt64SumObserver calls `Meter.NewInt64SumObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewInt64SumObserver(name string, callback Int64ObserverCallback, oos ...InstrumentOption) Int64SumObserver { +func (mm MeterMust) NewInt64SumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64SumObserver { if inst, err := mm.meter.NewInt64SumObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -125,7 +125,7 @@ func (mm MeterMust) NewInt64SumObserver(name string, callback Int64ObserverCallb // NewFloat64SumObserver calls `Meter.NewFloat64SumObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewFloat64SumObserver(name string, callback Float64ObserverCallback, oos ...InstrumentOption) Float64SumObserver { +func (mm MeterMust) NewFloat64SumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64SumObserver { if inst, err := mm.meter.NewFloat64SumObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -135,7 +135,7 @@ func (mm MeterMust) NewFloat64SumObserver(name string, callback Float64ObserverC // NewInt64UpDownSumObserver calls `Meter.NewInt64UpDownSumObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewInt64UpDownSumObserver(name string, callback Int64ObserverCallback, oos ...InstrumentOption) Int64UpDownSumObserver { +func (mm MeterMust) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownSumObserver { if inst, err := mm.meter.NewInt64UpDownSumObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -145,7 +145,7 @@ func (mm MeterMust) NewInt64UpDownSumObserver(name string, callback Int64Observe // NewFloat64UpDownSumObserver calls `Meter.NewFloat64UpDownSumObserver` and // returns the instrument, panicking if it encounters an error. -func (mm MeterMust) NewFloat64UpDownSumObserver(name string, callback Float64ObserverCallback, oos ...InstrumentOption) Float64UpDownSumObserver { +func (mm MeterMust) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownSumObserver { if inst, err := mm.meter.NewFloat64UpDownSumObserver(name, callback, oos...); err != nil { panic(err) } else { @@ -155,7 +155,7 @@ func (mm MeterMust) NewFloat64UpDownSumObserver(name string, callback Float64Obs // NewBatchObserver returns a wrapper around BatchObserver that panics // when any instrument constructor returns an error. -func (mm MeterMust) NewBatchObserver(callback BatchObserverCallback) BatchObserverMust { +func (mm MeterMust) NewBatchObserver(callback BatchObserverFunc) BatchObserverMust { return BatchObserverMust{ batch: mm.meter.NewBatchObserver(callback), } diff --git a/api/metric/observer.go b/api/metric/observer.go index 1616908cc..c347da78f 100644 --- a/api/metric/observer.go +++ b/api/metric/observer.go @@ -57,7 +57,7 @@ type Float64UpDownSumObserver struct { asyncInstrument } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. @@ -68,7 +68,7 @@ func (i Int64ValueObserver) Observation(v int64) Observation { } } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. @@ -79,7 +79,7 @@ func (f Float64ValueObserver) Observation(v float64) Observation { } } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. @@ -90,7 +90,7 @@ func (i Int64SumObserver) Observation(v int64) Observation { } } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. @@ -101,7 +101,7 @@ func (f Float64SumObserver) Observation(v float64) Observation { } } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. @@ -112,7 +112,7 @@ func (i Int64UpDownSumObserver) Observation(v int64) Observation { } } -// Observation returns an Observation, a BatchObserverCallback +// Observation returns an Observation, a BatchObserverFunc // argument, for an asynchronous integer instrument. // This returns an implementation-level object for use by the SDK, // users should not refer to this. diff --git a/exporters/otlp/otlp_integration_test.go b/exporters/otlp/otlp_integration_test.go index cf767d48e..8731b0605 100644 --- a/exporters/otlp/otlp_integration_test.go +++ b/exporters/otlp/otlp_integration_test.go @@ -162,13 +162,13 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption) case metric.ValueObserverKind: switch data.nKind { case metricapi.Int64NumberKind: - callback := func(v int64) metricapi.Int64ObserverCallback { - return metricapi.Int64ObserverCallback(func(_ context.Context, result metricapi.Int64ObserverResult) { result.Observe(v, labels...) }) + callback := func(v int64) metricapi.Int64ObserverFunc { + return metricapi.Int64ObserverFunc(func(_ context.Context, result metricapi.Int64ObserverResult) { result.Observe(v, labels...) }) }(data.val) metricapi.Must(meter).NewInt64ValueObserver(name, callback) case metricapi.Float64NumberKind: - callback := func(v float64) metricapi.Float64ObserverCallback { - return metricapi.Float64ObserverCallback(func(_ context.Context, result metricapi.Float64ObserverResult) { result.Observe(v, labels...) }) + callback := func(v float64) metricapi.Float64ObserverFunc { + return metricapi.Float64ObserverFunc(func(_ context.Context, result metricapi.Float64ObserverResult) { result.Observe(v, labels...) }) }(float64(data.val)) metricapi.Must(meter).NewFloat64ValueObserver(name, callback) default: