Skip to content

Commit

Permalink
Deprecate the syncint64/syncfloat64/asyncint64/asyncfloat64 packages (#…
Browse files Browse the repository at this point in the history
…3575)

* Dep async/sync pkgs for new inst in instrument pkg

* Replace use of deprecated instruments

* Add changelog entry

* Update changelog entry PR number
  • Loading branch information
MrAlias committed Jan 10, 2023
1 parent 78a5582 commit 36904e4
Show file tree
Hide file tree
Showing 21 changed files with 341 additions and 181 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions metric/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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) {}
24 changes: 24 additions & 0 deletions metric/instrument/asyncfloat64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
14 changes: 14 additions & 0 deletions metric/instrument/asyncfloat64/asyncfloat64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 }
24 changes: 24 additions & 0 deletions metric/instrument/asyncint64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
14 changes: 14 additions & 0 deletions metric/instrument/asyncint64/asyncint64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 }
35 changes: 35 additions & 0 deletions metric/instrument/syncfloat64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions metric/instrument/syncfloat64/syncfloat64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions metric/instrument/syncint64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions metric/instrument/syncint64/syncint64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 36904e4

Please sign in to comment.