Skip to content

Commit a54167d

Browse files
Remove metric instrument provider API (#3530)
* Remove all InstrumentProvider APIs * Fix noop impl * Fix metric/example_test.go * Update global impl * Update sdk/metric impl * Fix examples * Fix prometheus exporter * Add changes to changelog Co-authored-by: Aaron Clawson <[email protected]>
1 parent aac35a8 commit a54167d

22 files changed

+645
-689
lines changed

CHANGELOG.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1414
This `Registration` can be used to unregister callbacks. (#3522)
1515
- Add `Producer` interface and `Reader.RegisterProducer(Producer)` to `go.opentelemetry.io/otel/sdk/metric` to enable external metric Producers. (#3524)
1616

17-
### Removed
18-
19-
- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520)
20-
2117
### Changed
2218

19+
- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/asyncint64` is removed.
20+
Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530)
21+
- The `Counter` method is replaced by `Meter.Int64ObservableCounter`
22+
- The `UpDownCounter` method is replaced by `Meter.Int64ObservableUpDownCounter`
23+
- The `Gauge` method is replaced by `Meter.Int64ObservableGauge`
24+
- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/asyncfloat64` is removed.
25+
Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530)
26+
- The `Counter` method is replaced by `Meter.Float64ObservableCounter`
27+
- The `UpDownCounter` method is replaced by `Meter.Float64ObservableUpDownCounter`
28+
- The `Gauge` method is replaced by `Meter.Float64ObservableGauge`
29+
- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/syncint64` is removed.
30+
Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530)
31+
- The `Counter` method is replaced by `Meter.Int64Counter`
32+
- The `UpDownCounter` method is replaced by `Meter.Int64UpDownCounter`
33+
- The `Histogram` method is replaced by `Meter.Int64Histogram`
34+
- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/syncfloat64` is removed.
35+
Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530)
36+
- The `Counter` method is replaced by `Meter.Float64Counter`
37+
- The `UpDownCounter` method is replaced by `Meter.Float64UpDownCounter`
38+
- The `Histogram` method is replaced by `Meter.Float64Histogram`
2339
- Global error handler uses an atomic value instead of a mutex. (#3543)
2440
- Add `Producer` interface and `Reader.RegisterProducer(Producer)` to `go.opentelemetry.io/otel/sdk/metric` to enable external metric Producers. (#3524)
2541
- Add `NewMetricProducer` to `go.opentelemetry.io/otel/bridge/opencensus`, which can be used to pass OpenCensus metrics to an OpenTelemetry Reader. (#3541)
@@ -33,6 +49,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3349

3450
- The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` is deprecated. Use `NewMetricProducer` instead. (#3541)
3551

52+
### Removed
53+
54+
- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520)
55+
3656
## [1.11.2/0.34.0] 2022-12-05
3757

3858
### Added

example/prometheus/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func main() {
5858
}
5959

6060
// This is the equivalent of prometheus.NewCounterVec
61-
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter"))
61+
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
6262
if err != nil {
6363
log.Fatal(err)
6464
}
6565
counter.Add(ctx, 5, attrs...)
6666

67-
gauge, err := meter.AsyncFloat64().Gauge("bar", instrument.WithDescription("a fun little gauge"))
67+
gauge, err := meter.Float64ObservableGauge("bar", instrument.WithDescription("a fun little gauge"))
6868
if err != nil {
6969
log.Fatal(err)
7070
}
@@ -77,7 +77,7 @@ func main() {
7777
}
7878

7979
// This is the equivalent of prometheus.NewHistogramVec
80-
histogram, err := meter.SyncFloat64().Histogram("baz", instrument.WithDescription("a very nice histogram"))
80+
histogram, err := meter.Float64Histogram("baz", instrument.WithDescription("a very nice histogram"))
8181
if err != nil {
8282
log.Fatal(err)
8383
}

example/view/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ func main() {
6969
attribute.Key("C").String("D"),
7070
}
7171

72-
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter"))
72+
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
7373
if err != nil {
7474
log.Fatal(err)
7575
}
7676
counter.Add(ctx, 5, attrs...)
7777

78-
histogram, err := meter.SyncFloat64().Histogram("custom_histogram", instrument.WithDescription("a histogram with custom buckets and rename"))
78+
histogram, err := meter.Float64Histogram("custom_histogram", instrument.WithDescription("a histogram with custom buckets and rename"))
7979
if err != nil {
8080
log.Fatal(err)
8181
}

exporters/prometheus/benchmark_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func benchmarkCollect(b *testing.B, n int) {
3434
meter := provider.Meter("testmeter")
3535

3636
for i := 0; i < n; i++ {
37-
counter, err := meter.SyncFloat64().Counter(fmt.Sprintf("foo_%d", i))
37+
counter, err := meter.Float64Counter(fmt.Sprintf("foo_%d", i))
3838
require.NoError(b, err)
3939
counter.Add(ctx, float64(i))
4040
}

0 commit comments

Comments
 (0)