diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e07f8e8de1..33d3cf58bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm The package contains semantic conventions from the `v1.15.0` version of the OpenTelemetry specification. (#3578) - Add the `go.opentelemetry.io/otel/semconv/v1.16.0` package. The package contains semantic conventions from the `v1.16.0` version of the OpenTelemetry specification. (#3579) +- Metric instruments were added to `go.opentelemetry.io/otel/metric/instrument`. + These instruments are use as replacements of the depreacted `go.opentelemetry.io/otel/metric/instrument/{asyncfloat64,asyncint64,syncfloat64,syncint64}` packages.(#3575) + - `Float64ObservableCounter` replaces the `asyncfloat64.Counter` + - `Float64ObservableUpDownCounter` replaces the `asyncfloat64.UpDownCounter` + - `Float64ObservableGauge` replaces the `asyncfloat64.Gauge` + - `Int64ObservableCounter` replaces the `asyncint64.Counter` + - `Int64ObservableUpDownCounter` replaces the `asyncint64.UpDownCounter` + - `Int64ObservableGauge` replaces the `asyncint64.Gauge` + - `Float64Counter` replaces the `syncfloat64.Counter` + - `Float64UpDownCounter` replaces the `syncfloat64.UpDownCounter` + - `Float64Histogram` replaces the `syncfloat64.Histogram` + - `Int64Counter` replaces the `syncint64.Counter` + - `Int64UpDownCounter` replaces the `syncint64.UpDownCounter` + - `Int64Histogram` replaces the `syncint64.Histogram` ### Changed @@ -89,6 +103,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Deprecated - The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` is deprecated. Use `NewMetricProducer` instead. (#3541) +- The `go.opentelemetry.io/otel/metric/instrument/asyncfloat64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/asyncint64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/syncfloat64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/syncint64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) ### Removed diff --git a/metric/example_test.go b/metric/example_test.go index c6beeca7fc3..ac72d3e8cba 100644 --- a/metric/example_test.go +++ b/metric/example_test.go @@ -22,7 +22,6 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" "go.opentelemetry.io/otel/metric/unit" ) @@ -112,4 +111,4 @@ func ExampleMeter_asynchronous_multiple() { } // This is just an example, see the the contrib runtime instrumentation for real implementation. -func computeGCPauses(ctx context.Context, recorder syncfloat64.Histogram, pauseBuff []uint64) {} +func computeGCPauses(ctx context.Context, recorder instrument.Float64Histogram, pauseBuff []uint64) {} diff --git a/metric/instrument/asyncfloat64.go b/metric/instrument/asyncfloat64.go index 9f77afb7d38..ad58dd0d9e7 100644 --- a/metric/instrument/asyncfloat64.go +++ b/metric/instrument/asyncfloat64.go @@ -34,6 +34,30 @@ type Float64Observer interface { Observe(ctx context.Context, value float64, attributes ...attribute.KeyValue) } +// Float64ObservableCounter is an instrument used to asynchronously record +// increasing float64 measurements once per a measurement collection cycle. The +// Observe method is used to record the measured state of the instrument when +// it is called. Implementations will assume the observed value to be the +// cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableCounter interface{ Float64Observer } + +// Float64ObservableUpDownCounter is an instrument used to asynchronously +// record float64 measurements once per a measurement collection cycle. The +// Observe method is used to record the measured state of the instrument when +// it is called. Implementations will assume the observed value to be the +// cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableUpDownCounter interface{ Float64Observer } + +// Float64ObservableGauge is an instrument used to asynchronously record +// instantaneous float64 measurements once per a measurement collection cycle. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableGauge interface{ Float64Observer } + // Float64Callback is a function registered with a Meter that makes // observations for a Float64Observer it is registered with. // diff --git a/metric/instrument/asyncfloat64/asyncfloat64.go b/metric/instrument/asyncfloat64/asyncfloat64.go index 1932d55d225..7fb43ca363e 100644 --- a/metric/instrument/asyncfloat64/asyncfloat64.go +++ b/metric/instrument/asyncfloat64/asyncfloat64.go @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package asyncfloat64 provides asynchronous instruments that accept float64 +// measurments. +// +// Deprecated: Use the instruments provided by +// go.opentelemetry.io/otel/metric/instrument instead. package asyncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" import "go.opentelemetry.io/otel/metric/instrument" @@ -23,6 +28,9 @@ import "go.opentelemetry.io/otel/metric/instrument" // the count. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64ObservableCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type Counter interface{ instrument.Float64Observer } // UpDownCounter is an instrument used to asynchronously record float64 @@ -32,10 +40,16 @@ type Counter interface{ instrument.Float64Observer } // the count. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64ObservableUpDownCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type UpDownCounter interface{ instrument.Float64Observer } // Gauge is an instrument used to asynchronously record instantaneous float64 // measurements once per a measurement collection cycle. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64ObservableGauge in +// go.opentelemetry.io/otel/metric/instrument instead. type Gauge interface{ instrument.Float64Observer } diff --git a/metric/instrument/asyncint64.go b/metric/instrument/asyncint64.go index 296da3e6f94..debba92f0aa 100644 --- a/metric/instrument/asyncint64.go +++ b/metric/instrument/asyncint64.go @@ -35,6 +35,30 @@ type Int64Observer interface { Observe(ctx context.Context, value int64, attributes ...attribute.KeyValue) } +// Int64ObservableCounter is an instrument used to asynchronously record +// increasing int64 measurements once per a measurement collection cycle. The +// Observe method is used to record the measured state of the instrument when +// it is called. Implementations will assume the observed value to be the +// cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableCounter interface{ Int64Observer } + +// Int64ObservableUpDownCounter is an instrument used to asynchronously record +// int64 measurements once per a measurement collection cycle. The Observe +// method is used to record the measured state of the instrument when it is +// called. Implementations will assume the observed value to be the cumulative +// sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableUpDownCounter interface{ Int64Observer } + +// Int64ObservableGauge is an instrument used to asynchronously record +// instantaneous int64 measurements once per a measurement collection cycle. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableGauge interface{ Int64Observer } + // Int64Callback is a function registered with a Meter that makes // observations for an Int64Observer it is registered with. // diff --git a/metric/instrument/asyncint64/asyncint64.go b/metric/instrument/asyncint64/asyncint64.go index 8cf970855c8..1e3be250da8 100644 --- a/metric/instrument/asyncint64/asyncint64.go +++ b/metric/instrument/asyncint64/asyncint64.go @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package asyncint64 provides asynchronous instruments that accept int64 +// measurments. +// +// Deprecated: Use the instruments provided by +// go.opentelemetry.io/otel/metric/instrument instead. package asyncint64 // import "go.opentelemetry.io/otel/metric/instrument/asyncint64" import "go.opentelemetry.io/otel/metric/instrument" @@ -23,6 +28,9 @@ import "go.opentelemetry.io/otel/metric/instrument" // the count. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64ObservableCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type Counter interface{ instrument.Int64Observer } // UpDownCounter is an instrument used to asynchronously record int64 @@ -32,10 +40,16 @@ type Counter interface{ instrument.Int64Observer } // the count. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64ObservableUpDownCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type UpDownCounter interface{ instrument.Int64Observer } // Gauge is an instrument used to asynchronously record instantaneous int64 // measurements once per a measurement collection cycle. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64ObservableGauge in +// go.opentelemetry.io/otel/metric/instrument instead. type Gauge interface{ instrument.Int64Observer } diff --git a/metric/instrument/syncfloat64.go b/metric/instrument/syncfloat64.go index b3df2b02f20..d8f6ba9f438 100644 --- a/metric/instrument/syncfloat64.go +++ b/metric/instrument/syncfloat64.go @@ -15,9 +15,44 @@ package instrument // import "go.opentelemetry.io/otel/metric/instrument" import ( + "context" + + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/unit" ) +// Float64Counter is an instrument that records increasing float64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Counter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Float64UpDownCounter is an instrument that records increasing or decreasing +// float64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64UpDownCounter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Float64Histogram is an instrument that records a distribution of float64 +// values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Histogram interface { + // Record adds an additional value to the distribution. + Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + // Float64Config contains options for Asynchronous instruments that // observe float64 values. type Float64Config struct { diff --git a/metric/instrument/syncfloat64/syncfloat64.go b/metric/instrument/syncfloat64/syncfloat64.go index dff6b77b4f9..bd835ec842d 100644 --- a/metric/instrument/syncfloat64/syncfloat64.go +++ b/metric/instrument/syncfloat64/syncfloat64.go @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package syncfloat64 provides synchronous instruments that accept float64 +// measurments. +// +// Deprecated: Use the instruments provided by +// go.opentelemetry.io/otel/metric/instrument instead. package syncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/syncfloat64" import ( @@ -24,6 +29,9 @@ import ( // Counter is an instrument that records increasing values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64Counter in +// go.opentelemetry.io/otel/metric/instrument instead. type Counter interface { // Add records a change to the counter. Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) @@ -34,6 +42,9 @@ type Counter interface { // UpDownCounter is an instrument that records increasing or decreasing values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64UpDownCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type UpDownCounter interface { // Add records a change to the counter. Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) @@ -44,6 +55,9 @@ type UpDownCounter interface { // Histogram is an instrument that records a distribution of values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Float64Histogram in +// go.opentelemetry.io/otel/metric/instrument instead. type Histogram interface { // Record adds an additional value to the distribution. Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue) diff --git a/metric/instrument/syncint64.go b/metric/instrument/syncint64.go index d49aed6c85d..96bf730e4b3 100644 --- a/metric/instrument/syncint64.go +++ b/metric/instrument/syncint64.go @@ -15,9 +15,44 @@ package instrument // import "go.opentelemetry.io/otel/metric/instrument" import ( + "context" + + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/unit" ) +// Int64Counter is an instrument that records increasing int64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Int64Counter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Int64UpDownCounter is an instrument that records increasing or decreasing +// int64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Int64UpDownCounter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Int64Histogram is an instrument that records a distribution of int64 +// values. +// +// Warning: methods may be added to this interface in minor releases. +type Int64Histogram interface { + // Record adds an additional value to the distribution. + Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue) + + Synchronous +} + // Int64Config contains options for Synchronous instruments that record int64 // values. type Int64Config struct { diff --git a/metric/instrument/syncint64/syncint64.go b/metric/instrument/syncint64/syncint64.go index 2611c513cff..88408113f71 100644 --- a/metric/instrument/syncint64/syncint64.go +++ b/metric/instrument/syncint64/syncint64.go @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package syncint64 provides synchronous instruments that accept int64 +// measurments. +// +// Deprecated: Use the instruments provided by +// go.opentelemetry.io/otel/metric/instrument instead. package syncint64 // import "go.opentelemetry.io/otel/metric/instrument/syncint64" import ( @@ -24,6 +29,9 @@ import ( // Counter is an instrument that records increasing values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64Counter in +// go.opentelemetry.io/otel/metric/instrument instead. type Counter interface { // Add records a change to the counter. Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) @@ -34,6 +42,9 @@ type Counter interface { // UpDownCounter is an instrument that records increasing or decreasing values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64UpDownCounter in +// go.opentelemetry.io/otel/metric/instrument instead. type UpDownCounter interface { // Add records a change to the counter. Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) @@ -44,6 +55,9 @@ type UpDownCounter interface { // Histogram is an instrument that records a distribution of values. // // Warning: methods may be added to this interface in minor releases. +// +// Deprecated: Use the Int64Histogram in +// go.opentelemetry.io/otel/metric/instrument instead. type Histogram interface { // Record adds an additional value to the distribution. Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue) diff --git a/metric/internal/global/instruments.go b/metric/internal/global/instruments.go index 4b4e77ff988..c4b3d1ff5ab 100644 --- a/metric/internal/global/instruments.go +++ b/metric/internal/global/instruments.go @@ -22,17 +22,13 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) type afCounter struct { name string opts []instrument.Float64ObserverOption - delegate atomic.Value //asyncfloat64.Counter + delegate atomic.Value //instrument.Float64ObservableCounter instrument.Asynchronous } @@ -48,13 +44,13 @@ func (i *afCounter) setDelegate(m metric.Meter) { func (i *afCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.Counter).Observe(ctx, x, attrs...) + ctr.(instrument.Float64ObservableCounter).Observe(ctx, x, attrs...) } } func (i *afCounter) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.Counter) + return ctr.(instrument.Float64ObservableCounter) } return nil } @@ -63,7 +59,7 @@ type afUpDownCounter struct { name string opts []instrument.Float64ObserverOption - delegate atomic.Value //asyncfloat64.UpDownCounter + delegate atomic.Value //instrument.Float64ObservableUpDownCounter instrument.Asynchronous } @@ -79,13 +75,13 @@ func (i *afUpDownCounter) setDelegate(m metric.Meter) { func (i *afUpDownCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.UpDownCounter).Observe(ctx, x, attrs...) + ctr.(instrument.Float64ObservableUpDownCounter).Observe(ctx, x, attrs...) } } func (i *afUpDownCounter) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.UpDownCounter) + return ctr.(instrument.Float64ObservableUpDownCounter) } return nil } @@ -94,7 +90,7 @@ type afGauge struct { name string opts []instrument.Float64ObserverOption - delegate atomic.Value //asyncfloat64.Gauge + delegate atomic.Value //instrument.Float64ObservableGauge instrument.Asynchronous } @@ -110,13 +106,13 @@ func (i *afGauge) setDelegate(m metric.Meter) { func (i *afGauge) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.Gauge).Observe(ctx, x, attrs...) + ctr.(instrument.Float64ObservableGauge).Observe(ctx, x, attrs...) } } func (i *afGauge) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.Gauge) + return ctr.(instrument.Float64ObservableGauge) } return nil } @@ -125,7 +121,7 @@ type aiCounter struct { name string opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.Counter + delegate atomic.Value //instrument.Int64ObservableCounter instrument.Asynchronous } @@ -141,13 +137,13 @@ func (i *aiCounter) setDelegate(m metric.Meter) { func (i *aiCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.Counter).Observe(ctx, x, attrs...) + ctr.(instrument.Int64ObservableCounter).Observe(ctx, x, attrs...) } } func (i *aiCounter) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.Counter) + return ctr.(instrument.Int64ObservableCounter) } return nil } @@ -156,7 +152,7 @@ type aiUpDownCounter struct { name string opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.UpDownCounter + delegate atomic.Value //instrument.Int64ObservableUpDownCounter instrument.Asynchronous } @@ -172,13 +168,13 @@ func (i *aiUpDownCounter) setDelegate(m metric.Meter) { func (i *aiUpDownCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.UpDownCounter).Observe(ctx, x, attrs...) + ctr.(instrument.Int64ObservableUpDownCounter).Observe(ctx, x, attrs...) } } func (i *aiUpDownCounter) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.UpDownCounter) + return ctr.(instrument.Int64ObservableUpDownCounter) } return nil } @@ -187,7 +183,7 @@ type aiGauge struct { name string opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.Gauge + delegate atomic.Value //instrument.Int64ObservableGauge instrument.Asynchronous } @@ -203,13 +199,13 @@ func (i *aiGauge) setDelegate(m metric.Meter) { func (i *aiGauge) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.Gauge).Observe(ctx, x, attrs...) + ctr.(instrument.Int64ObservableGauge).Observe(ctx, x, attrs...) } } func (i *aiGauge) unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.Gauge) + return ctr.(instrument.Int64ObservableGauge) } return nil } @@ -219,7 +215,7 @@ type sfCounter struct { name string opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.Counter + delegate atomic.Value //instrument.Float64Counter instrument.Synchronous } @@ -235,7 +231,7 @@ func (i *sfCounter) setDelegate(m metric.Meter) { func (i *sfCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.Counter).Add(ctx, incr, attrs...) + ctr.(instrument.Float64Counter).Add(ctx, incr, attrs...) } } @@ -243,7 +239,7 @@ type sfUpDownCounter struct { name string opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.UpDownCounter + delegate atomic.Value //instrument.Float64UpDownCounter instrument.Synchronous } @@ -259,7 +255,7 @@ func (i *sfUpDownCounter) setDelegate(m metric.Meter) { func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.UpDownCounter).Add(ctx, incr, attrs...) + ctr.(instrument.Float64UpDownCounter).Add(ctx, incr, attrs...) } } @@ -267,7 +263,7 @@ type sfHistogram struct { name string opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.Histogram + delegate atomic.Value //instrument.Float64Histogram instrument.Synchronous } @@ -283,7 +279,7 @@ func (i *sfHistogram) setDelegate(m metric.Meter) { func (i *sfHistogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.Histogram).Record(ctx, x, attrs...) + ctr.(instrument.Float64Histogram).Record(ctx, x, attrs...) } } @@ -291,7 +287,7 @@ type siCounter struct { name string opts []instrument.Int64Option - delegate atomic.Value //syncint64.Counter + delegate atomic.Value //instrument.Int64Counter instrument.Synchronous } @@ -307,7 +303,7 @@ func (i *siCounter) setDelegate(m metric.Meter) { func (i *siCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.Counter).Add(ctx, x, attrs...) + ctr.(instrument.Int64Counter).Add(ctx, x, attrs...) } } @@ -315,7 +311,7 @@ type siUpDownCounter struct { name string opts []instrument.Int64Option - delegate atomic.Value //syncint64.UpDownCounter + delegate atomic.Value //instrument.Int64UpDownCounter instrument.Synchronous } @@ -331,7 +327,7 @@ func (i *siUpDownCounter) setDelegate(m metric.Meter) { func (i *siUpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.UpDownCounter).Add(ctx, x, attrs...) + ctr.(instrument.Int64UpDownCounter).Add(ctx, x, attrs...) } } @@ -339,7 +335,7 @@ type siHistogram struct { name string opts []instrument.Int64Option - delegate atomic.Value //syncint64.Histogram + delegate atomic.Value //instrument.Int64Histogram instrument.Synchronous } @@ -355,6 +351,6 @@ func (i *siHistogram) setDelegate(m metric.Meter) { func (i *siHistogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.Histogram).Record(ctx, x, attrs...) + ctr.(instrument.Int64Histogram).Record(ctx, x, attrs...) } } diff --git a/metric/internal/global/meter.go b/metric/internal/global/meter.go index bdde4e87ea0..97ad2735bea 100644 --- a/metric/internal/global/meter.go +++ b/metric/internal/global/meter.go @@ -22,10 +22,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // meterProvider is a placeholder for a configured SDK MeterProvider. @@ -146,7 +142,7 @@ func (m *meter) setDelegate(provider metric.MeterProvider) { m.registry.Init() } -func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (syncint64.Counter, error) { +func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64Counter(name, options...) } @@ -157,7 +153,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (sy return i, nil } -func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64UpDownCounter(name, options...) } @@ -168,7 +164,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Optio return i, nil } -func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (syncint64.Histogram, error) { +func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64Histogram(name, options...) } @@ -179,7 +175,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) ( return i, nil } -func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.Counter, error) { +func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64ObservableCounter(name, options...) } @@ -190,7 +186,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O return i, nil } -func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) { +func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64ObservableUpDownCounter(name, options...) } @@ -201,7 +197,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument. return i, nil } -func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) { +func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Int64ObservableGauge(name, options...) } @@ -212,7 +208,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs return i, nil } -func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (syncfloat64.Counter, error) { +func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64Counter(name, options...) } @@ -223,7 +219,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) return i, nil } -func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) { +func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64UpDownCounter(name, options...) } @@ -234,7 +230,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64O return i, nil } -func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (syncfloat64.Histogram, error) { +func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64Histogram(name, options...) } @@ -245,7 +241,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Optio return i, nil } -func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) { +func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64ObservableCounter(name, options...) } @@ -256,7 +252,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa return i, nil } -func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) { +func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64ObservableUpDownCounter(name, options...) } @@ -267,7 +263,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen return i, nil } -func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) { +func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { return del.Float64ObservableGauge(name, options...) } diff --git a/metric/internal/global/meter_test.go b/metric/internal/global/meter_test.go index 86d6f3e0ade..0260a7dedb3 100644 --- a/metric/internal/global/meter_test.go +++ b/metric/internal/global/meter_test.go @@ -25,8 +25,6 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" ) func TestMeterProviderRace(t *testing.T) { @@ -115,7 +113,7 @@ func TestUnregisterRace(t *testing.T) { close(finish) } -func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (syncfloat64.Counter, asyncfloat64.Counter) { +func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (instrument.Float64Counter, instrument.Float64ObservableCounter) { afcounter, err := m.Float64ObservableCounter("test_Async_Counter") require.NoError(t, err) _, err = m.Float64ObservableUpDownCounter("test_Async_UpDownCounter") diff --git a/metric/internal/global/meter_types_test.go b/metric/internal/global/meter_types_test.go index 31903995a83..57711f29e62 100644 --- a/metric/internal/global/meter_types_test.go +++ b/metric/internal/global/meter_types_test.go @@ -19,10 +19,6 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) type testMeterProvider struct { @@ -55,62 +51,62 @@ type testMeter struct { callbacks []metric.Callback } -func (m *testMeter) Int64Counter(name string, options ...instrument.Int64Option) (syncint64.Counter, error) { +func (m *testMeter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) { m.siCount++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { m.siUDCount++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Int64Histogram(name string, options ...instrument.Int64Option) (syncint64.Histogram, error) { +func (m *testMeter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) { m.siHist++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.Counter, error) { +func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { m.aiCount++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) { +func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { m.aiUDCount++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) { +func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { m.aiGauge++ return &testCountingIntInstrument{}, nil } -func (m *testMeter) Float64Counter(name string, options ...instrument.Float64Option) (syncfloat64.Counter, error) { +func (m *testMeter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) { m.sfCount++ return &testCountingFloatInstrument{}, nil } -func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) { +func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { m.sfUDCount++ return &testCountingFloatInstrument{}, nil } -func (m *testMeter) Float64Histogram(name string, options ...instrument.Float64Option) (syncfloat64.Histogram, error) { +func (m *testMeter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) { m.sfHist++ return &testCountingFloatInstrument{}, nil } -func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) { +func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { m.afCount++ return &testCountingFloatInstrument{}, nil } -func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) { +func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { m.afUDCount++ return &testCountingFloatInstrument{}, nil } -func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) { +func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { m.afGauge++ return &testCountingFloatInstrument{}, nil } diff --git a/metric/meter.go b/metric/meter.go index 35ffe0de384..41cbf91f255 100644 --- a/metric/meter.go +++ b/metric/meter.go @@ -18,10 +18,6 @@ import ( "context" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // MeterProvider provides access to named Meter instances, for instrumenting @@ -44,56 +40,56 @@ type Meter interface { // Int64Counter returns a new instrument identified by name and configured // with options. The instrument is used to synchronously record increasing // int64 measurements during a computational operation. - Int64Counter(name string, options ...instrument.Int64Option) (syncint64.Counter, error) + Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) // Int64UpDownCounter returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // int64 measurements during a computational operation. - Int64UpDownCounter(name string, options ...instrument.Int64Option) (syncint64.UpDownCounter, error) + Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) // Int64Histogram returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // the distribution of int64 measurements during a computational operation. - Int64Histogram(name string, options ...instrument.Int64Option) (syncint64.Histogram, error) + Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) // Int64ObservableCounter returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // increasing int64 measurements once per a measurement collection cycle. - Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.Counter, error) + Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) // Int64ObservableUpDownCounter returns a new instrument identified by name // and configured with options. The instrument is used to asynchronously // record int64 measurements once per a measurement collection cycle. - Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) + Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) // Int64ObservableGauge returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // instantaneous int64 measurements once per a measurement collection // cycle. - Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) + Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) // Float64Counter returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // increasing float64 measurements during a computational operation. - Float64Counter(name string, options ...instrument.Float64Option) (syncfloat64.Counter, error) + Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) // Float64UpDownCounter returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // float64 measurements during a computational operation. - Float64UpDownCounter(name string, options ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) + Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) // Float64Histogram returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // the distribution of float64 measurements during a computational // operation. - Float64Histogram(name string, options ...instrument.Float64Option) (syncfloat64.Histogram, error) + Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) // Float64ObservableCounter returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // increasing float64 measurements once per a measurement collection cycle. - Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) + Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) // Float64ObservableUpDownCounter returns a new instrument identified by // name and configured with options. The instrument is used to // asynchronously record float64 measurements once per a measurement // collection cycle. - Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) + Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) // Float64ObservableGauge returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // instantaneous float64 measurements once per a measurement collection // cycle. - Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) + Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) // RegisterCallback registers f to be called during the collection of a // measurement cycle. diff --git a/metric/noop.go b/metric/noop.go index 8c717f2a92a..98652b4fac7 100644 --- a/metric/noop.go +++ b/metric/noop.go @@ -19,10 +19,6 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // NewNoopMeterProvider creates a MeterProvider that does not record any metrics. @@ -43,51 +39,51 @@ func NewNoopMeter() Meter { type noopMeter struct{} -func (noopMeter) Int64Counter(string, ...instrument.Int64Option) (syncint64.Counter, error) { +func (noopMeter) Int64Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) { return nonrecordingSyncInt64Instrument{}, nil } -func (noopMeter) Int64UpDownCounter(string, ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (noopMeter) Int64UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { return nonrecordingSyncInt64Instrument{}, nil } -func (noopMeter) Int64Histogram(string, ...instrument.Int64Option) (syncint64.Histogram, error) { +func (noopMeter) Int64Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) { return nonrecordingSyncInt64Instrument{}, nil } -func (noopMeter) Int64ObservableCounter(string, ...instrument.Int64ObserverOption) (asyncint64.Counter, error) { +func (noopMeter) Int64ObservableCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { return nonrecordingAsyncInt64Instrument{}, nil } -func (noopMeter) Int64ObservableUpDownCounter(string, ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) { +func (noopMeter) Int64ObservableUpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { return nonrecordingAsyncInt64Instrument{}, nil } -func (noopMeter) Int64ObservableGauge(string, ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) { +func (noopMeter) Int64ObservableGauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { return nonrecordingAsyncInt64Instrument{}, nil } -func (noopMeter) Float64Counter(string, ...instrument.Float64Option) (syncfloat64.Counter, error) { +func (noopMeter) Float64Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) { return nonrecordingSyncFloat64Instrument{}, nil } -func (noopMeter) Float64UpDownCounter(string, ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) { +func (noopMeter) Float64UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { return nonrecordingSyncFloat64Instrument{}, nil } -func (noopMeter) Float64Histogram(string, ...instrument.Float64Option) (syncfloat64.Histogram, error) { +func (noopMeter) Float64Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) { return nonrecordingSyncFloat64Instrument{}, nil } -func (noopMeter) Float64ObservableCounter(string, ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) { +func (noopMeter) Float64ObservableCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { return nonrecordingAsyncFloat64Instrument{}, nil } -func (noopMeter) Float64ObservableUpDownCounter(string, ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) { +func (noopMeter) Float64ObservableUpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { return nonrecordingAsyncFloat64Instrument{}, nil } -func (noopMeter) Float64ObservableGauge(string, ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) { +func (noopMeter) Float64ObservableGauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { return nonrecordingAsyncFloat64Instrument{}, nil } @@ -105,20 +101,20 @@ type nonrecordingAsyncFloat64Instrument struct { } var ( - _ asyncfloat64.Counter = nonrecordingAsyncFloat64Instrument{} - _ asyncfloat64.UpDownCounter = nonrecordingAsyncFloat64Instrument{} - _ asyncfloat64.Gauge = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableCounter = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableUpDownCounter = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableGauge = nonrecordingAsyncFloat64Instrument{} ) -func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) { +func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { return n, nil } -func (n nonrecordingAsyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) { +func (n nonrecordingAsyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { return n, nil } -func (n nonrecordingAsyncFloat64Instrument) Gauge(string, ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) { +func (n nonrecordingAsyncFloat64Instrument) Gauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { return n, nil } @@ -131,20 +127,20 @@ type nonrecordingAsyncInt64Instrument struct { } var ( - _ asyncint64.Counter = nonrecordingAsyncInt64Instrument{} - _ asyncint64.UpDownCounter = nonrecordingAsyncInt64Instrument{} - _ asyncint64.Gauge = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableCounter = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableUpDownCounter = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableGauge = nonrecordingAsyncInt64Instrument{} ) -func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Int64ObserverOption) (asyncint64.Counter, error) { +func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { return n, nil } -func (n nonrecordingAsyncInt64Instrument) UpDownCounter(string, ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) { +func (n nonrecordingAsyncInt64Instrument) UpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { return n, nil } -func (n nonrecordingAsyncInt64Instrument) Gauge(string, ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) { +func (n nonrecordingAsyncInt64Instrument) Gauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { return n, nil } @@ -156,20 +152,20 @@ type nonrecordingSyncFloat64Instrument struct { } var ( - _ syncfloat64.Counter = nonrecordingSyncFloat64Instrument{} - _ syncfloat64.UpDownCounter = nonrecordingSyncFloat64Instrument{} - _ syncfloat64.Histogram = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64Counter = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64UpDownCounter = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64Histogram = nonrecordingSyncFloat64Instrument{} ) -func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Float64Option) (syncfloat64.Counter, error) { +func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) { return n, nil } -func (n nonrecordingSyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) { +func (n nonrecordingSyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { return n, nil } -func (n nonrecordingSyncFloat64Instrument) Histogram(string, ...instrument.Float64Option) (syncfloat64.Histogram, error) { +func (n nonrecordingSyncFloat64Instrument) Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) { return n, nil } @@ -186,20 +182,20 @@ type nonrecordingSyncInt64Instrument struct { } var ( - _ syncint64.Counter = nonrecordingSyncInt64Instrument{} - _ syncint64.UpDownCounter = nonrecordingSyncInt64Instrument{} - _ syncint64.Histogram = nonrecordingSyncInt64Instrument{} + _ instrument.Int64Counter = nonrecordingSyncInt64Instrument{} + _ instrument.Int64UpDownCounter = nonrecordingSyncInt64Instrument{} + _ instrument.Int64Histogram = nonrecordingSyncInt64Instrument{} ) -func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Int64Option) (syncint64.Counter, error) { +func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) { return n, nil } -func (n nonrecordingSyncInt64Instrument) UpDownCounter(string, ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (n nonrecordingSyncInt64Instrument) UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { return n, nil } -func (n nonrecordingSyncInt64Instrument) Histogram(string, ...instrument.Int64Option) (syncint64.Histogram, error) { +func (n nonrecordingSyncInt64Instrument) Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) { return n, nil } diff --git a/sdk/metric/benchmark_test.go b/sdk/metric/benchmark_test.go index e77bf149e2e..c7bf12beb67 100644 --- a/sdk/metric/benchmark_test.go +++ b/sdk/metric/benchmark_test.go @@ -19,10 +19,10 @@ import ( "testing" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric/instrument" ) -func benchCounter(b *testing.B, views ...View) (context.Context, Reader, syncint64.Counter) { +func benchCounter(b *testing.B, views ...View) (context.Context, Reader, instrument.Int64Counter) { ctx := context.Background() rdr := NewManualReader() provider := NewMeterProvider(WithReader(rdr), WithView(views...)) diff --git a/sdk/metric/instrument.go b/sdk/metric/instrument.go index 5454a4736ec..5414a8db7e6 100644 --- a/sdk/metric/instrument.go +++ b/sdk/metric/instrument.go @@ -19,10 +19,6 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/sdk/instrumentation" "go.opentelemetry.io/otel/sdk/metric/aggregation" @@ -180,18 +176,18 @@ type instrumentImpl[N int64 | float64] struct { aggregators []internal.Aggregator[N] } -var _ asyncfloat64.Counter = &instrumentImpl[float64]{} -var _ asyncfloat64.UpDownCounter = &instrumentImpl[float64]{} -var _ asyncfloat64.Gauge = &instrumentImpl[float64]{} -var _ asyncint64.Counter = &instrumentImpl[int64]{} -var _ asyncint64.UpDownCounter = &instrumentImpl[int64]{} -var _ asyncint64.Gauge = &instrumentImpl[int64]{} -var _ syncfloat64.Counter = &instrumentImpl[float64]{} -var _ syncfloat64.UpDownCounter = &instrumentImpl[float64]{} -var _ syncfloat64.Histogram = &instrumentImpl[float64]{} -var _ syncint64.Counter = &instrumentImpl[int64]{} -var _ syncint64.UpDownCounter = &instrumentImpl[int64]{} -var _ syncint64.Histogram = &instrumentImpl[int64]{} +var _ instrument.Float64ObservableCounter = &instrumentImpl[float64]{} +var _ instrument.Float64ObservableUpDownCounter = &instrumentImpl[float64]{} +var _ instrument.Float64ObservableGauge = &instrumentImpl[float64]{} +var _ instrument.Int64ObservableCounter = &instrumentImpl[int64]{} +var _ instrument.Int64ObservableUpDownCounter = &instrumentImpl[int64]{} +var _ instrument.Int64ObservableGauge = &instrumentImpl[int64]{} +var _ instrument.Float64Counter = &instrumentImpl[float64]{} +var _ instrument.Float64UpDownCounter = &instrumentImpl[float64]{} +var _ instrument.Float64Histogram = &instrumentImpl[float64]{} +var _ instrument.Int64Counter = &instrumentImpl[int64]{} +var _ instrument.Int64UpDownCounter = &instrumentImpl[int64]{} +var _ instrument.Int64Histogram = &instrumentImpl[int64]{} func (i *instrumentImpl[N]) Observe(ctx context.Context, val N, attrs ...attribute.KeyValue) { // Only record a value if this is being called from the MetricProvider. diff --git a/sdk/metric/internal/aggregator_example_test.go b/sdk/metric/internal/aggregator_example_test.go index be5d760f317..b5e58a887e6 100644 --- a/sdk/metric/internal/aggregator_example_test.go +++ b/sdk/metric/internal/aggregator_example_test.go @@ -20,7 +20,6 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/syncint64" "go.opentelemetry.io/otel/sdk/metric/aggregation" "go.opentelemetry.io/otel/sdk/metric/metricdata" ) @@ -31,7 +30,7 @@ type meter struct { aggregations []metricdata.Aggregation } -func (p *meter) Int64Counter(string, ...instrument.Int64Option) (syncint64.Counter, error) { +func (p *meter) Int64Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) { // This is an example of how a meter would create an aggregator for a new // counter. At this point the provider would determine the aggregation and // temporality to used based on the Reader and View configuration. Assume @@ -47,7 +46,7 @@ func (p *meter) Int64Counter(string, ...instrument.Int64Option) (syncint64.Count return count, nil } -func (p *meter) Int64UpDownCounter(string, ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (p *meter) Int64UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { // This is an example of how a meter would create an aggregator for a new // up-down counter. At this point the provider would determine the // aggregation and temporality to used based on the Reader and View @@ -64,7 +63,7 @@ func (p *meter) Int64UpDownCounter(string, ...instrument.Int64Option) (syncint64 return upDownCount, nil } -func (p *meter) Int64Histogram(string, ...instrument.Int64Option) (syncint64.Histogram, error) { +func (p *meter) Int64Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) { // This is an example of how a meter would create an aggregator for a new // histogram. At this point the provider would determine the aggregation // and temporality to used based on the Reader and View configuration. diff --git a/sdk/metric/meter.go b/sdk/metric/meter.go index 1ebd0cb8018..7aabb2a999e 100644 --- a/sdk/metric/meter.go +++ b/sdk/metric/meter.go @@ -19,10 +19,6 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/sdk/instrumentation" ) @@ -61,7 +57,7 @@ var _ metric.Meter = (*meter)(nil) // Int64Counter returns a new instrument identified by name and configured with // options. The instrument is used to synchronously record increasing int64 // measurements during a computational operation. -func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (syncint64.Counter, error) { +func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) { cfg := instrument.NewInt64Config(options...) const kind = InstrumentKindCounter return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -70,7 +66,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (sy // Int64UpDownCounter returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // int64 measurements during a computational operation. -func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (syncint64.UpDownCounter, error) { +func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { cfg := instrument.NewInt64Config(options...) const kind = InstrumentKindUpDownCounter return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -79,7 +75,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Optio // Int64Histogram returns a new instrument identified by name and configured // with options. The instrument is used to synchronously record the // distribution of int64 measurements during a computational operation. -func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (syncint64.Histogram, error) { +func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) { cfg := instrument.NewInt64Config(options...) const kind = InstrumentKindHistogram return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -88,7 +84,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) ( // Int64ObservableCounter returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // increasing int64 measurements once per a measurement collection cycle. -func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.Counter, error) { +func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { cfg := instrument.NewInt64ObserverConfig(options...) const kind = InstrumentKindObservableCounter p := int64ObservProvider{m.int64IP} @@ -103,7 +99,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O // Int64ObservableUpDownCounter returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // int64 measurements once per a measurement collection cycle. -func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (asyncint64.UpDownCounter, error) { +func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { cfg := instrument.NewInt64ObserverConfig(options...) const kind = InstrumentKindObservableUpDownCounter p := int64ObservProvider{m.int64IP} @@ -118,7 +114,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument. // Int64ObservableGauge returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // instantaneous int64 measurements once per a measurement collection cycle. -func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (asyncint64.Gauge, error) { +func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { cfg := instrument.NewInt64ObserverConfig(options...) const kind = InstrumentKindObservableGauge p := int64ObservProvider{m.int64IP} @@ -133,7 +129,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs // Float64Counter returns a new instrument identified by name and configured // with options. The instrument is used to synchronously record increasing // float64 measurements during a computational operation. -func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (syncfloat64.Counter, error) { +func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) { cfg := instrument.NewFloat64Config(options...) const kind = InstrumentKindCounter return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -142,7 +138,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) // Float64UpDownCounter returns a new instrument identified by name and // configured with options. The instrument is used to synchronously record // float64 measurements during a computational operation. -func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (syncfloat64.UpDownCounter, error) { +func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { cfg := instrument.NewFloat64Config(options...) const kind = InstrumentKindUpDownCounter return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -151,7 +147,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64O // Float64Histogram returns a new instrument identified by name and configured // with options. The instrument is used to synchronously record the // distribution of float64 measurements during a computational operation. -func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (syncfloat64.Histogram, error) { +func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) { cfg := instrument.NewFloat64Config(options...) const kind = InstrumentKindHistogram return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit()) @@ -160,7 +156,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Optio // Float64ObservableCounter returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // increasing float64 measurements once per a measurement collection cycle. -func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Counter, error) { +func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { cfg := instrument.NewFloat64ObserverConfig(options...) const kind = InstrumentKindObservableCounter p := float64ObservProvider{m.float64IP} @@ -175,7 +171,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa // Float64ObservableUpDownCounter returns a new instrument identified by name // and configured with options. The instrument is used to asynchronously record // float64 measurements once per a measurement collection cycle. -func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.UpDownCounter, error) { +func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { cfg := instrument.NewFloat64ObserverConfig(options...) const kind = InstrumentKindObservableUpDownCounter p := float64ObservProvider{m.float64IP} @@ -190,7 +186,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen // Float64ObservableGauge returns a new instrument identified by name and // configured with options. The instrument is used to asynchronously record // instantaneous float64 measurements once per a measurement collection cycle. -func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (asyncfloat64.Gauge, error) { +func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { cfg := instrument.NewFloat64ObserverConfig(options...) const kind = InstrumentKindObservableGauge p := float64ObservProvider{m.float64IP} diff --git a/sdk/metric/meter_test.go b/sdk/metric/meter_test.go index b394707b0aa..44209078fa6 100644 --- a/sdk/metric/meter_test.go +++ b/sdk/metric/meter_test.go @@ -25,10 +25,6 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" "go.opentelemetry.io/otel/sdk/instrumentation" "go.opentelemetry.io/otel/sdk/metric/aggregation" "go.opentelemetry.io/otel/sdk/metric/metricdata" @@ -1034,21 +1030,21 @@ func TestAttributeFilter(t *testing.T) { } var ( - aiCounter asyncint64.Counter - aiUpDownCounter asyncint64.UpDownCounter - aiGauge asyncint64.Gauge + aiCounter instrument.Int64ObservableCounter + aiUpDownCounter instrument.Int64ObservableUpDownCounter + aiGauge instrument.Int64ObservableGauge - afCounter asyncfloat64.Counter - afUpDownCounter asyncfloat64.UpDownCounter - afGauge asyncfloat64.Gauge + afCounter instrument.Float64ObservableCounter + afUpDownCounter instrument.Float64ObservableUpDownCounter + afGauge instrument.Float64ObservableGauge - siCounter syncint64.Counter - siUpDownCounter syncint64.UpDownCounter - siHistogram syncint64.Histogram + siCounter instrument.Int64Counter + siUpDownCounter instrument.Int64UpDownCounter + siHistogram instrument.Int64Histogram - sfCounter syncfloat64.Counter - sfUpDownCounter syncfloat64.UpDownCounter - sfHistogram syncfloat64.Histogram + sfCounter instrument.Float64Counter + sfUpDownCounter instrument.Float64UpDownCounter + sfHistogram instrument.Float64Histogram ) func BenchmarkInstrumentCreation(b *testing.B) {