1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-23 21:19:35 +02:00

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 <3766680+MadVikingGod@users.noreply.github.com>
This commit is contained in:
Tyler Yahn 2023-01-03 10:34:10 -08:00 committed by GitHub
parent aac35a80c4
commit a54167d2c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 646 additions and 690 deletions

View File

@ -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) 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) - 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 ### 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) - 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 `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) - 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
- The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` is deprecated. Use `NewMetricProducer` instead. (#3541) - 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 ## [1.11.2/0.34.0] 2022-12-05
### Added ### Added

View File

@ -58,13 +58,13 @@ func main() {
} }
// This is the equivalent of prometheus.NewCounterVec // 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
counter.Add(ctx, 5, attrs...) 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -77,7 +77,7 @@ func main() {
} }
// This is the equivalent of prometheus.NewHistogramVec // 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -69,13 +69,13 @@ func main() {
attribute.Key("C").String("D"), 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
counter.Add(ctx, 5, attrs...) 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -34,7 +34,7 @@ func benchmarkCollect(b *testing.B, n int) {
meter := provider.Meter("testmeter") meter := provider.Meter("testmeter")
for i := 0; i < n; i++ { 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) require.NoError(b, err)
counter.Add(ctx, float64(i)) counter.Add(ctx, float64(i))
} }

View File

@ -53,7 +53,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("E").Bool(true), attribute.Key("E").Bool(true),
attribute.Key("F").Int(42), attribute.Key("F").Int(42),
} }
counter, err := meter.SyncFloat64().Counter( counter, err := meter.Float64Counter(
"foo", "foo",
instrument.WithDescription("a simple counter"), instrument.WithDescription("a simple counter"),
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
@ -80,7 +80,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("A").String("B"), attribute.Key("A").String("B"),
attribute.Key("C").String("D"), attribute.Key("C").String("D"),
} }
gauge, err := meter.SyncFloat64().UpDownCounter( gauge, err := meter.Float64UpDownCounter(
"bar", "bar",
instrument.WithDescription("a fun little gauge"), instrument.WithDescription("a fun little gauge"),
instrument.WithUnit(unit.Dimensionless), instrument.WithUnit(unit.Dimensionless),
@ -98,7 +98,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("A").String("B"), attribute.Key("A").String("B"),
attribute.Key("C").String("D"), attribute.Key("C").String("D"),
} }
histogram, err := meter.SyncFloat64().Histogram( histogram, err := meter.Float64Histogram(
"histogram_baz", "histogram_baz",
instrument.WithDescription("a very nice histogram"), instrument.WithDescription("a very nice histogram"),
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
@ -124,7 +124,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("C.D").String("Y"), attribute.Key("C.D").String("Y"),
attribute.Key("C/D").String("Z"), attribute.Key("C/D").String("Z"),
} }
counter, err := meter.SyncFloat64().Counter( counter, err := meter.Float64Counter(
"foo", "foo",
instrument.WithDescription("a sanitary counter"), instrument.WithDescription("a sanitary counter"),
// This unit is not added to // This unit is not added to
@ -145,21 +145,21 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("C").String("D"), attribute.Key("C").String("D"),
} }
// Valid. // Valid.
gauge, err := meter.SyncFloat64().UpDownCounter("bar", instrument.WithDescription("a fun little gauge")) gauge, err := meter.Float64UpDownCounter("bar", instrument.WithDescription("a fun little gauge"))
require.NoError(t, err) require.NoError(t, err)
gauge.Add(ctx, 100, attrs...) gauge.Add(ctx, 100, attrs...)
gauge.Add(ctx, -25, attrs...) gauge.Add(ctx, -25, attrs...)
// Invalid, will be renamed. // Invalid, will be renamed.
gauge, err = meter.SyncFloat64().UpDownCounter("invalid.gauge.name", instrument.WithDescription("a gauge with an invalid name")) gauge, err = meter.Float64UpDownCounter("invalid.gauge.name", instrument.WithDescription("a gauge with an invalid name"))
require.NoError(t, err) require.NoError(t, err)
gauge.Add(ctx, 100, attrs...) gauge.Add(ctx, 100, attrs...)
counter, err := meter.SyncFloat64().Counter("0invalid.counter.name", instrument.WithDescription("a counter with an invalid name")) counter, err := meter.Float64Counter("0invalid.counter.name", instrument.WithDescription("a counter with an invalid name"))
require.NoError(t, err) require.NoError(t, err)
counter.Add(ctx, 100, attrs...) counter.Add(ctx, 100, attrs...)
histogram, err := meter.SyncFloat64().Histogram("invalid.hist.name", instrument.WithDescription("a histogram with an invalid name")) histogram, err := meter.Float64Histogram("invalid.hist.name", instrument.WithDescription("a histogram with an invalid name"))
require.NoError(t, err) require.NoError(t, err)
histogram.Record(ctx, 23, attrs...) histogram.Record(ctx, 23, attrs...)
}, },
@ -175,7 +175,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("E").Bool(true), attribute.Key("E").Bool(true),
attribute.Key("F").Int(42), attribute.Key("F").Int(42),
} }
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter")) counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
require.NoError(t, err) require.NoError(t, err)
counter.Add(ctx, 5, attrs...) counter.Add(ctx, 5, attrs...)
counter.Add(ctx, 10.3, attrs...) counter.Add(ctx, 10.3, attrs...)
@ -196,7 +196,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("E").Bool(true), attribute.Key("E").Bool(true),
attribute.Key("F").Int(42), attribute.Key("F").Int(42),
} }
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter")) counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
require.NoError(t, err) require.NoError(t, err)
counter.Add(ctx, 5, attrs...) counter.Add(ctx, 5, attrs...)
counter.Add(ctx, 10.3, attrs...) counter.Add(ctx, 10.3, attrs...)
@ -214,7 +214,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("E").Bool(true), attribute.Key("E").Bool(true),
attribute.Key("F").Int(42), attribute.Key("F").Int(42),
} }
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter")) counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
require.NoError(t, err) require.NoError(t, err)
counter.Add(ctx, 5, attrs...) counter.Add(ctx, 5, attrs...)
counter.Add(ctx, 10.3, attrs...) counter.Add(ctx, 10.3, attrs...)
@ -230,7 +230,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("A").String("B"), attribute.Key("A").String("B"),
attribute.Key("C").String("D"), attribute.Key("C").String("D"),
} }
gauge, err := meter.SyncInt64().UpDownCounter( gauge, err := meter.Int64UpDownCounter(
"bar", "bar",
instrument.WithDescription("a fun little gauge"), instrument.WithDescription("a fun little gauge"),
instrument.WithUnit(unit.Dimensionless), instrument.WithUnit(unit.Dimensionless),
@ -249,7 +249,7 @@ func TestPrometheusExporter(t *testing.T) {
attribute.Key("A").String("B"), attribute.Key("A").String("B"),
attribute.Key("C").String("D"), attribute.Key("C").String("D"),
} }
counter, err := meter.SyncInt64().Counter( counter, err := meter.Int64Counter(
"bar", "bar",
instrument.WithDescription("a fun little counter"), instrument.WithDescription("a fun little counter"),
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
@ -364,18 +364,18 @@ func TestMultiScopes(t *testing.T) {
) )
fooCounter, err := provider.Meter("meterfoo", otelmetric.WithInstrumentationVersion("v0.1.0")). fooCounter, err := provider.Meter("meterfoo", otelmetric.WithInstrumentationVersion("v0.1.0")).
SyncInt64().Counter( Int64Counter(
"foo", "foo",
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("meter foo counter")) instrument.WithDescription("meter foo counter"))
assert.NoError(t, err) assert.NoError(t, err)
fooCounter.Add(ctx, 100, attribute.String("type", "foo")) fooCounter.Add(ctx, 100, attribute.String("type", "foo"))
barCounter, err := provider.Meter("meterbar", otelmetric.WithInstrumentationVersion("v0.1.0")). barCounter, err := provider.Meter("meterbar", otelmetric.WithInstrumentationVersion("v0.1.0")).
SyncInt64().Counter( Int64Counter(
"bar", "bar",
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("meter bar counter")) instrument.WithDescription("meter bar counter"))
assert.NoError(t, err) assert.NoError(t, err)
barCounter.Add(ctx, 200, attribute.String("type", "bar")) barCounter.Add(ctx, 200, attribute.String("type", "bar"))
@ -398,13 +398,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "no_conflict_two_counters", name: "no_conflict_two_counters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
fooA, err := meterA.SyncInt64().Counter("foo", fooA, err := meterA.Int64Counter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter counter foo")) instrument.WithDescription("meter counter foo"))
assert.NoError(t, err) assert.NoError(t, err)
fooA.Add(ctx, 100, attribute.String("A", "B")) fooA.Add(ctx, 100, attribute.String("A", "B"))
fooB, err := meterB.SyncInt64().Counter("foo", fooB, err := meterB.Int64Counter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter counter foo")) instrument.WithDescription("meter counter foo"))
assert.NoError(t, err) assert.NoError(t, err)
@ -415,13 +415,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "no_conflict_two_updowncounters", name: "no_conflict_two_updowncounters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
fooA, err := meterA.SyncInt64().UpDownCounter("foo", fooA, err := meterA.Int64UpDownCounter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter gauge foo")) instrument.WithDescription("meter gauge foo"))
assert.NoError(t, err) assert.NoError(t, err)
fooA.Add(ctx, 100, attribute.String("A", "B")) fooA.Add(ctx, 100, attribute.String("A", "B"))
fooB, err := meterB.SyncInt64().UpDownCounter("foo", fooB, err := meterB.Int64UpDownCounter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter gauge foo")) instrument.WithDescription("meter gauge foo"))
assert.NoError(t, err) assert.NoError(t, err)
@ -432,13 +432,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "no_conflict_two_histograms", name: "no_conflict_two_histograms",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
fooA, err := meterA.SyncInt64().Histogram("foo", fooA, err := meterA.Int64Histogram("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter histogram foo")) instrument.WithDescription("meter histogram foo"))
assert.NoError(t, err) assert.NoError(t, err)
fooA.Record(ctx, 100, attribute.String("A", "B")) fooA.Record(ctx, 100, attribute.String("A", "B"))
fooB, err := meterB.SyncInt64().Histogram("foo", fooB, err := meterB.Int64Histogram("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter histogram foo")) instrument.WithDescription("meter histogram foo"))
assert.NoError(t, err) assert.NoError(t, err)
@ -449,13 +449,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_help_two_counters", name: "conflict_help_two_counters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
barA, err := meterA.SyncInt64().Counter("bar", barA, err := meterA.Int64Counter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter a bar")) instrument.WithDescription("meter a bar"))
assert.NoError(t, err) assert.NoError(t, err)
barA.Add(ctx, 100, attribute.String("type", "bar")) barA.Add(ctx, 100, attribute.String("type", "bar"))
barB, err := meterB.SyncInt64().Counter("bar", barB, err := meterB.Int64Counter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter b bar")) instrument.WithDescription("meter b bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -469,13 +469,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_help_two_updowncounters", name: "conflict_help_two_updowncounters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
barA, err := meterA.SyncInt64().UpDownCounter("bar", barA, err := meterA.Int64UpDownCounter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter a bar")) instrument.WithDescription("meter a bar"))
assert.NoError(t, err) assert.NoError(t, err)
barA.Add(ctx, 100, attribute.String("type", "bar")) barA.Add(ctx, 100, attribute.String("type", "bar"))
barB, err := meterB.SyncInt64().UpDownCounter("bar", barB, err := meterB.Int64UpDownCounter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter b bar")) instrument.WithDescription("meter b bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -489,13 +489,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_help_two_histograms", name: "conflict_help_two_histograms",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
barA, err := meterA.SyncInt64().Histogram("bar", barA, err := meterA.Int64Histogram("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter a bar")) instrument.WithDescription("meter a bar"))
assert.NoError(t, err) assert.NoError(t, err)
barA.Record(ctx, 100, attribute.String("A", "B")) barA.Record(ctx, 100, attribute.String("A", "B"))
barB, err := meterB.SyncInt64().Histogram("bar", barB, err := meterB.Int64Histogram("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter b bar")) instrument.WithDescription("meter b bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -509,13 +509,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_unit_two_counters", name: "conflict_unit_two_counters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
bazA, err := meterA.SyncInt64().Counter("bar", bazA, err := meterA.Int64Counter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter bar")) instrument.WithDescription("meter bar"))
assert.NoError(t, err) assert.NoError(t, err)
bazA.Add(ctx, 100, attribute.String("type", "bar")) bazA.Add(ctx, 100, attribute.String("type", "bar"))
bazB, err := meterB.SyncInt64().Counter("bar", bazB, err := meterB.Int64Counter("bar",
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("meter bar")) instrument.WithDescription("meter bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -527,13 +527,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_unit_two_updowncounters", name: "conflict_unit_two_updowncounters",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
barA, err := meterA.SyncInt64().UpDownCounter("bar", barA, err := meterA.Int64UpDownCounter("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter gauge bar")) instrument.WithDescription("meter gauge bar"))
assert.NoError(t, err) assert.NoError(t, err)
barA.Add(ctx, 100, attribute.String("type", "bar")) barA.Add(ctx, 100, attribute.String("type", "bar"))
barB, err := meterB.SyncInt64().UpDownCounter("bar", barB, err := meterB.Int64UpDownCounter("bar",
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("meter gauge bar")) instrument.WithDescription("meter gauge bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -545,13 +545,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_unit_two_histograms", name: "conflict_unit_two_histograms",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
barA, err := meterA.SyncInt64().Histogram("bar", barA, err := meterA.Int64Histogram("bar",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter histogram bar")) instrument.WithDescription("meter histogram bar"))
assert.NoError(t, err) assert.NoError(t, err)
barA.Record(ctx, 100, attribute.String("A", "B")) barA.Record(ctx, 100, attribute.String("A", "B"))
barB, err := meterB.SyncInt64().Histogram("bar", barB, err := meterB.Int64Histogram("bar",
instrument.WithUnit(unit.Milliseconds), instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("meter histogram bar")) instrument.WithDescription("meter histogram bar"))
assert.NoError(t, err) assert.NoError(t, err)
@ -563,13 +563,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_type_counter_and_updowncounter", name: "conflict_type_counter_and_updowncounter",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
counter, err := meterA.SyncInt64().Counter("foo", counter, err := meterA.Int64Counter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter foo")) instrument.WithDescription("meter foo"))
assert.NoError(t, err) assert.NoError(t, err)
counter.Add(ctx, 100, attribute.String("type", "foo")) counter.Add(ctx, 100, attribute.String("type", "foo"))
gauge, err := meterA.SyncInt64().UpDownCounter("foo_total", gauge, err := meterA.Int64UpDownCounter("foo_total",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter foo")) instrument.WithDescription("meter foo"))
assert.NoError(t, err) assert.NoError(t, err)
@ -584,13 +584,13 @@ func TestDuplicateMetrics(t *testing.T) {
{ {
name: "conflict_type_histogram_and_updowncounter", name: "conflict_type_histogram_and_updowncounter",
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) { recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
fooA, err := meterA.SyncInt64().UpDownCounter("foo", fooA, err := meterA.Int64UpDownCounter("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter gauge foo")) instrument.WithDescription("meter gauge foo"))
assert.NoError(t, err) assert.NoError(t, err)
fooA.Add(ctx, 100, attribute.String("A", "B")) fooA.Add(ctx, 100, attribute.String("A", "B"))
fooHistogramA, err := meterA.SyncInt64().Histogram("foo", fooHistogramA, err := meterA.Int64Histogram("foo",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
instrument.WithDescription("meter histogram foo")) instrument.WithDescription("meter histogram foo"))
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -31,7 +31,7 @@ func ExampleMeter_synchronous() {
// In a library or program this would be provided by otel.GetMeterProvider(). // In a library or program this would be provided by otel.GetMeterProvider().
meterProvider := metric.NewNoopMeterProvider() meterProvider := metric.NewNoopMeterProvider()
workDuration, err := meterProvider.Meter("go.opentelemetry.io/otel/metric#SyncExample").SyncInt64().Histogram( workDuration, err := meterProvider.Meter("go.opentelemetry.io/otel/metric#SyncExample").Int64Histogram(
"workDuration", "workDuration",
instrument.WithUnit(unit.Milliseconds)) instrument.WithUnit(unit.Milliseconds))
if err != nil { if err != nil {
@ -52,7 +52,7 @@ func ExampleMeter_asynchronous_single() {
meterProvider := metric.NewNoopMeterProvider() meterProvider := metric.NewNoopMeterProvider()
meter := meterProvider.Meter("go.opentelemetry.io/otel/metric#AsyncExample") meter := meterProvider.Meter("go.opentelemetry.io/otel/metric#AsyncExample")
memoryUsage, err := meter.AsyncInt64().Gauge( memoryUsage, err := meter.Int64ObservableGauge(
"MemoryUsage", "MemoryUsage",
instrument.WithUnit(unit.Bytes), instrument.WithUnit(unit.Bytes),
) )
@ -82,9 +82,9 @@ func ExampleMeter_asynchronous_multiple() {
meter := meterProvider.Meter("go.opentelemetry.io/otel/metric#MultiAsyncExample") meter := meterProvider.Meter("go.opentelemetry.io/otel/metric#MultiAsyncExample")
// This is just a sample of memory stats to record from the Memstats // This is just a sample of memory stats to record from the Memstats
heapAlloc, _ := meter.AsyncInt64().UpDownCounter("heapAllocs") heapAlloc, _ := meter.Int64ObservableUpDownCounter("heapAllocs")
gcCount, _ := meter.AsyncInt64().Counter("gcCount") gcCount, _ := meter.Int64ObservableCounter("gcCount")
gcPause, _ := meter.SyncFloat64().Histogram("gcPause") gcPause, _ := meter.Float64Histogram("gcPause")
_, err := meter.RegisterCallback([]instrument.Asynchronous{ _, err := meter.RegisterCallback([]instrument.Asynchronous{
heapAlloc, heapAlloc,

View File

@ -21,20 +21,6 @@ import (
"go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument"
) )
// InstrumentProvider provides access to individual instruments.
//
// Warning: methods may be added to this interface in minor releases.
type InstrumentProvider interface {
// Counter creates an instrument for recording increasing values.
Counter(name string, opts ...instrument.Option) (Counter, error)
// UpDownCounter creates an instrument for recording changes of a value.
UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error)
// Gauge creates an instrument for recording the current value.
Gauge(name string, opts ...instrument.Option) (Gauge, error)
}
// Counter is an instrument that records increasing values. // Counter is an instrument that records increasing values.
// //
// Warning: methods may be added to this interface in minor releases. // Warning: methods may be added to this interface in minor releases.

View File

@ -21,20 +21,6 @@ import (
"go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument"
) )
// InstrumentProvider provides access to individual instruments.
//
// Warning: methods may be added to this interface in minor releases.
type InstrumentProvider interface {
// Counter creates an instrument for recording increasing values.
Counter(name string, opts ...instrument.Option) (Counter, error)
// UpDownCounter creates an instrument for recording changes of a value.
UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error)
// Gauge creates an instrument for recording the current value.
Gauge(name string, opts ...instrument.Option) (Gauge, error)
}
// Counter is an instrument that records increasing values. // Counter is an instrument that records increasing values.
// //
// Warning: methods may be added to this interface in minor releases. // Warning: methods may be added to this interface in minor releases.

View File

@ -21,18 +21,6 @@ import (
"go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument"
) )
// InstrumentProvider provides access to individual instruments.
//
// Warning: methods may be added to this interface in minor releases.
type InstrumentProvider interface {
// Counter creates an instrument for recording increasing values.
Counter(name string, opts ...instrument.Option) (Counter, error)
// UpDownCounter creates an instrument for recording changes of a value.
UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error)
// Histogram creates an instrument for recording a distribution of values.
Histogram(name string, opts ...instrument.Option) (Histogram, error)
}
// Counter is an instrument that records increasing values. // Counter is an instrument that records increasing values.
// //
// Warning: methods may be added to this interface in minor releases. // Warning: methods may be added to this interface in minor releases.

View File

@ -21,18 +21,6 @@ import (
"go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument"
) )
// InstrumentProvider provides access to individual instruments.
//
// Warning: methods may be added to this interface in minor releases.
type InstrumentProvider interface {
// Counter creates an instrument for recording increasing values.
Counter(name string, opts ...instrument.Option) (Counter, error)
// UpDownCounter creates an instrument for recording changes of a value.
UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error)
// Histogram creates an instrument for recording a distribution of values.
Histogram(name string, opts ...instrument.Option) (Histogram, error)
}
// Counter is an instrument that records increasing values. // Counter is an instrument that records increasing values.
// //
// Warning: methods may be added to this interface in minor releases. // Warning: methods may be added to this interface in minor releases.

View File

@ -38,7 +38,7 @@ type afCounter struct {
} }
func (i *afCounter) setDelegate(m metric.Meter) { func (i *afCounter) setDelegate(m metric.Meter) {
ctr, err := m.AsyncFloat64().Counter(i.name, i.opts...) ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -69,7 +69,7 @@ type afUpDownCounter struct {
} }
func (i *afUpDownCounter) setDelegate(m metric.Meter) { func (i *afUpDownCounter) setDelegate(m metric.Meter) {
ctr, err := m.AsyncFloat64().UpDownCounter(i.name, i.opts...) ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -100,7 +100,7 @@ type afGauge struct {
} }
func (i *afGauge) setDelegate(m metric.Meter) { func (i *afGauge) setDelegate(m metric.Meter) {
ctr, err := m.AsyncFloat64().Gauge(i.name, i.opts...) ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -131,7 +131,7 @@ type aiCounter struct {
} }
func (i *aiCounter) setDelegate(m metric.Meter) { func (i *aiCounter) setDelegate(m metric.Meter) {
ctr, err := m.AsyncInt64().Counter(i.name, i.opts...) ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -162,7 +162,7 @@ type aiUpDownCounter struct {
} }
func (i *aiUpDownCounter) setDelegate(m metric.Meter) { func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
ctr, err := m.AsyncInt64().UpDownCounter(i.name, i.opts...) ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -193,7 +193,7 @@ type aiGauge struct {
} }
func (i *aiGauge) setDelegate(m metric.Meter) { func (i *aiGauge) setDelegate(m metric.Meter) {
ctr, err := m.AsyncInt64().Gauge(i.name, i.opts...) ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -225,7 +225,7 @@ type sfCounter struct {
} }
func (i *sfCounter) setDelegate(m metric.Meter) { func (i *sfCounter) setDelegate(m metric.Meter) {
ctr, err := m.SyncFloat64().Counter(i.name, i.opts...) ctr, err := m.Float64Counter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -249,7 +249,7 @@ type sfUpDownCounter struct {
} }
func (i *sfUpDownCounter) setDelegate(m metric.Meter) { func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
ctr, err := m.SyncFloat64().UpDownCounter(i.name, i.opts...) ctr, err := m.Float64UpDownCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -273,7 +273,7 @@ type sfHistogram struct {
} }
func (i *sfHistogram) setDelegate(m metric.Meter) { func (i *sfHistogram) setDelegate(m metric.Meter) {
ctr, err := m.SyncFloat64().Histogram(i.name, i.opts...) ctr, err := m.Float64Histogram(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -297,7 +297,7 @@ type siCounter struct {
} }
func (i *siCounter) setDelegate(m metric.Meter) { func (i *siCounter) setDelegate(m metric.Meter) {
ctr, err := m.SyncInt64().Counter(i.name, i.opts...) ctr, err := m.Int64Counter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -321,7 +321,7 @@ type siUpDownCounter struct {
} }
func (i *siUpDownCounter) setDelegate(m metric.Meter) { func (i *siUpDownCounter) setDelegate(m metric.Meter) {
ctr, err := m.SyncInt64().UpDownCounter(i.name, i.opts...) ctr, err := m.Int64UpDownCounter(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return
@ -345,7 +345,7 @@ type siHistogram struct {
} }
func (i *siHistogram) setDelegate(m metric.Meter) { func (i *siHistogram) setDelegate(m metric.Meter) {
ctr, err := m.SyncInt64().Histogram(i.name, i.opts...) ctr, err := m.Int64Histogram(i.name, i.opts...)
if err != nil { if err != nil {
otel.Handle(err) otel.Handle(err)
return return

View File

@ -147,24 +147,136 @@ func (m *meter) setDelegate(provider metric.MeterProvider) {
m.registry.Init() m.registry.Init()
} }
// AsyncInt64 is the namespace for the Asynchronous Integer instruments. func (m *meter) Int64Counter(name string, options ...instrument.Option) (syncint64.Counter, error) {
//
// To Observe data with instruments it must be registered in a callback.
func (m *meter) AsyncInt64() asyncint64.InstrumentProvider {
if del, ok := m.delegate.Load().(metric.Meter); ok { if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.AsyncInt64() return del.Int64Counter(name, options...)
} }
return (*aiInstProvider)(m) m.mtx.Lock()
defer m.mtx.Unlock()
i := &siCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
} }
// AsyncFloat64 is the namespace for the Asynchronous Float instruments. func (m *meter) Int64UpDownCounter(name string, options ...instrument.Option) (syncint64.UpDownCounter, error) {
//
// To Observe data with instruments it must be registered in a callback.
func (m *meter) AsyncFloat64() asyncfloat64.InstrumentProvider {
if del, ok := m.delegate.Load().(metric.Meter); ok { if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.AsyncFloat64() return del.Int64UpDownCounter(name, options...)
} }
return (*afInstProvider)(m) m.mtx.Lock()
defer m.mtx.Unlock()
i := &siUpDownCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Int64Histogram(name string, options ...instrument.Option) (syncint64.Histogram, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64Histogram(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &siHistogram{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Option) (asyncint64.Counter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableCounter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &aiCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncint64.UpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableUpDownCounter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &aiUpDownCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Option) (asyncint64.Gauge, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableGauge(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &aiGauge{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64Counter(name string, options ...instrument.Option) (syncfloat64.Counter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64Counter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &sfCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Option) (syncfloat64.UpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64UpDownCounter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &sfUpDownCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64Histogram(name string, options ...instrument.Option) (syncfloat64.Histogram, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64Histogram(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &sfHistogram{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Option) (asyncfloat64.Counter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableCounter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &afCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableUpDownCounter(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &afUpDownCounter{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
}
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Option) (asyncfloat64.Gauge, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableGauge(name, options...)
}
m.mtx.Lock()
defer m.mtx.Unlock()
i := &afGauge{name: name, opts: options}
m.instruments = append(m.instruments, i)
return i, nil
} }
// RegisterCallback captures the function that will be called during Collect. // RegisterCallback captures the function that will be called during Collect.
@ -209,22 +321,6 @@ func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Async
return out return out
} }
// SyncInt64 is the namespace for the Synchronous Integer instruments.
func (m *meter) SyncInt64() syncint64.InstrumentProvider {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.SyncInt64()
}
return (*siInstProvider)(m)
}
// SyncFloat64 is the namespace for the Synchronous Float instruments.
func (m *meter) SyncFloat64() syncfloat64.InstrumentProvider {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.SyncFloat64()
}
return (*sfInstProvider)(m)
}
type registration struct { type registration struct {
instruments []instrument.Asynchronous instruments []instrument.Asynchronous
function func(context.Context) function func(context.Context)
@ -264,119 +360,3 @@ func (c *registration) Unregister() error {
err, c.unreg = c.unreg(), nil err, c.unreg = c.unreg(), nil
return err return err
} }
type afInstProvider meter
// Counter creates an instrument for recording increasing values.
func (ip *afInstProvider) Counter(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &afCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip *afInstProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &afUpDownCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// Gauge creates an instrument for recording the current value.
func (ip *afInstProvider) Gauge(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &afGauge{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
type aiInstProvider meter
// Counter creates an instrument for recording increasing values.
func (ip *aiInstProvider) Counter(name string, opts ...instrument.Option) (asyncint64.Counter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &aiCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip *aiInstProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &aiUpDownCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// Gauge creates an instrument for recording the current value.
func (ip *aiInstProvider) Gauge(name string, opts ...instrument.Option) (asyncint64.Gauge, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &aiGauge{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
type sfInstProvider meter
// Counter creates an instrument for recording increasing values.
func (ip *sfInstProvider) Counter(name string, opts ...instrument.Option) (syncfloat64.Counter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &sfCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip *sfInstProvider) UpDownCounter(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &sfUpDownCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// Histogram creates an instrument for recording a distribution of values.
func (ip *sfInstProvider) Histogram(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &sfHistogram{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
type siInstProvider meter
// Counter creates an instrument for recording increasing values.
func (ip *siInstProvider) Counter(name string, opts ...instrument.Option) (syncint64.Counter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &siCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip *siInstProvider) UpDownCounter(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &siUpDownCounter{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}
// Histogram creates an instrument for recording a distribution of values.
func (ip *siInstProvider) Histogram(name string, opts ...instrument.Option) (syncint64.Histogram, error) {
ip.mtx.Lock()
defer ip.mtx.Unlock()
ctr := &siHistogram{name: name, opts: opts}
ip.instruments = append(ip.instruments, ctr)
return ctr, nil
}

View File

@ -56,18 +56,18 @@ func TestMeterRace(t *testing.T) {
go func() { go func() {
for i, once := 0, false; ; i++ { for i, once := 0, false; ; i++ {
name := fmt.Sprintf("a%d", i) name := fmt.Sprintf("a%d", i)
_, _ = mtr.AsyncFloat64().Counter(name) _, _ = mtr.Float64ObservableCounter(name)
_, _ = mtr.AsyncFloat64().UpDownCounter(name) _, _ = mtr.Float64ObservableUpDownCounter(name)
_, _ = mtr.AsyncFloat64().Gauge(name) _, _ = mtr.Float64ObservableGauge(name)
_, _ = mtr.AsyncInt64().Counter(name) _, _ = mtr.Int64ObservableCounter(name)
_, _ = mtr.AsyncInt64().UpDownCounter(name) _, _ = mtr.Int64ObservableUpDownCounter(name)
_, _ = mtr.AsyncInt64().Gauge(name) _, _ = mtr.Int64ObservableGauge(name)
_, _ = mtr.SyncFloat64().Counter(name) _, _ = mtr.Float64Counter(name)
_, _ = mtr.SyncFloat64().UpDownCounter(name) _, _ = mtr.Float64UpDownCounter(name)
_, _ = mtr.SyncFloat64().Histogram(name) _, _ = mtr.Float64Histogram(name)
_, _ = mtr.SyncInt64().Counter(name) _, _ = mtr.Int64Counter(name)
_, _ = mtr.SyncInt64().UpDownCounter(name) _, _ = mtr.Int64UpDownCounter(name)
_, _ = mtr.SyncInt64().Histogram(name) _, _ = mtr.Int64Histogram(name)
_, _ = mtr.RegisterCallback(nil, func(ctx context.Context) {}) _, _ = mtr.RegisterCallback(nil, func(ctx context.Context) {})
if !once { if !once {
wg.Done() wg.Done()
@ -116,18 +116,18 @@ func TestUnregisterRace(t *testing.T) {
} }
func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (syncfloat64.Counter, asyncfloat64.Counter) { func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (syncfloat64.Counter, asyncfloat64.Counter) {
afcounter, err := m.AsyncFloat64().Counter("test_Async_Counter") afcounter, err := m.Float64ObservableCounter("test_Async_Counter")
require.NoError(t, err) require.NoError(t, err)
_, err = m.AsyncFloat64().UpDownCounter("test_Async_UpDownCounter") _, err = m.Float64ObservableUpDownCounter("test_Async_UpDownCounter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.AsyncFloat64().Gauge("test_Async_Gauge") _, err = m.Float64ObservableGauge("test_Async_Gauge")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.AsyncInt64().Counter("test_Async_Counter") _, err = m.Int64ObservableCounter("test_Async_Counter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.AsyncInt64().UpDownCounter("test_Async_UpDownCounter") _, err = m.Int64ObservableUpDownCounter("test_Async_UpDownCounter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.AsyncInt64().Gauge("test_Async_Gauge") _, err = m.Int64ObservableGauge("test_Async_Gauge")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{afcounter}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{afcounter}, func(ctx context.Context) {
@ -135,18 +135,18 @@ func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (syncfloat64.Coun
}) })
require.NoError(t, err) require.NoError(t, err)
sfcounter, err := m.SyncFloat64().Counter("test_Async_Counter") sfcounter, err := m.Float64Counter("test_Async_Counter")
require.NoError(t, err) require.NoError(t, err)
_, err = m.SyncFloat64().UpDownCounter("test_Async_UpDownCounter") _, err = m.Float64UpDownCounter("test_Async_UpDownCounter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.SyncFloat64().Histogram("test_Async_Histogram") _, err = m.Float64Histogram("test_Async_Histogram")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.SyncInt64().Counter("test_Async_Counter") _, err = m.Int64Counter("test_Async_Counter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.SyncInt64().UpDownCounter("test_Async_UpDownCounter") _, err = m.Int64UpDownCounter("test_Async_UpDownCounter")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.SyncInt64().Histogram("test_Async_Histogram") _, err = m.Int64Histogram("test_Async_Histogram")
assert.NoError(t, err) assert.NoError(t, err)
return sfcounter, afcounter return sfcounter, afcounter
@ -194,10 +194,18 @@ func TestMeterProviderDelegatesCalls(t *testing.T) {
// Calls to Meter() after setDelegate() should be executed by the delegate // Calls to Meter() after setDelegate() should be executed by the delegate
require.IsType(t, &testMeter{}, meter) require.IsType(t, &testMeter{}, meter)
tMeter := meter.(*testMeter) tMeter := meter.(*testMeter)
assert.Equal(t, 3, tMeter.afCount) assert.Equal(t, 1, tMeter.afCount)
assert.Equal(t, 3, tMeter.aiCount) assert.Equal(t, 1, tMeter.afUDCount)
assert.Equal(t, 3, tMeter.sfCount) assert.Equal(t, 1, tMeter.afGauge)
assert.Equal(t, 3, tMeter.siCount) assert.Equal(t, 1, tMeter.aiCount)
assert.Equal(t, 1, tMeter.aiUDCount)
assert.Equal(t, 1, tMeter.aiGauge)
assert.Equal(t, 1, tMeter.sfCount)
assert.Equal(t, 1, tMeter.sfUDCount)
assert.Equal(t, 1, tMeter.sfHist)
assert.Equal(t, 1, tMeter.siCount)
assert.Equal(t, 1, tMeter.siUDCount)
assert.Equal(t, 1, tMeter.siHist)
assert.Equal(t, 1, len(tMeter.callbacks)) assert.Equal(t, 1, len(tMeter.callbacks))
// Because the Meter was provided by testmeterProvider it should also return our test instrument // Because the Meter was provided by testmeterProvider it should also return our test instrument
@ -236,10 +244,18 @@ func TestMeterDelegatesCalls(t *testing.T) {
require.IsType(t, &meter{}, m) require.IsType(t, &meter{}, m)
tMeter := m.(*meter).delegate.Load().(*testMeter) tMeter := m.(*meter).delegate.Load().(*testMeter)
require.NotNil(t, tMeter) require.NotNil(t, tMeter)
assert.Equal(t, 3, tMeter.afCount) assert.Equal(t, 1, tMeter.afCount)
assert.Equal(t, 3, tMeter.aiCount) assert.Equal(t, 1, tMeter.afUDCount)
assert.Equal(t, 3, tMeter.sfCount) assert.Equal(t, 1, tMeter.afGauge)
assert.Equal(t, 3, tMeter.siCount) assert.Equal(t, 1, tMeter.aiCount)
assert.Equal(t, 1, tMeter.aiUDCount)
assert.Equal(t, 1, tMeter.aiGauge)
assert.Equal(t, 1, tMeter.sfCount)
assert.Equal(t, 1, tMeter.sfUDCount)
assert.Equal(t, 1, tMeter.sfHist)
assert.Equal(t, 1, tMeter.siCount)
assert.Equal(t, 1, tMeter.siUDCount)
assert.Equal(t, 1, tMeter.siHist)
// Because the Meter was provided by testmeterProvider it should also return our test instrument // Because the Meter was provided by testmeterProvider it should also return our test instrument
require.IsType(t, &testCountingFloatInstrument{}, ctr, "the meter did not delegate calls to the meter") require.IsType(t, &testCountingFloatInstrument{}, ctr, "the meter did not delegate calls to the meter")
@ -276,10 +292,18 @@ func TestMeterDefersDelegations(t *testing.T) {
require.IsType(t, &meter{}, m) require.IsType(t, &meter{}, m)
tMeter := m.(*meter).delegate.Load().(*testMeter) tMeter := m.(*meter).delegate.Load().(*testMeter)
require.NotNil(t, tMeter) require.NotNil(t, tMeter)
assert.Equal(t, 3, tMeter.afCount) assert.Equal(t, 1, tMeter.afCount)
assert.Equal(t, 3, tMeter.aiCount) assert.Equal(t, 1, tMeter.afUDCount)
assert.Equal(t, 3, tMeter.sfCount) assert.Equal(t, 1, tMeter.afGauge)
assert.Equal(t, 3, tMeter.siCount) assert.Equal(t, 1, tMeter.aiCount)
assert.Equal(t, 1, tMeter.aiUDCount)
assert.Equal(t, 1, tMeter.aiGauge)
assert.Equal(t, 1, tMeter.sfCount)
assert.Equal(t, 1, tMeter.sfUDCount)
assert.Equal(t, 1, tMeter.sfHist)
assert.Equal(t, 1, tMeter.siCount)
assert.Equal(t, 1, tMeter.siUDCount)
assert.Equal(t, 1, tMeter.siHist)
// Because the Meter was a delegate it should return a delegated instrument // Because the Meter was a delegate it should return a delegated instrument
@ -296,7 +320,7 @@ func TestRegistrationDelegation(t *testing.T) {
require.IsType(t, &meter{}, m) require.IsType(t, &meter{}, m)
mImpl := m.(*meter) mImpl := m.(*meter)
actr, err := m.AsyncFloat64().Counter("test_Async_Counter") actr, err := m.Float64ObservableCounter("test_Async_Counter")
require.NoError(t, err) require.NoError(t, err)
var called0 bool var called0 bool

View File

@ -36,28 +36,83 @@ func (p *testMeterProvider) Meter(name string, opts ...metric.MeterOption) metri
} }
type testMeter struct { type testMeter struct {
afCount int afCount int
aiCount int afUDCount int
sfCount int afGauge int
siCount int
aiCount int
aiUDCount int
aiGauge int
sfCount int
sfUDCount int
sfHist int
siCount int
siUDCount int
siHist int
callbacks []func(context.Context) callbacks []func(context.Context)
} }
// AsyncInt64 is the namespace for the Asynchronous Integer instruments. func (m *testMeter) Int64Counter(name string, options ...instrument.Option) (syncint64.Counter, error) {
// m.siCount++
// To Observe data with instruments it must be registered in a callback. return &testCountingIntInstrument{}, nil
func (m *testMeter) AsyncInt64() asyncint64.InstrumentProvider {
m.aiCount++
return &testAIInstrumentProvider{}
} }
// AsyncFloat64 is the namespace for the Asynchronous Float instruments func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Option) (syncint64.UpDownCounter, error) {
// m.siUDCount++
// To Observe data with instruments it must be registered in a callback. return &testCountingIntInstrument{}, nil
func (m *testMeter) AsyncFloat64() asyncfloat64.InstrumentProvider { }
func (m *testMeter) Int64Histogram(name string, options ...instrument.Option) (syncint64.Histogram, error) {
m.siHist++
return &testCountingIntInstrument{}, nil
}
func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Option) (asyncint64.Counter, error) {
m.aiCount++
return &testCountingIntInstrument{}, nil
}
func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncint64.UpDownCounter, error) {
m.aiUDCount++
return &testCountingIntInstrument{}, nil
}
func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Option) (asyncint64.Gauge, error) {
m.aiGauge++
return &testCountingIntInstrument{}, nil
}
func (m *testMeter) Float64Counter(name string, options ...instrument.Option) (syncfloat64.Counter, error) {
m.sfCount++
return &testCountingFloatInstrument{}, nil
}
func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Option) (syncfloat64.UpDownCounter, error) {
m.sfUDCount++
return &testCountingFloatInstrument{}, nil
}
func (m *testMeter) Float64Histogram(name string, options ...instrument.Option) (syncfloat64.Histogram, error) {
m.sfHist++
return &testCountingFloatInstrument{}, nil
}
func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Option) (asyncfloat64.Counter, error) {
m.afCount++ m.afCount++
return &testAFInstrumentProvider{} return &testCountingFloatInstrument{}, nil
}
func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
m.afUDCount++
return &testCountingFloatInstrument{}, nil
}
func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Option) (asyncfloat64.Gauge, error) {
m.afGauge++
return &testCountingFloatInstrument{}, nil
} }
// RegisterCallback captures the function that will be called during Collect. // RegisterCallback captures the function that will be called during Collect.
@ -82,18 +137,6 @@ func (r testReg) Unregister() error {
return nil return nil
} }
// SyncInt64 is the namespace for the Synchronous Integer instruments.
func (m *testMeter) SyncInt64() syncint64.InstrumentProvider {
m.siCount++
return &testSIInstrumentProvider{}
}
// SyncFloat64 is the namespace for the Synchronous Float instruments.
func (m *testMeter) SyncFloat64() syncfloat64.InstrumentProvider {
m.sfCount++
return &testSFInstrumentProvider{}
}
// This enables async collection. // This enables async collection.
func (m *testMeter) collect() { func (m *testMeter) collect() {
ctx := context.Background() ctx := context.Background()
@ -105,71 +148,3 @@ func (m *testMeter) collect() {
f(ctx) f(ctx)
} }
} }
type testAFInstrumentProvider struct{}
// Counter creates an instrument for recording increasing values.
func (ip testAFInstrumentProvider) Counter(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) {
return &testCountingFloatInstrument{}, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip testAFInstrumentProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
return &testCountingFloatInstrument{}, nil
}
// Gauge creates an instrument for recording the current value.
func (ip testAFInstrumentProvider) Gauge(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) {
return &testCountingFloatInstrument{}, nil
}
type testAIInstrumentProvider struct{}
// Counter creates an instrument for recording increasing values.
func (ip testAIInstrumentProvider) Counter(name string, opts ...instrument.Option) (asyncint64.Counter, error) {
return &testCountingIntInstrument{}, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip testAIInstrumentProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) {
return &testCountingIntInstrument{}, nil
}
// Gauge creates an instrument for recording the current value.
func (ip testAIInstrumentProvider) Gauge(name string, opts ...instrument.Option) (asyncint64.Gauge, error) {
return &testCountingIntInstrument{}, nil
}
type testSFInstrumentProvider struct{}
// Counter creates an instrument for recording increasing values.
func (ip testSFInstrumentProvider) Counter(name string, opts ...instrument.Option) (syncfloat64.Counter, error) {
return &testCountingFloatInstrument{}, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip testSFInstrumentProvider) UpDownCounter(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) {
return &testCountingFloatInstrument{}, nil
}
// Histogram creates an instrument for recording a distribution of values.
func (ip testSFInstrumentProvider) Histogram(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) {
return &testCountingFloatInstrument{}, nil
}
type testSIInstrumentProvider struct{}
// Counter creates an instrument for recording increasing values.
func (ip testSIInstrumentProvider) Counter(name string, opts ...instrument.Option) (syncint64.Counter, error) {
return &testCountingIntInstrument{}, nil
}
// UpDownCounter creates an instrument for recording changes of a value.
func (ip testSIInstrumentProvider) UpDownCounter(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) {
return &testCountingIntInstrument{}, nil
}
// Histogram creates an instrument for recording a distribution of values.
func (ip testSIInstrumentProvider) Histogram(name string, opts ...instrument.Option) (syncint64.Histogram, error) {
return &testCountingIntInstrument{}, nil
}

View File

@ -41,20 +41,59 @@ type MeterProvider interface {
// //
// Warning: methods may be added to this interface in minor releases. // Warning: methods may be added to this interface in minor releases.
type Meter interface { type Meter interface {
// AsyncInt64 is the namespace for the Asynchronous Integer instruments. // Int64Counter returns a new instrument identified by name and configured
// // with options. The instrument is used to synchronously record increasing
// To Observe data with instruments it must be registered in a callback. // int64 measurements during a computational operation.
AsyncInt64() asyncint64.InstrumentProvider Int64Counter(name string, options ...instrument.Option) (syncint64.Counter, 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.Option) (syncint64.UpDownCounter, 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.Option) (syncint64.Histogram, 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.Option) (asyncint64.Counter, 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.Option) (asyncint64.UpDownCounter, 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.Option) (asyncint64.Gauge, error)
// AsyncFloat64 is the namespace for the Asynchronous Float instruments // Float64Counter returns a new instrument identified by name and
// // configured with options. The instrument is used to synchronously record
// To Observe data with instruments it must be registered in a callback. // increasing float64 measurements during a computational operation.
AsyncFloat64() asyncfloat64.InstrumentProvider Float64Counter(name string, options ...instrument.Option) (syncfloat64.Counter, error)
// Float64UpDownCounter returns a new instrument identified by name and
// SyncInt64 is the namespace for the Synchronous Integer instruments // configured with options. The instrument is used to synchronously record
SyncInt64() syncint64.InstrumentProvider // float64 measurements during a computational operation.
// SyncFloat64 is the namespace for the Synchronous Float instruments Float64UpDownCounter(name string, options ...instrument.Option) (syncfloat64.UpDownCounter, error)
SyncFloat64() syncfloat64.InstrumentProvider // 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.Option) (syncfloat64.Histogram, 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.Option) (asyncfloat64.Counter, 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.Option) (asyncfloat64.UpDownCounter, 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.Option) (asyncfloat64.Gauge, error)
// RegisterCallback registers f to be called during the collection of a // RegisterCallback registers f to be called during the collection of a
// measurement cycle. // measurement cycle.

View File

@ -43,24 +43,52 @@ func NewNoopMeter() Meter {
type noopMeter struct{} type noopMeter struct{}
// AsyncInt64 creates an instrument that does not record any metrics. func (noopMeter) Int64Counter(string, ...instrument.Option) (syncint64.Counter, error) {
func (noopMeter) AsyncInt64() asyncint64.InstrumentProvider { return nonrecordingSyncInt64Instrument{}, nil
return nonrecordingAsyncInt64Instrument{}
} }
// AsyncFloat64 creates an instrument that does not record any metrics. func (noopMeter) Int64UpDownCounter(string, ...instrument.Option) (syncint64.UpDownCounter, error) {
func (noopMeter) AsyncFloat64() asyncfloat64.InstrumentProvider { return nonrecordingSyncInt64Instrument{}, nil
return nonrecordingAsyncFloat64Instrument{}
} }
// SyncInt64 creates an instrument that does not record any metrics. func (noopMeter) Int64Histogram(string, ...instrument.Option) (syncint64.Histogram, error) {
func (noopMeter) SyncInt64() syncint64.InstrumentProvider { return nonrecordingSyncInt64Instrument{}, nil
return nonrecordingSyncInt64Instrument{}
} }
// SyncFloat64 creates an instrument that does not record any metrics. func (noopMeter) Int64ObservableCounter(string, ...instrument.Option) (asyncint64.Counter, error) {
func (noopMeter) SyncFloat64() syncfloat64.InstrumentProvider { return nonrecordingAsyncInt64Instrument{}, nil
return nonrecordingSyncFloat64Instrument{} }
func (noopMeter) Int64ObservableUpDownCounter(string, ...instrument.Option) (asyncint64.UpDownCounter, error) {
return nonrecordingAsyncInt64Instrument{}, nil
}
func (noopMeter) Int64ObservableGauge(string, ...instrument.Option) (asyncint64.Gauge, error) {
return nonrecordingAsyncInt64Instrument{}, nil
}
func (noopMeter) Float64Counter(string, ...instrument.Option) (syncfloat64.Counter, error) {
return nonrecordingSyncFloat64Instrument{}, nil
}
func (noopMeter) Float64UpDownCounter(string, ...instrument.Option) (syncfloat64.UpDownCounter, error) {
return nonrecordingSyncFloat64Instrument{}, nil
}
func (noopMeter) Float64Histogram(string, ...instrument.Option) (syncfloat64.Histogram, error) {
return nonrecordingSyncFloat64Instrument{}, nil
}
func (noopMeter) Float64ObservableCounter(string, ...instrument.Option) (asyncfloat64.Counter, error) {
return nonrecordingAsyncFloat64Instrument{}, nil
}
func (noopMeter) Float64ObservableUpDownCounter(string, ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
return nonrecordingAsyncFloat64Instrument{}, nil
}
func (noopMeter) Float64ObservableGauge(string, ...instrument.Option) (asyncfloat64.Gauge, error) {
return nonrecordingAsyncFloat64Instrument{}, nil
} }
// RegisterCallback creates a register callback that does not record any metrics. // RegisterCallback creates a register callback that does not record any metrics.
@ -77,10 +105,9 @@ type nonrecordingAsyncFloat64Instrument struct {
} }
var ( var (
_ asyncfloat64.InstrumentProvider = nonrecordingAsyncFloat64Instrument{} _ asyncfloat64.Counter = nonrecordingAsyncFloat64Instrument{}
_ asyncfloat64.Counter = nonrecordingAsyncFloat64Instrument{} _ asyncfloat64.UpDownCounter = nonrecordingAsyncFloat64Instrument{}
_ asyncfloat64.UpDownCounter = nonrecordingAsyncFloat64Instrument{} _ asyncfloat64.Gauge = nonrecordingAsyncFloat64Instrument{}
_ asyncfloat64.Gauge = nonrecordingAsyncFloat64Instrument{}
) )
func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Option) (asyncfloat64.Counter, error) { func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Option) (asyncfloat64.Counter, error) {
@ -104,10 +131,9 @@ type nonrecordingAsyncInt64Instrument struct {
} }
var ( var (
_ asyncint64.InstrumentProvider = nonrecordingAsyncInt64Instrument{} _ asyncint64.Counter = nonrecordingAsyncInt64Instrument{}
_ asyncint64.Counter = nonrecordingAsyncInt64Instrument{} _ asyncint64.UpDownCounter = nonrecordingAsyncInt64Instrument{}
_ asyncint64.UpDownCounter = nonrecordingAsyncInt64Instrument{} _ asyncint64.Gauge = nonrecordingAsyncInt64Instrument{}
_ asyncint64.Gauge = nonrecordingAsyncInt64Instrument{}
) )
func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Option) (asyncint64.Counter, error) { func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Option) (asyncint64.Counter, error) {
@ -130,10 +156,9 @@ type nonrecordingSyncFloat64Instrument struct {
} }
var ( var (
_ syncfloat64.InstrumentProvider = nonrecordingSyncFloat64Instrument{} _ syncfloat64.Counter = nonrecordingSyncFloat64Instrument{}
_ syncfloat64.Counter = nonrecordingSyncFloat64Instrument{} _ syncfloat64.UpDownCounter = nonrecordingSyncFloat64Instrument{}
_ syncfloat64.UpDownCounter = nonrecordingSyncFloat64Instrument{} _ syncfloat64.Histogram = nonrecordingSyncFloat64Instrument{}
_ syncfloat64.Histogram = nonrecordingSyncFloat64Instrument{}
) )
func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Option) (syncfloat64.Counter, error) { func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Option) (syncfloat64.Counter, error) {
@ -161,10 +186,9 @@ type nonrecordingSyncInt64Instrument struct {
} }
var ( var (
_ syncint64.InstrumentProvider = nonrecordingSyncInt64Instrument{} _ syncint64.Counter = nonrecordingSyncInt64Instrument{}
_ syncint64.Counter = nonrecordingSyncInt64Instrument{} _ syncint64.UpDownCounter = nonrecordingSyncInt64Instrument{}
_ syncint64.UpDownCounter = nonrecordingSyncInt64Instrument{} _ syncint64.Histogram = nonrecordingSyncInt64Instrument{}
_ syncint64.Histogram = nonrecordingSyncInt64Instrument{}
) )
func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Option) (syncint64.Counter, error) { func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Option) (syncint64.Counter, error) {

View File

@ -34,19 +34,19 @@ func TestNewNoopMeterProvider(t *testing.T) {
func TestSyncFloat64(t *testing.T) { func TestSyncFloat64(t *testing.T) {
meter := NewNoopMeterProvider().Meter("test instrumentation") meter := NewNoopMeterProvider().Meter("test instrumentation")
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncFloat64().Counter("test instrument") inst, err := meter.Float64Counter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Add(context.Background(), 1.0, attribute.String("key", "value")) inst.Add(context.Background(), 1.0, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncFloat64().UpDownCounter("test instrument") inst, err := meter.Float64UpDownCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Add(context.Background(), -1.0, attribute.String("key", "value")) inst.Add(context.Background(), -1.0, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncFloat64().Histogram("test instrument") inst, err := meter.Float64Histogram("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Record(context.Background(), 1.0, attribute.String("key", "value")) inst.Record(context.Background(), 1.0, attribute.String("key", "value"))
}) })
@ -55,19 +55,19 @@ func TestSyncFloat64(t *testing.T) {
func TestSyncInt64(t *testing.T) { func TestSyncInt64(t *testing.T) {
meter := NewNoopMeterProvider().Meter("test instrumentation") meter := NewNoopMeterProvider().Meter("test instrumentation")
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncInt64().Counter("test instrument") inst, err := meter.Int64Counter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Add(context.Background(), 1, attribute.String("key", "value")) inst.Add(context.Background(), 1, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncInt64().UpDownCounter("test instrument") inst, err := meter.Int64UpDownCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Add(context.Background(), -1, attribute.String("key", "value")) inst.Add(context.Background(), -1, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.SyncInt64().Histogram("test instrument") inst, err := meter.Int64Histogram("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Record(context.Background(), 1, attribute.String("key", "value")) inst.Record(context.Background(), 1, attribute.String("key", "value"))
}) })
@ -76,19 +76,19 @@ func TestSyncInt64(t *testing.T) {
func TestAsyncFloat64(t *testing.T) { func TestAsyncFloat64(t *testing.T) {
meter := NewNoopMeterProvider().Meter("test instrumentation") meter := NewNoopMeterProvider().Meter("test instrumentation")
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncFloat64().Counter("test instrument") inst, err := meter.Float64ObservableCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), 1.0, attribute.String("key", "value")) inst.Observe(context.Background(), 1.0, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncFloat64().UpDownCounter("test instrument") inst, err := meter.Float64ObservableUpDownCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), -1.0, attribute.String("key", "value")) inst.Observe(context.Background(), -1.0, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncFloat64().Gauge("test instrument") inst, err := meter.Float64ObservableGauge("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), 1.0, attribute.String("key", "value")) inst.Observe(context.Background(), 1.0, attribute.String("key", "value"))
}) })
@ -97,19 +97,19 @@ func TestAsyncFloat64(t *testing.T) {
func TestAsyncInt64(t *testing.T) { func TestAsyncInt64(t *testing.T) {
meter := NewNoopMeterProvider().Meter("test instrumentation") meter := NewNoopMeterProvider().Meter("test instrumentation")
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncInt64().Counter("test instrument") inst, err := meter.Int64ObservableCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), 1, attribute.String("key", "value")) inst.Observe(context.Background(), 1, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncInt64().UpDownCounter("test instrument") inst, err := meter.Int64ObservableUpDownCounter("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), -1, attribute.String("key", "value")) inst.Observe(context.Background(), -1, attribute.String("key", "value"))
}) })
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
inst, err := meter.AsyncInt64().Gauge("test instrument") inst, err := meter.Int64ObservableGauge("test instrument")
require.NoError(t, err) require.NoError(t, err)
inst.Observe(context.Background(), 1, attribute.String("key", "value")) inst.Observe(context.Background(), 1, attribute.String("key", "value"))
}) })

View File

@ -26,7 +26,7 @@ func benchCounter(b *testing.B, views ...View) (context.Context, Reader, syncint
ctx := context.Background() ctx := context.Background()
rdr := NewManualReader() rdr := NewManualReader()
provider := NewMeterProvider(WithReader(rdr), WithView(views...)) provider := NewMeterProvider(WithReader(rdr), WithView(views...))
cntr, _ := provider.Meter("test").SyncInt64().Counter("hello") cntr, _ := provider.Meter("test").Int64Counter("hello")
b.ResetTimer() b.ResetTimer()
b.ReportAllocs() b.ReportAllocs()
return ctx, rdr, cntr return ctx, rdr, cntr

View File

@ -1,132 +0,0 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package metric // import "go.opentelemetry.io/otel/sdk/metric"
import (
"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"
)
// instProvider provides all OpenTelemetry instruments.
type instProvider[N int64 | float64] struct {
scope instrumentation.Scope
resolve resolver[N]
}
func newInstProvider[N int64 | float64](s instrumentation.Scope, p pipelines, c instrumentCache[N]) *instProvider[N] {
return &instProvider[N]{scope: s, resolve: newResolver(p, c)}
}
// lookup returns the resolved instrumentImpl.
func (p *instProvider[N]) lookup(kind InstrumentKind, name string, opts []instrument.Option) (*instrumentImpl[N], error) {
cfg := instrument.NewConfig(opts...)
i := Instrument{
Name: name,
Description: cfg.Description(),
Unit: cfg.Unit(),
Kind: kind,
Scope: p.scope,
}
aggs, err := p.resolve.Aggregators(i)
return &instrumentImpl[N]{aggregators: aggs}, err
}
type asyncInt64Provider struct {
*instProvider[int64]
}
var _ asyncint64.InstrumentProvider = asyncInt64Provider{}
// Counter creates an instrument for recording increasing values.
func (p asyncInt64Provider) Counter(name string, opts ...instrument.Option) (asyncint64.Counter, error) {
return p.lookup(InstrumentKindAsyncCounter, name, opts)
}
// UpDownCounter creates an instrument for recording changes of a value.
func (p asyncInt64Provider) UpDownCounter(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) {
return p.lookup(InstrumentKindAsyncUpDownCounter, name, opts)
}
// Gauge creates an instrument for recording the current value.
func (p asyncInt64Provider) Gauge(name string, opts ...instrument.Option) (asyncint64.Gauge, error) {
return p.lookup(InstrumentKindAsyncGauge, name, opts)
}
type asyncFloat64Provider struct {
*instProvider[float64]
}
var _ asyncfloat64.InstrumentProvider = asyncFloat64Provider{}
// Counter creates an instrument for recording increasing values.
func (p asyncFloat64Provider) Counter(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) {
return p.lookup(InstrumentKindAsyncCounter, name, opts)
}
// UpDownCounter creates an instrument for recording changes of a value.
func (p asyncFloat64Provider) UpDownCounter(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
return p.lookup(InstrumentKindAsyncUpDownCounter, name, opts)
}
// Gauge creates an instrument for recording the current value.
func (p asyncFloat64Provider) Gauge(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) {
return p.lookup(InstrumentKindAsyncGauge, name, opts)
}
type syncInt64Provider struct {
*instProvider[int64]
}
var _ syncint64.InstrumentProvider = syncInt64Provider{}
// Counter creates an instrument for recording increasing values.
func (p syncInt64Provider) Counter(name string, opts ...instrument.Option) (syncint64.Counter, error) {
return p.lookup(InstrumentKindSyncCounter, name, opts)
}
// UpDownCounter creates an instrument for recording changes of a value.
func (p syncInt64Provider) UpDownCounter(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) {
return p.lookup(InstrumentKindSyncUpDownCounter, name, opts)
}
// Histogram creates an instrument for recording the current value.
func (p syncInt64Provider) Histogram(name string, opts ...instrument.Option) (syncint64.Histogram, error) {
return p.lookup(InstrumentKindSyncHistogram, name, opts)
}
type syncFloat64Provider struct {
*instProvider[float64]
}
var _ syncfloat64.InstrumentProvider = syncFloat64Provider{}
// Counter creates an instrument for recording increasing values.
func (p syncFloat64Provider) Counter(name string, opts ...instrument.Option) (syncfloat64.Counter, error) {
return p.lookup(InstrumentKindSyncCounter, name, opts)
}
// UpDownCounter creates an instrument for recording changes of a value.
func (p syncFloat64Provider) UpDownCounter(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) {
return p.lookup(InstrumentKindSyncUpDownCounter, name, opts)
}
// Histogram creates an instrument for recording the current value.
func (p syncFloat64Provider) Histogram(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) {
return p.lookup(InstrumentKindSyncHistogram, name, opts)
}

View File

@ -31,19 +31,11 @@ type meter struct {
aggregations []metricdata.Aggregation aggregations []metricdata.Aggregation
} }
func (m *meter) SyncInt64() syncint64.InstrumentProvider { func (p *meter) Int64Counter(string, ...instrument.Option) (syncint64.Counter, error) {
// The same would be done for all the other instrument providers. // This is an example of how a meter would create an aggregator for a new
return (*syncInt64Provider)(m) // counter. At this point the provider would determine the aggregation and
} // temporality to used based on the Reader and View configuration. Assume
// here these are determined to be a cumulative sum.
type syncInt64Provider meter
func (p *syncInt64Provider) Counter(string, ...instrument.Option) (syncint64.Counter, error) {
// This is an example of how a synchronous int64 provider 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 here these are determined to be a
// cumulative sum.
aggregator := NewCumulativeSum[int64](true) aggregator := NewCumulativeSum[int64](true)
count := inst{aggregateFunc: aggregator.Aggregate} count := inst{aggregateFunc: aggregator.Aggregate}
@ -55,13 +47,12 @@ func (p *syncInt64Provider) Counter(string, ...instrument.Option) (syncint64.Cou
return count, nil return count, nil
} }
func (p *syncInt64Provider) UpDownCounter(string, ...instrument.Option) (syncint64.UpDownCounter, error) { func (p *meter) Int64UpDownCounter(string, ...instrument.Option) (syncint64.UpDownCounter, error) {
// This is an example of how a synchronous int64 provider would create an // This is an example of how a meter would create an aggregator for a new
// aggregator for a new up-down counter. At this point the provider would // up-down counter. At this point the provider would determine the
// determine the aggregation and temporality to used based on the Reader // aggregation and temporality to used based on the Reader and View
// and View configuration. Assume here these are determined to be a // configuration. Assume here these are determined to be a last-value
// last-value aggregation (the temporality does not affect the produced // aggregation (the temporality does not affect the produced aggregations).
// aggregations).
aggregator := NewLastValue[int64]() aggregator := NewLastValue[int64]()
upDownCount := inst{aggregateFunc: aggregator.Aggregate} upDownCount := inst{aggregateFunc: aggregator.Aggregate}
@ -73,12 +64,12 @@ func (p *syncInt64Provider) UpDownCounter(string, ...instrument.Option) (syncint
return upDownCount, nil return upDownCount, nil
} }
func (p *syncInt64Provider) Histogram(string, ...instrument.Option) (syncint64.Histogram, error) { func (p *meter) Int64Histogram(string, ...instrument.Option) (syncint64.Histogram, error) {
// This is an example of how a synchronous int64 provider would create an // This is an example of how a meter would create an aggregator for a new
// aggregator for a new histogram. At this point the provider would // histogram. At this point the provider would determine the aggregation
// determine the aggregation and temporality to used based on the Reader // and temporality to used based on the Reader and View configuration.
// and View configuration. Assume here these are determined to be a delta // Assume here these are determined to be a delta explicit-bucket
// explicit-bucket histogram. // histogram.
aggregator := NewDeltaHistogram[int64](aggregation.ExplicitBucketHistogram{ aggregator := NewDeltaHistogram[int64](aggregation.ExplicitBucketHistogram{
Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 1000}, Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 1000},
@ -106,11 +97,10 @@ func (inst) Record(context.Context, int64, ...attribute.KeyValue) {}
func Example() { func Example() {
m := meter{} m := meter{}
provider := m.SyncInt64()
_, _ = provider.Counter("counter example") _, _ = m.Int64Counter("counter example")
_, _ = provider.UpDownCounter("up-down counter example") _, _ = m.Int64UpDownCounter("up-down counter example")
_, _ = provider.Histogram("histogram example") _, _ = m.Int64Histogram("histogram example")
// Output: // Output:
// using *internal.cumulativeSum[int64] aggregator for counter // using *internal.cumulativeSum[int64] aggregator for counter

View File

@ -57,14 +57,88 @@ func newMeter(s instrumentation.Scope, p pipelines) *meter {
// Compile-time check meter implements metric.Meter. // Compile-time check meter implements metric.Meter.
var _ metric.Meter = (*meter)(nil) var _ metric.Meter = (*meter)(nil)
// AsyncInt64 returns the asynchronous integer instrument provider. // Int64Counter returns a new instrument identified by name and configured with
func (m *meter) AsyncInt64() asyncint64.InstrumentProvider { // options. The instrument is used to synchronously record increasing int64
return asyncInt64Provider{m.instProviderInt64} // measurements during a computational operation.
func (m *meter) Int64Counter(name string, options ...instrument.Option) (syncint64.Counter, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncCounter, name, options)
} }
// AsyncFloat64 returns the asynchronous floating-point instrument provider. // Int64UpDownCounter returns a new instrument identified by name and
func (m *meter) AsyncFloat64() asyncfloat64.InstrumentProvider { // configured with options. The instrument is used to synchronously record
return asyncFloat64Provider{m.instProviderFloat64} // int64 measurements during a computational operation.
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Option) (syncint64.UpDownCounter, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncUpDownCounter, name, options)
}
// 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.Option) (syncint64.Histogram, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncHistogram, name, options)
}
// 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.Option) (asyncint64.Counter, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncCounter, name, options)
}
// 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.Option) (asyncint64.UpDownCounter, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncUpDownCounter, name, options)
}
// 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.Option) (asyncint64.Gauge, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncGauge, name, options)
}
// 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.Option) (syncfloat64.Counter, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncCounter, name, options)
}
// 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.Option) (syncfloat64.UpDownCounter, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncUpDownCounter, name, options)
}
// 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.Option) (syncfloat64.Histogram, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncHistogram, name, options)
}
// 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.Option) (asyncfloat64.Counter, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncCounter, name, options)
}
// 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.Option) (asyncfloat64.UpDownCounter, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncUpDownCounter, name, options)
}
// 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.Option) (asyncfloat64.Gauge, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncGauge, name, options)
} }
// RegisterCallback registers the function f to be called when any of the // RegisterCallback registers the function f to be called when any of the
@ -106,12 +180,26 @@ func (m *meter) registerCallback(c callback) (metric.Registration, error) {
return m.pipes.registerCallback(c), nil return m.pipes.registerCallback(c), nil
} }
// SyncInt64 returns the synchronous integer instrument provider. // instProvider provides all OpenTelemetry instruments.
func (m *meter) SyncInt64() syncint64.InstrumentProvider { type instProvider[N int64 | float64] struct {
return syncInt64Provider{m.instProviderInt64} scope instrumentation.Scope
resolve resolver[N]
} }
// SyncFloat64 returns the synchronous floating-point instrument provider. func newInstProvider[N int64 | float64](s instrumentation.Scope, p pipelines, c instrumentCache[N]) *instProvider[N] {
func (m *meter) SyncFloat64() syncfloat64.InstrumentProvider { return &instProvider[N]{scope: s, resolve: newResolver(p, c)}
return syncFloat64Provider{m.instProviderFloat64} }
// lookup returns the resolved instrumentImpl.
func (p *instProvider[N]) lookup(kind InstrumentKind, name string, opts []instrument.Option) (*instrumentImpl[N], error) {
cfg := instrument.NewConfig(opts...)
i := Instrument{
Name: name,
Description: cfg.Description(),
Unit: cfg.Unit(),
Kind: kind,
Scope: p.scope,
}
aggs, err := p.resolve.Aggregators(i)
return &instrumentImpl[N]{aggregators: aggs}, err
} }

View File

@ -44,51 +44,51 @@ func TestMeterInstrumentConcurrency(t *testing.T) {
m := NewMeterProvider().Meter("inst-concurrency") m := NewMeterProvider().Meter("inst-concurrency")
go func() { go func() {
_, _ = m.AsyncFloat64().Counter("AFCounter") _, _ = m.Float64ObservableCounter("AFCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.AsyncFloat64().UpDownCounter("AFUpDownCounter") _, _ = m.Float64ObservableUpDownCounter("AFUpDownCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.AsyncFloat64().Gauge("AFGauge") _, _ = m.Float64ObservableGauge("AFGauge")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.AsyncInt64().Counter("AICounter") _, _ = m.Int64ObservableCounter("AICounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.AsyncInt64().UpDownCounter("AIUpDownCounter") _, _ = m.Int64ObservableUpDownCounter("AIUpDownCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.AsyncInt64().Gauge("AIGauge") _, _ = m.Int64ObservableGauge("AIGauge")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncFloat64().Counter("SFCounter") _, _ = m.Float64Counter("SFCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncFloat64().UpDownCounter("SFUpDownCounter") _, _ = m.Float64UpDownCounter("SFUpDownCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncFloat64().Histogram("SFHistogram") _, _ = m.Float64Histogram("SFHistogram")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncInt64().Counter("SICounter") _, _ = m.Int64Counter("SICounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncInt64().UpDownCounter("SIUpDownCounter") _, _ = m.Int64UpDownCounter("SIUpDownCounter")
wg.Done() wg.Done()
}() }()
go func() { go func() {
_, _ = m.SyncInt64().Histogram("SIHistogram") _, _ = m.Int64Histogram("SIHistogram")
wg.Done() wg.Done()
}() }()
@ -136,10 +136,10 @@ func TestCallbackUnregisterConcurrency(t *testing.T) {
provider := NewMeterProvider(WithReader(reader)) provider := NewMeterProvider(WithReader(reader))
meter := provider.Meter("unregister-concurrency") meter := provider.Meter("unregister-concurrency")
actr, err := meter.AsyncFloat64().Counter("counter") actr, err := meter.Float64ObservableCounter("counter")
require.NoError(t, err) require.NoError(t, err)
ag, err := meter.AsyncInt64().Gauge("gauge") ag, err := meter.Int64ObservableGauge("gauge")
require.NoError(t, err) require.NoError(t, err)
i := []instrument.Asynchronous{actr} i := []instrument.Asynchronous{actr}
@ -176,7 +176,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncInt64Count", name: "AsyncInt64Count",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.AsyncInt64().Counter("aint") ctr, err := m.Int64ObservableCounter("aint")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) {
ctr.Observe(ctx, 3) ctr.Observe(ctx, 3)
@ -200,7 +200,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncInt64UpDownCount", name: "AsyncInt64UpDownCount",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.AsyncInt64().UpDownCounter("aint") ctr, err := m.Int64ObservableUpDownCounter("aint")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) {
ctr.Observe(ctx, 11) ctr.Observe(ctx, 11)
@ -224,7 +224,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncInt64Gauge", name: "AsyncInt64Gauge",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.AsyncInt64().Gauge("agauge") gauge, err := m.Int64ObservableGauge("agauge")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{gauge}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{gauge}, func(ctx context.Context) {
gauge.Observe(ctx, 11) gauge.Observe(ctx, 11)
@ -246,7 +246,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncFloat64Count", name: "AsyncFloat64Count",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.AsyncFloat64().Counter("afloat") ctr, err := m.Float64ObservableCounter("afloat")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) {
ctr.Observe(ctx, 3) ctr.Observe(ctx, 3)
@ -270,7 +270,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncFloat64UpDownCount", name: "AsyncFloat64UpDownCount",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.AsyncFloat64().UpDownCounter("afloat") ctr, err := m.Float64ObservableUpDownCounter("afloat")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{ctr}, func(ctx context.Context) {
ctr.Observe(ctx, 11) ctr.Observe(ctx, 11)
@ -294,7 +294,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "AsyncFloat64Gauge", name: "AsyncFloat64Gauge",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.AsyncFloat64().Gauge("agauge") gauge, err := m.Float64ObservableGauge("agauge")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m.RegisterCallback([]instrument.Asynchronous{gauge}, func(ctx context.Context) { _, err = m.RegisterCallback([]instrument.Asynchronous{gauge}, func(ctx context.Context) {
gauge.Observe(ctx, 11) gauge.Observe(ctx, 11)
@ -317,7 +317,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncInt64Count", name: "SyncInt64Count",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.SyncInt64().Counter("sint") ctr, err := m.Int64Counter("sint")
assert.NoError(t, err) assert.NoError(t, err)
ctr.Add(context.Background(), 3) ctr.Add(context.Background(), 3)
@ -336,7 +336,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncInt64UpDownCount", name: "SyncInt64UpDownCount",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.SyncInt64().UpDownCounter("sint") ctr, err := m.Int64UpDownCounter("sint")
assert.NoError(t, err) assert.NoError(t, err)
ctr.Add(context.Background(), 11) ctr.Add(context.Background(), 11)
@ -355,7 +355,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncInt64Histogram", name: "SyncInt64Histogram",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.SyncInt64().Histogram("histogram") gauge, err := m.Int64Histogram("histogram")
assert.NoError(t, err) assert.NoError(t, err)
gauge.Record(context.Background(), 7) gauge.Record(context.Background(), 7)
@ -381,7 +381,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncFloat64Count", name: "SyncFloat64Count",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.SyncFloat64().Counter("sfloat") ctr, err := m.Float64Counter("sfloat")
assert.NoError(t, err) assert.NoError(t, err)
ctr.Add(context.Background(), 3) ctr.Add(context.Background(), 3)
@ -400,7 +400,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncFloat64UpDownCount", name: "SyncFloat64UpDownCount",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.SyncFloat64().UpDownCounter("sfloat") ctr, err := m.Float64UpDownCounter("sfloat")
assert.NoError(t, err) assert.NoError(t, err)
ctr.Add(context.Background(), 11) ctr.Add(context.Background(), 11)
@ -419,7 +419,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
{ {
name: "SyncFloat64Histogram", name: "SyncFloat64Histogram",
fn: func(t *testing.T, m metric.Meter) { fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.SyncFloat64().Histogram("histogram") gauge, err := m.Float64Histogram("histogram")
assert.NoError(t, err) assert.NoError(t, err)
gauge.Record(context.Background(), 7) gauge.Record(context.Background(), 7)
@ -468,7 +468,7 @@ func TestMetersProvideScope(t *testing.T) {
mp := NewMeterProvider(WithReader(rdr)) mp := NewMeterProvider(WithReader(rdr))
m1 := mp.Meter("scope1") m1 := mp.Meter("scope1")
ctr1, err := m1.AsyncFloat64().Counter("ctr1") ctr1, err := m1.Float64ObservableCounter("ctr1")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m1.RegisterCallback([]instrument.Asynchronous{ctr1}, func(ctx context.Context) { _, err = m1.RegisterCallback([]instrument.Asynchronous{ctr1}, func(ctx context.Context) {
ctr1.Observe(ctx, 5) ctr1.Observe(ctx, 5)
@ -476,7 +476,7 @@ func TestMetersProvideScope(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
m2 := mp.Meter("scope2") m2 := mp.Meter("scope2")
ctr2, err := m2.AsyncInt64().Counter("ctr2") ctr2, err := m2.Int64ObservableCounter("ctr2")
assert.NoError(t, err) assert.NoError(t, err)
_, err = m1.RegisterCallback([]instrument.Asynchronous{ctr2}, func(ctx context.Context) { _, err = m1.RegisterCallback([]instrument.Asynchronous{ctr2}, func(ctx context.Context) {
ctr2.Observe(ctx, 7) ctr2.Observe(ctx, 7)
@ -537,22 +537,22 @@ func TestUnregisterUnregisters(t *testing.T) {
mp := NewMeterProvider(WithReader(r)) mp := NewMeterProvider(WithReader(r))
m := mp.Meter("TestUnregisterUnregisters") m := mp.Meter("TestUnregisterUnregisters")
int64Counter, err := m.AsyncInt64().Counter("int64.counter") int64Counter, err := m.Int64ObservableCounter("int64.counter")
require.NoError(t, err) require.NoError(t, err)
int64UpDownCounter, err := m.AsyncInt64().UpDownCounter("int64.up_down_counter") int64UpDownCounter, err := m.Int64ObservableUpDownCounter("int64.up_down_counter")
require.NoError(t, err) require.NoError(t, err)
int64Gauge, err := m.AsyncInt64().Gauge("int64.gauge") int64Gauge, err := m.Int64ObservableGauge("int64.gauge")
require.NoError(t, err) require.NoError(t, err)
floag64Counter, err := m.AsyncFloat64().Counter("floag64.counter") floag64Counter, err := m.Float64ObservableCounter("floag64.counter")
require.NoError(t, err) require.NoError(t, err)
floag64UpDownCounter, err := m.AsyncFloat64().UpDownCounter("floag64.up_down_counter") floag64UpDownCounter, err := m.Float64ObservableUpDownCounter("floag64.up_down_counter")
require.NoError(t, err) require.NoError(t, err)
floag64Gauge, err := m.AsyncFloat64().Gauge("floag64.gauge") floag64Gauge, err := m.Float64ObservableGauge("floag64.gauge")
require.NoError(t, err) require.NoError(t, err)
var called bool var called bool
@ -587,22 +587,22 @@ func TestRegisterCallbackDropAggregations(t *testing.T) {
mp := NewMeterProvider(WithReader(r)) mp := NewMeterProvider(WithReader(r))
m := mp.Meter("testRegisterCallbackDropAggregations") m := mp.Meter("testRegisterCallbackDropAggregations")
int64Counter, err := m.AsyncInt64().Counter("int64.counter") int64Counter, err := m.Int64ObservableCounter("int64.counter")
require.NoError(t, err) require.NoError(t, err)
int64UpDownCounter, err := m.AsyncInt64().UpDownCounter("int64.up_down_counter") int64UpDownCounter, err := m.Int64ObservableUpDownCounter("int64.up_down_counter")
require.NoError(t, err) require.NoError(t, err)
int64Gauge, err := m.AsyncInt64().Gauge("int64.gauge") int64Gauge, err := m.Int64ObservableGauge("int64.gauge")
require.NoError(t, err) require.NoError(t, err)
floag64Counter, err := m.AsyncFloat64().Counter("floag64.counter") floag64Counter, err := m.Float64ObservableCounter("floag64.counter")
require.NoError(t, err) require.NoError(t, err)
floag64UpDownCounter, err := m.AsyncFloat64().UpDownCounter("floag64.up_down_counter") floag64UpDownCounter, err := m.Float64ObservableUpDownCounter("floag64.up_down_counter")
require.NoError(t, err) require.NoError(t, err)
floag64Gauge, err := m.AsyncFloat64().Gauge("floag64.gauge") floag64Gauge, err := m.Float64ObservableGauge("floag64.gauge")
require.NoError(t, err) require.NoError(t, err)
var called bool var called bool
@ -634,7 +634,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncFloat64Counter", name: "AsyncFloat64Counter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncFloat64().Counter("afcounter") ctr, err := mtr.Float64ObservableCounter("afcounter")
if err != nil { if err != nil {
return err return err
} }
@ -661,7 +661,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncFloat64UpDownCounter", name: "AsyncFloat64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncFloat64().UpDownCounter("afupdowncounter") ctr, err := mtr.Float64ObservableUpDownCounter("afupdowncounter")
if err != nil { if err != nil {
return err return err
} }
@ -688,7 +688,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncFloat64Gauge", name: "AsyncFloat64Gauge",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncFloat64().Gauge("afgauge") ctr, err := mtr.Float64ObservableGauge("afgauge")
if err != nil { if err != nil {
return err return err
} }
@ -713,7 +713,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncInt64Counter", name: "AsyncInt64Counter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncInt64().Counter("aicounter") ctr, err := mtr.Int64ObservableCounter("aicounter")
if err != nil { if err != nil {
return err return err
} }
@ -740,7 +740,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncInt64UpDownCounter", name: "AsyncInt64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncInt64().UpDownCounter("aiupdowncounter") ctr, err := mtr.Int64ObservableUpDownCounter("aiupdowncounter")
if err != nil { if err != nil {
return err return err
} }
@ -767,7 +767,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "AsyncInt64Gauge", name: "AsyncInt64Gauge",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.AsyncInt64().Gauge("aigauge") ctr, err := mtr.Int64ObservableGauge("aigauge")
if err != nil { if err != nil {
return err return err
} }
@ -792,7 +792,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncFloat64Counter", name: "SyncFloat64Counter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncFloat64().Counter("sfcounter") ctr, err := mtr.Float64Counter("sfcounter")
if err != nil { if err != nil {
return err return err
} }
@ -818,7 +818,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncFloat64UpDownCounter", name: "SyncFloat64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncFloat64().UpDownCounter("sfupdowncounter") ctr, err := mtr.Float64UpDownCounter("sfupdowncounter")
if err != nil { if err != nil {
return err return err
} }
@ -844,7 +844,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncFloat64Histogram", name: "SyncFloat64Histogram",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncFloat64().Histogram("sfhistogram") ctr, err := mtr.Float64Histogram("sfhistogram")
if err != nil { if err != nil {
return err return err
} }
@ -874,7 +874,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncInt64Counter", name: "SyncInt64Counter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncInt64().Counter("sicounter") ctr, err := mtr.Int64Counter("sicounter")
if err != nil { if err != nil {
return err return err
} }
@ -900,7 +900,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncInt64UpDownCounter", name: "SyncInt64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncInt64().UpDownCounter("siupdowncounter") ctr, err := mtr.Int64UpDownCounter("siupdowncounter")
if err != nil { if err != nil {
return err return err
} }
@ -926,7 +926,7 @@ func TestAttributeFilter(t *testing.T) {
{ {
name: "SyncInt64Histogram", name: "SyncInt64Histogram",
register: func(t *testing.T, mtr metric.Meter) error { register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.SyncInt64().Histogram("sihistogram") ctr, err := mtr.Int64Histogram("sihistogram")
if err != nil { if err != nil {
return err return err
} }
@ -1006,20 +1006,20 @@ func BenchmarkInstrumentCreation(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {
aiCounter, _ = meter.AsyncInt64().Counter("async.int64.counter") aiCounter, _ = meter.Int64ObservableCounter("async.int64.counter")
aiUpDownCounter, _ = meter.AsyncInt64().UpDownCounter("async.int64.up.down.counter") aiUpDownCounter, _ = meter.Int64ObservableUpDownCounter("async.int64.up.down.counter")
aiGauge, _ = meter.AsyncInt64().Gauge("async.int64.gauge") aiGauge, _ = meter.Int64ObservableGauge("async.int64.gauge")
afCounter, _ = meter.AsyncFloat64().Counter("async.float64.counter") afCounter, _ = meter.Float64ObservableCounter("async.float64.counter")
afUpDownCounter, _ = meter.AsyncFloat64().UpDownCounter("async.float64.up.down.counter") afUpDownCounter, _ = meter.Float64ObservableUpDownCounter("async.float64.up.down.counter")
afGauge, _ = meter.AsyncFloat64().Gauge("async.float64.gauge") afGauge, _ = meter.Float64ObservableGauge("async.float64.gauge")
siCounter, _ = meter.SyncInt64().Counter("sync.int64.counter") siCounter, _ = meter.Int64Counter("sync.int64.counter")
siUpDownCounter, _ = meter.SyncInt64().UpDownCounter("sync.int64.up.down.counter") siUpDownCounter, _ = meter.Int64UpDownCounter("sync.int64.up.down.counter")
siHistogram, _ = meter.SyncInt64().Histogram("sync.int64.histogram") siHistogram, _ = meter.Int64Histogram("sync.int64.histogram")
sfCounter, _ = meter.SyncFloat64().Counter("sync.float64.counter") sfCounter, _ = meter.Float64Counter("sync.float64.counter")
sfUpDownCounter, _ = meter.SyncFloat64().UpDownCounter("sync.float64.up.down.counter") sfUpDownCounter, _ = meter.Float64UpDownCounter("sync.float64.up.down.counter")
sfHistogram, _ = meter.SyncFloat64().Histogram("sync.float64.histogram") sfHistogram, _ = meter.Float64Histogram("sync.float64.histogram")
} }
} }