Skip to content

Commit

Permalink
Remove metric instrument provider API (#3530)
Browse files Browse the repository at this point in the history
* 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 <3766680+MadVikingGod@users.noreply.github.com>
  • Loading branch information
MrAlias and MadVikingGod authored Jan 3, 2023
1 parent aac35a8 commit a54167d
Show file tree
Hide file tree
Showing 22 changed files with 645 additions and 689 deletions.
28 changes: 24 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,28 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This `Registration` can be used to unregister callbacks. (#3522)
- Add `Producer` interface and `Reader.RegisterProducer(Producer)` to `go.opentelemetry.io/otel/sdk/metric` to enable external metric Producers. (#3524)

### Removed

- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520)

### Changed

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

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

### Removed

- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520)

## [1.11.2/0.34.0] 2022-12-05

### Added
Expand Down
6 changes: 3 additions & 3 deletions example/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func main() {
}

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

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

// This is the equivalent of prometheus.NewHistogramVec
histogram, err := meter.SyncFloat64().Histogram("baz", instrument.WithDescription("a very nice histogram"))
histogram, err := meter.Float64Histogram("baz", instrument.WithDescription("a very nice histogram"))
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions example/view/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func main() {
attribute.Key("C").String("D"),
}

counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter"))
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
if err != nil {
log.Fatal(err)
}
counter.Add(ctx, 5, attrs...)

histogram, err := meter.SyncFloat64().Histogram("custom_histogram", instrument.WithDescription("a histogram with custom buckets and rename"))
histogram, err := meter.Float64Histogram("custom_histogram", instrument.WithDescription("a histogram with custom buckets and rename"))
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/prometheus/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func benchmarkCollect(b *testing.B, n int) {
meter := provider.Meter("testmeter")

for i := 0; i < n; i++ {
counter, err := meter.SyncFloat64().Counter(fmt.Sprintf("foo_%d", i))
counter, err := meter.Float64Counter(fmt.Sprintf("foo_%d", i))
require.NoError(b, err)
counter.Add(ctx, float64(i))
}
Expand Down
Loading

0 comments on commit a54167d

Please sign in to comment.