Skip to content

Commit 36904e4

Browse files
authored
Deprecate the syncint64/syncfloat64/asyncint64/asyncfloat64 packages (#3575)
* Dep async/sync pkgs for new inst in instrument pkg * Replace use of deprecated instruments * Add changelog entry * Update changelog entry PR number
1 parent 78a5582 commit 36904e4

21 files changed

+341
-181
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3535
The package contains semantic conventions from the `v1.15.0` version of the OpenTelemetry specification. (#3578)
3636
- Add the `go.opentelemetry.io/otel/semconv/v1.16.0` package.
3737
The package contains semantic conventions from the `v1.16.0` version of the OpenTelemetry specification. (#3579)
38+
- Metric instruments were added to `go.opentelemetry.io/otel/metric/instrument`.
39+
These instruments are use as replacements of the depreacted `go.opentelemetry.io/otel/metric/instrument/{asyncfloat64,asyncint64,syncfloat64,syncint64}` packages.(#3575)
40+
- `Float64ObservableCounter` replaces the `asyncfloat64.Counter`
41+
- `Float64ObservableUpDownCounter` replaces the `asyncfloat64.UpDownCounter`
42+
- `Float64ObservableGauge` replaces the `asyncfloat64.Gauge`
43+
- `Int64ObservableCounter` replaces the `asyncint64.Counter`
44+
- `Int64ObservableUpDownCounter` replaces the `asyncint64.UpDownCounter`
45+
- `Int64ObservableGauge` replaces the `asyncint64.Gauge`
46+
- `Float64Counter` replaces the `syncfloat64.Counter`
47+
- `Float64UpDownCounter` replaces the `syncfloat64.UpDownCounter`
48+
- `Float64Histogram` replaces the `syncfloat64.Histogram`
49+
- `Int64Counter` replaces the `syncint64.Counter`
50+
- `Int64UpDownCounter` replaces the `syncint64.UpDownCounter`
51+
- `Int64Histogram` replaces the `syncint64.Histogram`
3852

3953
### Changed
4054

@@ -89,6 +103,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
89103
### Deprecated
90104

91105
- The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` is deprecated. Use `NewMetricProducer` instead. (#3541)
106+
- The `go.opentelemetry.io/otel/metric/instrument/asyncfloat64` package is deprecated.
107+
Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575)
108+
- The `go.opentelemetry.io/otel/metric/instrument/asyncint64` package is deprecated.
109+
Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575)
110+
- The `go.opentelemetry.io/otel/metric/instrument/syncfloat64` package is deprecated.
111+
Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575)
112+
- The `go.opentelemetry.io/otel/metric/instrument/syncint64` package is deprecated.
113+
Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575)
92114

93115
### Removed
94116

metric/example_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"go.opentelemetry.io/otel/metric"
2424
"go.opentelemetry.io/otel/metric/instrument"
25-
"go.opentelemetry.io/otel/metric/instrument/syncfloat64"
2625
"go.opentelemetry.io/otel/metric/unit"
2726
)
2827

@@ -112,4 +111,4 @@ func ExampleMeter_asynchronous_multiple() {
112111
}
113112

114113
// This is just an example, see the the contrib runtime instrumentation for real implementation.
115-
func computeGCPauses(ctx context.Context, recorder syncfloat64.Histogram, pauseBuff []uint64) {}
114+
func computeGCPauses(ctx context.Context, recorder instrument.Float64Histogram, pauseBuff []uint64) {}

metric/instrument/asyncfloat64.go

+24
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ type Float64Observer interface {
3434
Observe(ctx context.Context, value float64, attributes ...attribute.KeyValue)
3535
}
3636

37+
// Float64ObservableCounter is an instrument used to asynchronously record
38+
// increasing float64 measurements once per a measurement collection cycle. The
39+
// Observe method is used to record the measured state of the instrument when
40+
// it is called. Implementations will assume the observed value to be the
41+
// cumulative sum of the count.
42+
//
43+
// Warning: methods may be added to this interface in minor releases.
44+
type Float64ObservableCounter interface{ Float64Observer }
45+
46+
// Float64ObservableUpDownCounter is an instrument used to asynchronously
47+
// record float64 measurements once per a measurement collection cycle. The
48+
// Observe method is used to record the measured state of the instrument when
49+
// it is called. Implementations will assume the observed value to be the
50+
// cumulative sum of the count.
51+
//
52+
// Warning: methods may be added to this interface in minor releases.
53+
type Float64ObservableUpDownCounter interface{ Float64Observer }
54+
55+
// Float64ObservableGauge is an instrument used to asynchronously record
56+
// instantaneous float64 measurements once per a measurement collection cycle.
57+
//
58+
// Warning: methods may be added to this interface in minor releases.
59+
type Float64ObservableGauge interface{ Float64Observer }
60+
3761
// Float64Callback is a function registered with a Meter that makes
3862
// observations for a Float64Observer it is registered with.
3963
//

metric/instrument/asyncfloat64/asyncfloat64.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Package asyncfloat64 provides asynchronous instruments that accept float64
16+
// measurments.
17+
//
18+
// Deprecated: Use the instruments provided by
19+
// go.opentelemetry.io/otel/metric/instrument instead.
1520
package asyncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/asyncfloat64"
1621

1722
import "go.opentelemetry.io/otel/metric/instrument"
@@ -23,6 +28,9 @@ import "go.opentelemetry.io/otel/metric/instrument"
2328
// the count.
2429
//
2530
// Warning: methods may be added to this interface in minor releases.
31+
//
32+
// Deprecated: Use the Float64ObservableCounter in
33+
// go.opentelemetry.io/otel/metric/instrument instead.
2634
type Counter interface{ instrument.Float64Observer }
2735

2836
// UpDownCounter is an instrument used to asynchronously record float64
@@ -32,10 +40,16 @@ type Counter interface{ instrument.Float64Observer }
3240
// the count.
3341
//
3442
// Warning: methods may be added to this interface in minor releases.
43+
//
44+
// Deprecated: Use the Float64ObservableUpDownCounter in
45+
// go.opentelemetry.io/otel/metric/instrument instead.
3546
type UpDownCounter interface{ instrument.Float64Observer }
3647

3748
// Gauge is an instrument used to asynchronously record instantaneous float64
3849
// measurements once per a measurement collection cycle.
3950
//
4051
// Warning: methods may be added to this interface in minor releases.
52+
//
53+
// Deprecated: Use the Float64ObservableGauge in
54+
// go.opentelemetry.io/otel/metric/instrument instead.
4155
type Gauge interface{ instrument.Float64Observer }

metric/instrument/asyncint64.go

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ type Int64Observer interface {
3535
Observe(ctx context.Context, value int64, attributes ...attribute.KeyValue)
3636
}
3737

38+
// Int64ObservableCounter is an instrument used to asynchronously record
39+
// increasing int64 measurements once per a measurement collection cycle. The
40+
// Observe method is used to record the measured state of the instrument when
41+
// it is called. Implementations will assume the observed value to be the
42+
// cumulative sum of the count.
43+
//
44+
// Warning: methods may be added to this interface in minor releases.
45+
type Int64ObservableCounter interface{ Int64Observer }
46+
47+
// Int64ObservableUpDownCounter is an instrument used to asynchronously record
48+
// int64 measurements once per a measurement collection cycle. The Observe
49+
// method is used to record the measured state of the instrument when it is
50+
// called. Implementations will assume the observed value to be the cumulative
51+
// sum of the count.
52+
//
53+
// Warning: methods may be added to this interface in minor releases.
54+
type Int64ObservableUpDownCounter interface{ Int64Observer }
55+
56+
// Int64ObservableGauge is an instrument used to asynchronously record
57+
// instantaneous int64 measurements once per a measurement collection cycle.
58+
//
59+
// Warning: methods may be added to this interface in minor releases.
60+
type Int64ObservableGauge interface{ Int64Observer }
61+
3862
// Int64Callback is a function registered with a Meter that makes
3963
// observations for an Int64Observer it is registered with.
4064
//

metric/instrument/asyncint64/asyncint64.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Package asyncint64 provides asynchronous instruments that accept int64
16+
// measurments.
17+
//
18+
// Deprecated: Use the instruments provided by
19+
// go.opentelemetry.io/otel/metric/instrument instead.
1520
package asyncint64 // import "go.opentelemetry.io/otel/metric/instrument/asyncint64"
1621

1722
import "go.opentelemetry.io/otel/metric/instrument"
@@ -23,6 +28,9 @@ import "go.opentelemetry.io/otel/metric/instrument"
2328
// the count.
2429
//
2530
// Warning: methods may be added to this interface in minor releases.
31+
//
32+
// Deprecated: Use the Int64ObservableCounter in
33+
// go.opentelemetry.io/otel/metric/instrument instead.
2634
type Counter interface{ instrument.Int64Observer }
2735

2836
// UpDownCounter is an instrument used to asynchronously record int64
@@ -32,10 +40,16 @@ type Counter interface{ instrument.Int64Observer }
3240
// the count.
3341
//
3442
// Warning: methods may be added to this interface in minor releases.
43+
//
44+
// Deprecated: Use the Int64ObservableUpDownCounter in
45+
// go.opentelemetry.io/otel/metric/instrument instead.
3546
type UpDownCounter interface{ instrument.Int64Observer }
3647

3748
// Gauge is an instrument used to asynchronously record instantaneous int64
3849
// measurements once per a measurement collection cycle.
3950
//
4051
// Warning: methods may be added to this interface in minor releases.
52+
//
53+
// Deprecated: Use the Int64ObservableGauge in
54+
// go.opentelemetry.io/otel/metric/instrument instead.
4155
type Gauge interface{ instrument.Int64Observer }

metric/instrument/syncfloat64.go

+35
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,44 @@
1515
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
1616

1717
import (
18+
"context"
19+
20+
"go.opentelemetry.io/otel/attribute"
1821
"go.opentelemetry.io/otel/metric/unit"
1922
)
2023

24+
// Float64Counter is an instrument that records increasing float64 values.
25+
//
26+
// Warning: methods may be added to this interface in minor releases.
27+
type Float64Counter interface {
28+
// Add records a change to the counter.
29+
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
30+
31+
Synchronous
32+
}
33+
34+
// Float64UpDownCounter is an instrument that records increasing or decreasing
35+
// float64 values.
36+
//
37+
// Warning: methods may be added to this interface in minor releases.
38+
type Float64UpDownCounter interface {
39+
// Add records a change to the counter.
40+
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
41+
42+
Synchronous
43+
}
44+
45+
// Float64Histogram is an instrument that records a distribution of float64
46+
// values.
47+
//
48+
// Warning: methods may be added to this interface in minor releases.
49+
type Float64Histogram interface {
50+
// Record adds an additional value to the distribution.
51+
Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
52+
53+
Synchronous
54+
}
55+
2156
// Float64Config contains options for Asynchronous instruments that
2257
// observe float64 values.
2358
type Float64Config struct {

metric/instrument/syncfloat64/syncfloat64.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Package syncfloat64 provides synchronous instruments that accept float64
16+
// measurments.
17+
//
18+
// Deprecated: Use the instruments provided by
19+
// go.opentelemetry.io/otel/metric/instrument instead.
1520
package syncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/syncfloat64"
1621

1722
import (
@@ -24,6 +29,9 @@ import (
2429
// Counter is an instrument that records increasing values.
2530
//
2631
// Warning: methods may be added to this interface in minor releases.
32+
//
33+
// Deprecated: Use the Float64Counter in
34+
// go.opentelemetry.io/otel/metric/instrument instead.
2735
type Counter interface {
2836
// Add records a change to the counter.
2937
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
@@ -34,6 +42,9 @@ type Counter interface {
3442
// UpDownCounter is an instrument that records increasing or decreasing values.
3543
//
3644
// Warning: methods may be added to this interface in minor releases.
45+
//
46+
// Deprecated: Use the Float64UpDownCounter in
47+
// go.opentelemetry.io/otel/metric/instrument instead.
3748
type UpDownCounter interface {
3849
// Add records a change to the counter.
3950
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
@@ -44,6 +55,9 @@ type UpDownCounter interface {
4455
// Histogram is an instrument that records a distribution of values.
4556
//
4657
// Warning: methods may be added to this interface in minor releases.
58+
//
59+
// Deprecated: Use the Float64Histogram in
60+
// go.opentelemetry.io/otel/metric/instrument instead.
4761
type Histogram interface {
4862
// Record adds an additional value to the distribution.
4963
Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue)

metric/instrument/syncint64.go

+35
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,44 @@
1515
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
1616

1717
import (
18+
"context"
19+
20+
"go.opentelemetry.io/otel/attribute"
1821
"go.opentelemetry.io/otel/metric/unit"
1922
)
2023

24+
// Int64Counter is an instrument that records increasing int64 values.
25+
//
26+
// Warning: methods may be added to this interface in minor releases.
27+
type Int64Counter interface {
28+
// Add records a change to the counter.
29+
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
30+
31+
Synchronous
32+
}
33+
34+
// Int64UpDownCounter is an instrument that records increasing or decreasing
35+
// int64 values.
36+
//
37+
// Warning: methods may be added to this interface in minor releases.
38+
type Int64UpDownCounter interface {
39+
// Add records a change to the counter.
40+
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
41+
42+
Synchronous
43+
}
44+
45+
// Int64Histogram is an instrument that records a distribution of int64
46+
// values.
47+
//
48+
// Warning: methods may be added to this interface in minor releases.
49+
type Int64Histogram interface {
50+
// Record adds an additional value to the distribution.
51+
Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
52+
53+
Synchronous
54+
}
55+
2156
// Int64Config contains options for Synchronous instruments that record int64
2257
// values.
2358
type Int64Config struct {

metric/instrument/syncint64/syncint64.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Package syncint64 provides synchronous instruments that accept int64
16+
// measurments.
17+
//
18+
// Deprecated: Use the instruments provided by
19+
// go.opentelemetry.io/otel/metric/instrument instead.
1520
package syncint64 // import "go.opentelemetry.io/otel/metric/instrument/syncint64"
1621

1722
import (
@@ -24,6 +29,9 @@ import (
2429
// Counter is an instrument that records increasing values.
2530
//
2631
// Warning: methods may be added to this interface in minor releases.
32+
//
33+
// Deprecated: Use the Int64Counter in
34+
// go.opentelemetry.io/otel/metric/instrument instead.
2735
type Counter interface {
2836
// Add records a change to the counter.
2937
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
@@ -34,6 +42,9 @@ type Counter interface {
3442
// UpDownCounter is an instrument that records increasing or decreasing values.
3543
//
3644
// Warning: methods may be added to this interface in minor releases.
45+
//
46+
// Deprecated: Use the Int64UpDownCounter in
47+
// go.opentelemetry.io/otel/metric/instrument instead.
3748
type UpDownCounter interface {
3849
// Add records a change to the counter.
3950
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
@@ -44,6 +55,9 @@ type UpDownCounter interface {
4455
// Histogram is an instrument that records a distribution of values.
4556
//
4657
// Warning: methods may be added to this interface in minor releases.
58+
//
59+
// Deprecated: Use the Int64Histogram in
60+
// go.opentelemetry.io/otel/metric/instrument instead.
4761
type Histogram interface {
4862
// Record adds an additional value to the distribution.
4963
Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue)

0 commit comments

Comments
 (0)