mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-26 03:52:03 +02:00
Unify metric API into the one otel/metric
package (#4018)
* Move instrument into metric * Update metric docs to include instrument * Update package names * Update all imports of sdk/metric/instrument * Rename Option to InstrumentOption * Deprecate otel/metric/instrument * Add changelog entry
This commit is contained in:
parent
94f6c4fc00
commit
15d6ba2921
@ -59,6 +59,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- Fix a data race in `SpanProcessor` returned by `NewSimpleSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace`. (#3951)
|
||||
- Automatically figure out the default aggregation with `aggregation.Default`. (#3967)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- The `go.opentelemetry.io/otel/metric/instrument` package is deprecated.
|
||||
Use the equivalent types added to `go.opentelemetry.io/otel/metric` instead. (#4018)
|
||||
|
||||
## [1.15.0-rc.2/0.38.0-rc.2] 2023-03-23
|
||||
|
||||
This is a release candidate for the v1.15.0/v0.38.0 release.
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/prometheus"
|
||||
api "go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
)
|
||||
|
||||
@ -50,19 +49,19 @@ func main() {
|
||||
// Start the prometheus HTTP server and pass the exporter Collector to it
|
||||
go serveMetrics()
|
||||
|
||||
opt := instrument.WithAttributes(
|
||||
opt := api.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
|
||||
// This is the equivalent of prometheus.NewCounterVec
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", api.WithDescription("a simple counter"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
counter.Add(ctx, 5, opt)
|
||||
|
||||
gauge, err := meter.Float64ObservableGauge("bar", instrument.WithDescription("a fun little gauge"))
|
||||
gauge, err := meter.Float64ObservableGauge("bar", api.WithDescription("a fun little gauge"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -76,7 +75,7 @@ func main() {
|
||||
}
|
||||
|
||||
// This is the equivalent of prometheus.NewHistogramVec
|
||||
histogram, err := meter.Float64Histogram("baz", instrument.WithDescription("a very nice histogram"))
|
||||
histogram, err := meter.Float64Histogram("baz", api.WithDescription("a very nice histogram"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
otelprom "go.opentelemetry.io/otel/exporters/prometheus"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
api "go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
@ -64,18 +64,18 @@ func main() {
|
||||
// Start the prometheus HTTP server and pass the exporter Collector to it
|
||||
go serveMetrics()
|
||||
|
||||
opt := instrument.WithAttributes(
|
||||
opt := api.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", api.WithDescription("a simple counter"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
counter.Add(ctx, 5, opt)
|
||||
|
||||
histogram, err := meter.Float64Histogram("custom_histogram", instrument.WithDescription("a histogram with custom buckets and rename"))
|
||||
histogram, err := meter.Float64Histogram("custom_histogram", api.WithDescription("a histogram with custom buckets and rename"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
otelmetric "go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
@ -46,7 +45,7 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
name: "counter",
|
||||
expectedFile: "testdata/counter.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
@ -54,8 +53,8 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
)
|
||||
counter, err := meter.Float64Counter(
|
||||
"foo",
|
||||
instrument.WithDescription("a simple counter"),
|
||||
instrument.WithUnit("ms"),
|
||||
otelmetric.WithDescription("a simple counter"),
|
||||
otelmetric.WithUnit("ms"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
@ -68,21 +67,21 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
)
|
||||
counter.Add(ctx, 5, instrument.WithAttributeSet(attrs2))
|
||||
counter.Add(ctx, 5, otelmetric.WithAttributeSet(attrs2))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "gauge",
|
||||
expectedFile: "testdata/gauge.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
gauge, err := meter.Float64UpDownCounter(
|
||||
"bar",
|
||||
instrument.WithDescription("a fun little gauge"),
|
||||
instrument.WithUnit("1"),
|
||||
otelmetric.WithDescription("a fun little gauge"),
|
||||
otelmetric.WithUnit("1"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
gauge.Add(ctx, 1.0, opt)
|
||||
@ -93,14 +92,14 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
name: "histogram",
|
||||
expectedFile: "testdata/histogram.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
histogram, err := meter.Float64Histogram(
|
||||
"histogram_baz",
|
||||
instrument.WithDescription("a very nice histogram"),
|
||||
instrument.WithUnit("By"),
|
||||
otelmetric.WithDescription("a very nice histogram"),
|
||||
otelmetric.WithUnit("By"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
histogram.Record(ctx, 23, opt)
|
||||
@ -114,7 +113,7 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
expectedFile: "testdata/sanitized_labels.txt",
|
||||
options: []Option{WithoutUnits()},
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
// exact match, value should be overwritten
|
||||
attribute.Key("A.B").String("X"),
|
||||
attribute.Key("A.B").String("Q"),
|
||||
@ -125,9 +124,9 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
)
|
||||
counter, err := meter.Float64Counter(
|
||||
"foo",
|
||||
instrument.WithDescription("a sanitary counter"),
|
||||
otelmetric.WithDescription("a sanitary counter"),
|
||||
// This unit is not added to
|
||||
instrument.WithUnit("By"),
|
||||
otelmetric.WithUnit("By"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
@ -139,26 +138,26 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
name: "invalid instruments are renamed",
|
||||
expectedFile: "testdata/sanitized_names.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
// Valid.
|
||||
gauge, err := meter.Float64UpDownCounter("bar", instrument.WithDescription("a fun little gauge"))
|
||||
gauge, err := meter.Float64UpDownCounter("bar", otelmetric.WithDescription("a fun little gauge"))
|
||||
require.NoError(t, err)
|
||||
gauge.Add(ctx, 100, opt)
|
||||
gauge.Add(ctx, -25, opt)
|
||||
|
||||
// Invalid, will be renamed.
|
||||
gauge, err = meter.Float64UpDownCounter("invalid.gauge.name", instrument.WithDescription("a gauge with an invalid name"))
|
||||
gauge, err = meter.Float64UpDownCounter("invalid.gauge.name", otelmetric.WithDescription("a gauge with an invalid name"))
|
||||
require.NoError(t, err)
|
||||
gauge.Add(ctx, 100, opt)
|
||||
|
||||
counter, err := meter.Float64Counter("0invalid.counter.name", instrument.WithDescription("a counter with an invalid name"))
|
||||
counter, err := meter.Float64Counter("0invalid.counter.name", otelmetric.WithDescription("a counter with an invalid name"))
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 100, opt)
|
||||
|
||||
histogram, err := meter.Float64Histogram("invalid.hist.name", instrument.WithDescription("a histogram with an invalid name"))
|
||||
histogram, err := meter.Float64Histogram("invalid.hist.name", otelmetric.WithDescription("a histogram with an invalid name"))
|
||||
require.NoError(t, err)
|
||||
histogram.Record(ctx, 23, opt)
|
||||
},
|
||||
@ -168,13 +167,13 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
emptyResource: true,
|
||||
expectedFile: "testdata/empty_resource.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
)
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", otelmetric.WithDescription("a simple counter"))
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
counter.Add(ctx, 10.3, opt)
|
||||
@ -189,13 +188,13 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
},
|
||||
expectedFile: "testdata/custom_resource.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
)
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", otelmetric.WithDescription("a simple counter"))
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
counter.Add(ctx, 10.3, opt)
|
||||
@ -207,13 +206,13 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
options: []Option{WithoutTargetInfo()},
|
||||
expectedFile: "testdata/without_target_info.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
)
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", otelmetric.WithDescription("a simple counter"))
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
counter.Add(ctx, 10.3, opt)
|
||||
@ -225,14 +224,14 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
options: []Option{WithoutScopeInfo()},
|
||||
expectedFile: "testdata/without_scope_info.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
gauge, err := meter.Int64UpDownCounter(
|
||||
"bar",
|
||||
instrument.WithDescription("a fun little gauge"),
|
||||
instrument.WithUnit("1"),
|
||||
otelmetric.WithDescription("a fun little gauge"),
|
||||
otelmetric.WithUnit("1"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
gauge.Add(ctx, 2, opt)
|
||||
@ -244,14 +243,14 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
options: []Option{WithoutScopeInfo(), WithoutTargetInfo()},
|
||||
expectedFile: "testdata/without_scope_and_target_info.txt",
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
)
|
||||
counter, err := meter.Int64Counter(
|
||||
"bar",
|
||||
instrument.WithDescription("a fun little counter"),
|
||||
instrument.WithUnit("By"),
|
||||
otelmetric.WithDescription("a fun little counter"),
|
||||
otelmetric.WithUnit("By"),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 2, opt)
|
||||
@ -265,13 +264,13 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
WithNamespace("test"),
|
||||
},
|
||||
recordMetrics: func(ctx context.Context, meter otelmetric.Meter) {
|
||||
opt := instrument.WithAttributes(
|
||||
opt := otelmetric.WithAttributes(
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
)
|
||||
counter, err := meter.Float64Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
counter, err := meter.Float64Counter("foo", otelmetric.WithDescription("a simple counter"))
|
||||
require.NoError(t, err)
|
||||
counter.Add(ctx, 5, opt)
|
||||
counter.Add(ctx, 10.3, opt)
|
||||
@ -385,18 +384,18 @@ func TestMultiScopes(t *testing.T) {
|
||||
fooCounter, err := provider.Meter("meterfoo", otelmetric.WithInstrumentationVersion("v0.1.0")).
|
||||
Int64Counter(
|
||||
"foo",
|
||||
instrument.WithUnit("ms"),
|
||||
instrument.WithDescription("meter foo counter"))
|
||||
otelmetric.WithUnit("ms"),
|
||||
otelmetric.WithDescription("meter foo counter"))
|
||||
assert.NoError(t, err)
|
||||
fooCounter.Add(ctx, 100, instrument.WithAttributes(attribute.String("type", "foo")))
|
||||
fooCounter.Add(ctx, 100, otelmetric.WithAttributes(attribute.String("type", "foo")))
|
||||
|
||||
barCounter, err := provider.Meter("meterbar", otelmetric.WithInstrumentationVersion("v0.1.0")).
|
||||
Int64Counter(
|
||||
"bar",
|
||||
instrument.WithUnit("ms"),
|
||||
instrument.WithDescription("meter bar counter"))
|
||||
otelmetric.WithUnit("ms"),
|
||||
otelmetric.WithDescription("meter bar counter"))
|
||||
assert.NoError(t, err)
|
||||
barCounter.Add(ctx, 200, instrument.WithAttributes(attribute.String("type", "bar")))
|
||||
barCounter.Add(ctx, 200, otelmetric.WithAttributes(attribute.String("type", "bar")))
|
||||
|
||||
file, err := os.Open("testdata/multi_scopes.txt")
|
||||
require.NoError(t, err)
|
||||
@ -408,11 +407,11 @@ func TestMultiScopes(t *testing.T) {
|
||||
|
||||
func TestDuplicateMetrics(t *testing.T) {
|
||||
ab := attribute.NewSet(attribute.String("A", "B"))
|
||||
withAB := instrument.WithAttributeSet(ab)
|
||||
withAB := otelmetric.WithAttributeSet(ab)
|
||||
typeBar := attribute.NewSet(attribute.String("type", "bar"))
|
||||
withTypeBar := instrument.WithAttributeSet(typeBar)
|
||||
withTypeBar := otelmetric.WithAttributeSet(typeBar)
|
||||
typeFoo := attribute.NewSet(attribute.String("type", "foo"))
|
||||
withTypeFoo := instrument.WithAttributeSet(typeFoo)
|
||||
withTypeFoo := otelmetric.WithAttributeSet(typeFoo)
|
||||
testCases := []struct {
|
||||
name string
|
||||
customResouceAttrs []attribute.KeyValue
|
||||
@ -424,14 +423,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "no_conflict_two_counters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
fooA, err := meterA.Int64Counter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter counter foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter counter foo"))
|
||||
assert.NoError(t, err)
|
||||
fooA.Add(ctx, 100, withAB)
|
||||
|
||||
fooB, err := meterB.Int64Counter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter counter foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter counter foo"))
|
||||
assert.NoError(t, err)
|
||||
fooB.Add(ctx, 100, withAB)
|
||||
},
|
||||
@ -441,14 +440,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "no_conflict_two_updowncounters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
fooA, err := meterA.Int64UpDownCounter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter gauge foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter gauge foo"))
|
||||
assert.NoError(t, err)
|
||||
fooA.Add(ctx, 100, withAB)
|
||||
|
||||
fooB, err := meterB.Int64UpDownCounter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter gauge foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter gauge foo"))
|
||||
assert.NoError(t, err)
|
||||
fooB.Add(ctx, 100, withAB)
|
||||
},
|
||||
@ -458,14 +457,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "no_conflict_two_histograms",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
fooA, err := meterA.Int64Histogram("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter histogram foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter histogram foo"))
|
||||
assert.NoError(t, err)
|
||||
fooA.Record(ctx, 100, withAB)
|
||||
|
||||
fooB, err := meterB.Int64Histogram("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter histogram foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter histogram foo"))
|
||||
assert.NoError(t, err)
|
||||
fooB.Record(ctx, 100, withAB)
|
||||
},
|
||||
@ -475,14 +474,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_help_two_counters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
barA, err := meterA.Int64Counter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter a bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter a bar"))
|
||||
assert.NoError(t, err)
|
||||
barA.Add(ctx, 100, withTypeBar)
|
||||
|
||||
barB, err := meterB.Int64Counter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter b bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter b bar"))
|
||||
assert.NoError(t, err)
|
||||
barB.Add(ctx, 100, withTypeBar)
|
||||
},
|
||||
@ -495,14 +494,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_help_two_updowncounters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
barA, err := meterA.Int64UpDownCounter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter a bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter a bar"))
|
||||
assert.NoError(t, err)
|
||||
barA.Add(ctx, 100, withTypeBar)
|
||||
|
||||
barB, err := meterB.Int64UpDownCounter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter b bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter b bar"))
|
||||
assert.NoError(t, err)
|
||||
barB.Add(ctx, 100, withTypeBar)
|
||||
},
|
||||
@ -515,14 +514,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_help_two_histograms",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
barA, err := meterA.Int64Histogram("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter a bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter a bar"))
|
||||
assert.NoError(t, err)
|
||||
barA.Record(ctx, 100, withAB)
|
||||
|
||||
barB, err := meterB.Int64Histogram("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter b bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter b bar"))
|
||||
assert.NoError(t, err)
|
||||
barB.Record(ctx, 100, withAB)
|
||||
},
|
||||
@ -535,14 +534,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_unit_two_counters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
bazA, err := meterA.Int64Counter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter bar"))
|
||||
assert.NoError(t, err)
|
||||
bazA.Add(ctx, 100, withTypeBar)
|
||||
|
||||
bazB, err := meterB.Int64Counter("bar",
|
||||
instrument.WithUnit("ms"),
|
||||
instrument.WithDescription("meter bar"))
|
||||
otelmetric.WithUnit("ms"),
|
||||
otelmetric.WithDescription("meter bar"))
|
||||
assert.NoError(t, err)
|
||||
bazB.Add(ctx, 100, withTypeBar)
|
||||
},
|
||||
@ -553,14 +552,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_unit_two_updowncounters",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
barA, err := meterA.Int64UpDownCounter("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter gauge bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter gauge bar"))
|
||||
assert.NoError(t, err)
|
||||
barA.Add(ctx, 100, withTypeBar)
|
||||
|
||||
barB, err := meterB.Int64UpDownCounter("bar",
|
||||
instrument.WithUnit("ms"),
|
||||
instrument.WithDescription("meter gauge bar"))
|
||||
otelmetric.WithUnit("ms"),
|
||||
otelmetric.WithDescription("meter gauge bar"))
|
||||
assert.NoError(t, err)
|
||||
barB.Add(ctx, 100, withTypeBar)
|
||||
},
|
||||
@ -571,14 +570,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_unit_two_histograms",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
barA, err := meterA.Int64Histogram("bar",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter histogram bar"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter histogram bar"))
|
||||
assert.NoError(t, err)
|
||||
barA.Record(ctx, 100, withAB)
|
||||
|
||||
barB, err := meterB.Int64Histogram("bar",
|
||||
instrument.WithUnit("ms"),
|
||||
instrument.WithDescription("meter histogram bar"))
|
||||
otelmetric.WithUnit("ms"),
|
||||
otelmetric.WithDescription("meter histogram bar"))
|
||||
assert.NoError(t, err)
|
||||
barB.Record(ctx, 100, withAB)
|
||||
},
|
||||
@ -589,14 +588,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_type_counter_and_updowncounter",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
counter, err := meterA.Int64Counter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter foo"))
|
||||
assert.NoError(t, err)
|
||||
counter.Add(ctx, 100, withTypeFoo)
|
||||
|
||||
gauge, err := meterA.Int64UpDownCounter("foo_total",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter foo"))
|
||||
assert.NoError(t, err)
|
||||
gauge.Add(ctx, 200, withTypeFoo)
|
||||
},
|
||||
@ -610,14 +609,14 @@ func TestDuplicateMetrics(t *testing.T) {
|
||||
name: "conflict_type_histogram_and_updowncounter",
|
||||
recordMetrics: func(ctx context.Context, meterA, meterB otelmetric.Meter) {
|
||||
fooA, err := meterA.Int64UpDownCounter("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter gauge foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter gauge foo"))
|
||||
assert.NoError(t, err)
|
||||
fooA.Add(ctx, 100, withAB)
|
||||
|
||||
fooHistogramA, err := meterA.Int64Histogram("foo",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithDescription("meter histogram foo"))
|
||||
otelmetric.WithUnit("By"),
|
||||
otelmetric.WithDescription("meter histogram foo"))
|
||||
assert.NoError(t, err)
|
||||
fooHistogramA.Record(ctx, 100, withAB)
|
||||
},
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -26,9 +26,47 @@ instruments are created by a [Meter] which itself is created by a
|
||||
as a starting point when instrumenting. This can be done directly, or by using
|
||||
the OpenTelemetry global MeterProvider via [GetMeterProvider]. Using an
|
||||
appropriately named [Meter] from the accepted [MeterProvider], instrumentation
|
||||
can then be built from the [Meter]'s instruments. See
|
||||
[go.opentelemetry.io/otel/metric/instrument] for documentation on each
|
||||
instrument and its intended use.
|
||||
can then be built from the [Meter]'s instruments.
|
||||
|
||||
# Instruments
|
||||
|
||||
Each instrument is designed to make measurements of a particular type. Broadly,
|
||||
all instruments fall into two overlapping logical categories: asynchronous or
|
||||
synchronous, and int64 or float64.
|
||||
|
||||
All synchronous instruments ([Int64Counter], [Int64UpDownCounter],
|
||||
[Int64Histogram], [Float64Counter], [Float64UpDownCounter], [Float64Histogram])
|
||||
are used to measure the operation and performance of source code during the
|
||||
source code execution. These instruments only make measurements when the source
|
||||
code they instrument is run.
|
||||
|
||||
All asynchronous instruments ([Int64ObservableCounter],
|
||||
[Int64ObservableUpDownCounter], [Int64ObservableGauge],
|
||||
[Float64ObservableCounter], [Float64ObservableUpDownCounter],
|
||||
[Float64ObservableGauge]) are used to measure metrics outside of the execution
|
||||
of source code. They are said to make "observations" via a callback function
|
||||
called once every measurement collection cycle.
|
||||
|
||||
Each instrument is also grouped by the value type it measures. Either int64 or
|
||||
float64. The value being measured will dictate which instrument in these
|
||||
categories to use.
|
||||
|
||||
Outside of these two broad categories, instruments are described by the
|
||||
function they are designed to serve. All Counters ([Int64Counter],
|
||||
[Float64Counter], [Int64ObservableCounter], [Float64ObservableCounter]) are
|
||||
designed to measure values that never decrease in value, but instead only
|
||||
incrementally increase in value. UpDownCounters ([Int64UpDownCounter],
|
||||
[Float64UpDownCounter], [Int64ObservableUpDownCounter],
|
||||
[Float64ObservableUpDownCounter]) on the other hand, are designed to measure
|
||||
values that can increase and decrease. When more information
|
||||
needs to be conveyed about all the synchronous measurements made during a
|
||||
collection cycle, a Histogram ([Int64Histogram], [Float64Histogram]) should be
|
||||
used. Finally, when just the most recent measurement needs to be conveyed about an
|
||||
asynchronous measurement, a Gauge ([Int64ObservableGauge],
|
||||
[Float64ObservableGauge]) should be used.
|
||||
|
||||
See the [OpenTelemetry documentation] for more information about instruments
|
||||
and their intended use.
|
||||
|
||||
# API Implementations
|
||||
|
||||
@ -93,6 +131,7 @@ It is strongly recommended that authors only embed
|
||||
That implementation is the only one OpenTelemetry authors can guarantee will
|
||||
fully implement all the API interfaces when a user updates their API.
|
||||
|
||||
[OpenTelemetry documentation]: https://opentelemetry.io/docs/concepts/signals/metrics/
|
||||
[GetMeterProvider]: https://pkg.go.dev/go.opentelemetry.io/otel#GetMeterProvider
|
||||
*/
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
@ -46,25 +46,25 @@ type MeterProvider interface{ meterProvider() }
|
||||
type Meter interface{ meter() }
|
||||
|
||||
// Float64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Observer].
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Observer] if you want
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Observer] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Observer interface{ float64Observer() }
|
||||
|
||||
// Int64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Observer].
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Observer] if you want users
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Observer] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Observer interface{ int64Observer() }
|
||||
@ -90,145 +90,145 @@ type Observer interface{ observer() }
|
||||
type Registration interface{ registration() }
|
||||
|
||||
// Float64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Counter].
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Counter] if you want
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Counter] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Counter interface{ float64Counter() }
|
||||
|
||||
// Float64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Histogram].
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Histogram] if you want
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64Histogram] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Histogram interface{ float64Histogram() }
|
||||
|
||||
// Float64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableCounter] if you
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableCounter]
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableCounter interface{ float64ObservableCounter() }
|
||||
|
||||
// Float64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableGauge].
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableGauge] if you
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableGauge]
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableGauge interface{ float64ObservableGauge() }
|
||||
|
||||
// Float64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableUpDownCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableUpDownCounter]
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// if you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64ObservableUpDownCounter]
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableUpDownCounter interface{ float64ObservableUpDownCounter() }
|
||||
|
||||
// Float64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64UpDownCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64UpDownCounter] if you
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Float64UpDownCounter] interface
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Float64UpDownCounter interface{ float64UpDownCounter() }
|
||||
|
||||
// Int64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Counter].
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Counter] if you want users
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Counter] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Counter interface{ int64Counter() }
|
||||
|
||||
// Int64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Histogram].
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Histogram] if you want
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64Histogram] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Histogram interface{ int64Histogram() }
|
||||
|
||||
// Int64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableCounter] if you
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableCounter]
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableCounter interface{ int64ObservableCounter() }
|
||||
|
||||
// Int64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableGauge].
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableGauge] if you
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableGauge] interface
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Int64ObservableGauge interface{ int64ObservableGauge() }
|
||||
|
||||
// Int64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableUpDownCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableUpDownCounter] if
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter] if
|
||||
// you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64ObservableUpDownCounter]
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableUpDownCounter interface{ int64ObservableUpDownCounter() }
|
||||
|
||||
// Int64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64UpDownCounter].
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64UpDownCounter] if you want
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric/instrument.Int64UpDownCounter] interface is
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64UpDownCounter interface{ int64UpDownCounter() }
|
||||
|
@ -23,14 +23,13 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
func ExampleMeter_synchronous() {
|
||||
// Create a histogram using the global MeterProvider.
|
||||
workDuration, err := global.Meter("go.opentelemetry.io/otel/metric#SyncExample").Int64Histogram(
|
||||
"workDuration",
|
||||
instrument.WithUnit("ms"))
|
||||
metric.WithUnit("ms"))
|
||||
if err != nil {
|
||||
fmt.Println("Failed to register instrument")
|
||||
panic(err)
|
||||
@ -48,8 +47,8 @@ func ExampleMeter_asynchronous_single() {
|
||||
|
||||
_, err := meter.Int64ObservableGauge(
|
||||
"DiskUsage",
|
||||
instrument.WithUnit("By"),
|
||||
instrument.WithInt64Callback(func(_ context.Context, obsrv instrument.Int64Observer) error {
|
||||
metric.WithUnit("By"),
|
||||
metric.WithInt64Callback(func(_ context.Context, obsrv metric.Int64Observer) error {
|
||||
// Do the real work here to get the real disk usage. For example,
|
||||
//
|
||||
// usage, err := GetDiskUsage(diskID)
|
||||
@ -63,7 +62,7 @@ func ExampleMeter_asynchronous_single() {
|
||||
//
|
||||
// For demonstration purpose, a static value is used here.
|
||||
usage := 75000
|
||||
obsrv.Observe(int64(usage), instrument.WithAttributes(attribute.Int("disk.id", 3)))
|
||||
obsrv.Observe(int64(usage), metric.WithAttributes(attribute.Int("disk.id", 3)))
|
||||
return nil
|
||||
}),
|
||||
)
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
@ -22,8 +22,8 @@ type Observable interface {
|
||||
observable()
|
||||
}
|
||||
|
||||
// Option applies options to all instruments.
|
||||
type Option interface {
|
||||
// InstrumentOption applies options to all instruments.
|
||||
type InstrumentOption interface {
|
||||
Int64CounterOption
|
||||
Int64UpDownCounterOption
|
||||
Int64HistogramOption
|
||||
@ -102,7 +102,7 @@ func (o descOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64Ob
|
||||
}
|
||||
|
||||
// WithDescription sets the instrument description.
|
||||
func WithDescription(desc string) Option { return descOpt(desc) }
|
||||
func WithDescription(desc string) InstrumentOption { return descOpt(desc) }
|
||||
|
||||
type unitOpt string
|
||||
|
||||
@ -167,7 +167,7 @@ func (o unitOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64Ob
|
||||
}
|
||||
|
||||
// WithUnit sets the instrument unit.
|
||||
func WithUnit(u string) Option { return unitOpt(u) }
|
||||
func WithUnit(u string) InstrumentOption { return unitOpt(u) }
|
||||
|
||||
// AddOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a AddOption.
|
452
metric/instrument/deprecation.go
Normal file
452
metric/instrument/deprecation.go
Normal file
@ -0,0 +1,452 @@
|
||||
// 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 instrument provides the OpenTelemetry API instruments used to make
|
||||
// measurements.
|
||||
//
|
||||
// Deprecated: Use go.opentelemetry.io/otel/metric instead.
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
// Float64Observable is an alias for [metric.Float64Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Observable] instead.
|
||||
type Float64Observable metric.Float64Observable
|
||||
|
||||
// Float64ObservableCounter is an alias for [metric.Float64ObservableCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounter] instead.
|
||||
type Float64ObservableCounter metric.Float64ObservableCounter
|
||||
|
||||
// Float64ObservableCounterConfig is an alias for
|
||||
// [metric.Float64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounterConfig] instead.
|
||||
type Float64ObservableCounterConfig metric.Float64ObservableCounterConfig
|
||||
|
||||
// NewFloat64ObservableCounterConfig wraps
|
||||
// [metric.NewFloat64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableCounterConfig] instead.
|
||||
func NewFloat64ObservableCounterConfig(opts ...Float64ObservableCounterOption) Float64ObservableCounterConfig {
|
||||
o := make([]metric.Float64ObservableCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableCounterConfig(o...)
|
||||
return Float64ObservableCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableCounterOption is an alias for
|
||||
// [metric.Float64ObservableCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounterOption] instead.
|
||||
type Float64ObservableCounterOption metric.Float64ObservableCounterOption
|
||||
|
||||
// Float64ObservableUpDownCounter is an alias for
|
||||
// [metric.Float64ObservableUpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounter] instead.
|
||||
type Float64ObservableUpDownCounter metric.Float64ObservableUpDownCounter
|
||||
|
||||
// Float64ObservableUpDownCounterConfig is an alias for
|
||||
// [metric.Float64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounterConfig] instead.
|
||||
type Float64ObservableUpDownCounterConfig metric.Float64ObservableUpDownCounterConfig
|
||||
|
||||
// NewFloat64ObservableUpDownCounterConfig wraps
|
||||
// [metric.NewFloat64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableUpDownCounterConfig] instead.
|
||||
func NewFloat64ObservableUpDownCounterConfig(opts ...Float64ObservableUpDownCounterOption) Float64ObservableUpDownCounterConfig {
|
||||
o := make([]metric.Float64ObservableUpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableUpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableUpDownCounterConfig(o...)
|
||||
return Float64ObservableUpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterOption is an alias for
|
||||
// [metric.Float64ObservableUpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounterOption] instead.
|
||||
type Float64ObservableUpDownCounterOption metric.Float64ObservableUpDownCounterOption
|
||||
|
||||
// Float64ObservableGauge is an alias for [metric.Float64ObservableGauge].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGauge] instead.
|
||||
type Float64ObservableGauge metric.Float64ObservableGauge
|
||||
|
||||
// Float64ObservableGaugeConfig is an alias for
|
||||
// [metric.Float64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGaugeConfig] instead.
|
||||
type Float64ObservableGaugeConfig metric.Float64ObservableGaugeConfig
|
||||
|
||||
// NewFloat64ObservableGaugeConfig wraps
|
||||
// [metric.NewFloat64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableGaugeConfig] instead.
|
||||
func NewFloat64ObservableGaugeConfig(opts ...Float64ObservableGaugeOption) Float64ObservableGaugeConfig {
|
||||
o := make([]metric.Float64ObservableGaugeOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableGaugeOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableGaugeConfig(o...)
|
||||
return Float64ObservableGaugeConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeOption is an alias for
|
||||
// [metric.Float64ObservableGaugeOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGaugeOption] instead.
|
||||
type Float64ObservableGaugeOption metric.Float64ObservableGaugeOption
|
||||
|
||||
// Float64Observer is an alias for [metric.Float64Observer].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Observer] instead.
|
||||
type Float64Observer metric.Float64Observer
|
||||
|
||||
// Float64Callback is an alias for [metric.Float64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Callback] instead.
|
||||
type Float64Callback metric.Float64Callback
|
||||
|
||||
// Float64ObservableOption is an alias for [metric.Float64ObservableOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableOption] instead.
|
||||
type Float64ObservableOption metric.Float64ObservableOption
|
||||
|
||||
// WithFloat64Callback wraps [metric.WithFloat64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.WithFloat64Callback] instead.
|
||||
func WithFloat64Callback(callback Float64Callback) Float64ObservableOption {
|
||||
cback := metric.Float64Callback(callback)
|
||||
opt := metric.WithFloat64Callback(cback)
|
||||
return Float64ObservableOption(opt)
|
||||
}
|
||||
|
||||
// Int64Observable is an alias for [metric.Int64Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Observable] instead.
|
||||
type Int64Observable metric.Int64Observable
|
||||
|
||||
// Int64ObservableCounter is an alias for [metric.Int64ObservableCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounter] instead.
|
||||
type Int64ObservableCounter metric.Int64ObservableCounter
|
||||
|
||||
// Int64ObservableCounterConfig is an alias for
|
||||
// [metric.Int64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounterConfig] instead.
|
||||
type Int64ObservableCounterConfig metric.Int64ObservableCounterConfig
|
||||
|
||||
// NewInt64ObservableCounterConfig wraps
|
||||
// [metric.NewInt64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableCounterConfig] instead.
|
||||
func NewInt64ObservableCounterConfig(opts ...Int64ObservableCounterOption) Int64ObservableCounterConfig {
|
||||
o := make([]metric.Int64ObservableCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableCounterConfig(o...)
|
||||
return Int64ObservableCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableCounterOption is an alias for
|
||||
// [metric.Int64ObservableCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounterOption] instead.
|
||||
type Int64ObservableCounterOption metric.Int64ObservableCounterOption
|
||||
|
||||
// Int64ObservableUpDownCounter is an alias for
|
||||
// [metric.Int64ObservableUpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounter] instead.
|
||||
type Int64ObservableUpDownCounter metric.Int64ObservableUpDownCounter
|
||||
|
||||
// Int64ObservableUpDownCounterConfig is an alias for
|
||||
// [metric.Int64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounterConfig] instead.
|
||||
type Int64ObservableUpDownCounterConfig metric.Int64ObservableUpDownCounterConfig
|
||||
|
||||
// NewInt64ObservableUpDownCounterConfig wraps
|
||||
// [metric.NewInt64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableUpDownCounterConfig] instead.
|
||||
func NewInt64ObservableUpDownCounterConfig(opts ...Int64ObservableUpDownCounterOption) Int64ObservableUpDownCounterConfig {
|
||||
o := make([]metric.Int64ObservableUpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableUpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableUpDownCounterConfig(o...)
|
||||
return Int64ObservableUpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterOption is an alias for
|
||||
// [metric.Int64ObservableUpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounterOption] instead.
|
||||
type Int64ObservableUpDownCounterOption metric.Int64ObservableUpDownCounterOption
|
||||
|
||||
// Int64ObservableGauge is an alias for [metric.Int64ObservableGauge].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGauge] instead.
|
||||
type Int64ObservableGauge metric.Int64ObservableGauge
|
||||
|
||||
// Int64ObservableGaugeConfig is an alias for
|
||||
// [metric.Int64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGaugeConfig] instead.
|
||||
type Int64ObservableGaugeConfig metric.Int64ObservableGaugeConfig
|
||||
|
||||
// NewInt64ObservableGaugeConfig wraps [metric.NewInt64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableGaugeConfig] instead.
|
||||
func NewInt64ObservableGaugeConfig(opts ...Int64ObservableGaugeOption) Int64ObservableGaugeConfig {
|
||||
o := make([]metric.Int64ObservableGaugeOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableGaugeOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableGaugeConfig(o...)
|
||||
return Int64ObservableGaugeConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeOption is an alias for
|
||||
// [metric.Int64ObservableGaugeOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGaugeOption] instead.
|
||||
type Int64ObservableGaugeOption metric.Int64ObservableGaugeOption
|
||||
|
||||
// Int64Observer is an alias for [metric.Int64Observer].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Observer] instead.
|
||||
type Int64Observer metric.Int64Observer
|
||||
|
||||
// Int64Callback is an alias for [metric.Int64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Callback] instead.
|
||||
type Int64Callback metric.Int64Callback
|
||||
|
||||
// Int64ObservableOption is an alias for [metric.Int64ObservableOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableOption] instead.
|
||||
type Int64ObservableOption metric.Int64ObservableOption
|
||||
|
||||
// WithInt64Callback wraps [metric.WithInt64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.WithInt64Callback] instead.
|
||||
func WithInt64Callback(callback Int64Callback) Int64ObservableOption {
|
||||
cback := metric.Int64Callback(callback)
|
||||
opt := metric.WithInt64Callback(cback)
|
||||
return Int64ObservableOption(opt)
|
||||
}
|
||||
|
||||
// Float64Counter is an alias for [metric.Float64Counter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Counter] instead.
|
||||
type Float64Counter metric.Float64Counter
|
||||
|
||||
// Float64CounterConfig is an alias for [metric.Float64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64CounterConfig] instead.
|
||||
type Float64CounterConfig metric.Float64CounterConfig
|
||||
|
||||
// NewFloat64CounterConfig wraps [metric.NewFloat64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64CounterConfig] instead.
|
||||
func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
|
||||
o := make([]metric.Float64CounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64CounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64CounterConfig(o...)
|
||||
return Float64CounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64CounterOption is an alias for [metric.Float64CounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64CounterOption] instead.
|
||||
type Float64CounterOption metric.Float64CounterOption
|
||||
|
||||
// Float64UpDownCounter is an alias for [metric.Float64UpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounter] instead.
|
||||
type Float64UpDownCounter metric.Float64UpDownCounter
|
||||
|
||||
// Float64UpDownCounterConfig is an alias for
|
||||
// [metric.Float64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounterConfig] instead.
|
||||
type Float64UpDownCounterConfig metric.Float64UpDownCounterConfig
|
||||
|
||||
// NewFloat64UpDownCounterConfig wraps [metric.NewFloat64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64UpDownCounterConfig] instead.
|
||||
func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
|
||||
o := make([]metric.Float64UpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64UpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64UpDownCounterConfig(o...)
|
||||
return Float64UpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64UpDownCounterOption is an alias for
|
||||
// [metric.Float64UpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounterOption] instead.
|
||||
type Float64UpDownCounterOption metric.Float64UpDownCounterOption
|
||||
|
||||
// Float64Histogram is an alias for [metric.Float64Histogram].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Histogram] instead.
|
||||
type Float64Histogram metric.Float64Histogram
|
||||
|
||||
// Float64HistogramConfig is an alias for [metric.Float64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64HistogramConfig] instead.
|
||||
type Float64HistogramConfig metric.Float64HistogramConfig
|
||||
|
||||
// NewFloat64HistogramConfig wraps [metric.NewFloat64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64HistogramConfig] instead.
|
||||
func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
|
||||
o := make([]metric.Float64HistogramOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64HistogramOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64HistogramConfig(o...)
|
||||
return Float64HistogramConfig(c)
|
||||
}
|
||||
|
||||
// Float64HistogramOption is an alias for [metric.Float64HistogramOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64HistogramOption] instead.
|
||||
type Float64HistogramOption metric.Float64HistogramOption
|
||||
|
||||
// Int64Counter is an alias for [metric.Int64Counter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Counter] instead.
|
||||
type Int64Counter metric.Int64Counter
|
||||
|
||||
// Int64CounterConfig is an alias for [metric.Int64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64CounterConfig] instead.
|
||||
type Int64CounterConfig metric.Int64CounterConfig
|
||||
|
||||
// NewInt64CounterConfig wraps [metric.NewInt64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64CounterConfig] instead.
|
||||
func NewInt64CounterConfig(opts ...Int64CounterOption) Int64CounterConfig {
|
||||
o := make([]metric.Int64CounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64CounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64CounterConfig(o...)
|
||||
return Int64CounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64CounterOption is an alias for [metric.Int64CounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64CounterOption] instead.
|
||||
type Int64CounterOption metric.Int64CounterOption
|
||||
|
||||
// Int64UpDownCounter is an alias for [metric.Int64UpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounter] instead.
|
||||
type Int64UpDownCounter metric.Int64UpDownCounter
|
||||
|
||||
// Int64UpDownCounterConfig is an alias for [metric.Int64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounterConfig] instead.
|
||||
type Int64UpDownCounterConfig metric.Int64UpDownCounterConfig
|
||||
|
||||
// NewInt64UpDownCounterConfig wraps [metric.NewInt64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64UpDownCounterConfig] instead.
|
||||
func NewInt64UpDownCounterConfig(opts ...Int64UpDownCounterOption) Int64UpDownCounterConfig {
|
||||
o := make([]metric.Int64UpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64UpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64UpDownCounterConfig(o...)
|
||||
return Int64UpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64UpDownCounterOption is an alias for [metric.Int64UpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounterOption] instead.
|
||||
type Int64UpDownCounterOption metric.Int64UpDownCounterOption
|
||||
|
||||
// Int64Histogram is an alias for [metric.Int64Histogram].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Histogram] instead.
|
||||
type Int64Histogram metric.Int64Histogram
|
||||
|
||||
// Int64HistogramConfig is an alias for [metric.Int64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64HistogramConfig] instead.
|
||||
type Int64HistogramConfig metric.Int64HistogramConfig
|
||||
|
||||
// NewInt64HistogramConfig wraps [metric.NewInt64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64HistogramConfig] instead.
|
||||
func NewInt64HistogramConfig(opts ...Int64HistogramOption) Int64HistogramConfig {
|
||||
o := make([]metric.Int64HistogramOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64HistogramOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64HistogramConfig(o...)
|
||||
return Int64HistogramConfig(c)
|
||||
}
|
||||
|
||||
// Int64HistogramOption is an alias for [metric.Int64HistogramOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64HistogramOption] instead.
|
||||
type Int64HistogramOption metric.Int64HistogramOption
|
||||
|
||||
// Observable is an alias for [metric.Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Observable] instead.
|
||||
type Observable metric.Observable
|
||||
|
||||
// Option is an alias for [metric.InstrumentOption].
|
||||
//
|
||||
// Deprecated: Use [metric.InstrumentOption] instead.
|
||||
type Option metric.InstrumentOption
|
||||
|
||||
// WithDescription is an alias for [metric.WithDescription].
|
||||
//
|
||||
// Deprecated: Use [metric.WithDescription] instead.
|
||||
func WithDescription(desc string) Option {
|
||||
o := metric.WithDescription(desc)
|
||||
return Option(o)
|
||||
}
|
||||
|
||||
// WithUnit is an alias for [metric.WithUnit].
|
||||
//
|
||||
// Deprecated: Use [metric.WithUnit] instead.
|
||||
func WithUnit(u string) Option {
|
||||
o := metric.WithUnit(u)
|
||||
return Option(o)
|
||||
}
|
@ -1,59 +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 instrument provides the OpenTelemetry API instruments used to make
|
||||
measurements.
|
||||
|
||||
Each instrument is designed to make measurements of a particular type. Broadly,
|
||||
all instruments fall into two overlapping logical categories: asynchronous or
|
||||
synchronous, and int64 or float64.
|
||||
|
||||
All synchronous instruments ([Int64Counter], [Int64UpDownCounter],
|
||||
[Int64Histogram], [Float64Counter], [Float64UpDownCounter], [Float64Histogram])
|
||||
are used to measure the operation and performance of source code during the
|
||||
source code execution. These instruments only make measurements when the source
|
||||
code they instrument is run.
|
||||
|
||||
All asynchronous instruments ([Int64ObservableCounter],
|
||||
[Int64ObservableUpDownCounter], [Int64ObservableGauge],
|
||||
[Float64ObservableCounter], [Float64ObservableUpDownCounter],
|
||||
[Float64ObservableGauge]) are used to measure metrics outside of the execution
|
||||
of source code. They are said to make "observations" via a callback function
|
||||
called once every measurement collection cycle.
|
||||
|
||||
Each instrument is also grouped by the value type it measures. Either int64 or
|
||||
float64. The value being measured will dictate which instrument in these
|
||||
categories to use.
|
||||
|
||||
Outside of these two broad categories, instruments are described by the
|
||||
function they are designed to serve. All Counters ([Int64Counter],
|
||||
[Float64Counter], [Int64ObservableCounter], [Float64ObservableCounter]) are
|
||||
designed to measure values that never decrease in value, but instead only
|
||||
incrementally increase in value. UpDownCounters ([Int64UpDownCounter],
|
||||
[Float64UpDownCounter], [Int64ObservableUpDownCounter],
|
||||
[Float64ObservableUpDownCounter]) on the other hand, are designed to measure
|
||||
values that can increase and decrease. When more information
|
||||
needs to be conveyed about all the synchronous measurements made during a
|
||||
collection cycle, a Histogram ([Int64Histogram], [Float64Histogram]) should be
|
||||
used. Finally, when just the most recent measurement needs to be conveyed about an
|
||||
asynchronous measurement, a Gauge ([Int64ObservableGauge],
|
||||
[Float64ObservableGauge]) should be used.
|
||||
|
||||
See the [OpenTelemetry documentation] for more information about instruments
|
||||
and their intended use.
|
||||
|
||||
[OpenTelemetry documentation]: https://opentelemetry.io/docs/concepts/signals/metrics/
|
||||
*/
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"sync"
|
@ -21,26 +21,25 @@ import (
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// unwrapper unwraps to return the underlying instrument implementation.
|
||||
type unwrapper interface {
|
||||
Unwrap() instrument.Observable
|
||||
Unwrap() metric.Observable
|
||||
}
|
||||
|
||||
type afCounter struct {
|
||||
embedded.Float64ObservableCounter
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObservableCounterOption
|
||||
opts []metric.Float64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableCounter
|
||||
delegate atomic.Value //metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afCounter)(nil)
|
||||
var _ instrument.Float64ObservableCounter = (*afCounter)(nil)
|
||||
var _ metric.Float64ObservableCounter = (*afCounter)(nil)
|
||||
|
||||
func (i *afCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
|
||||
@ -51,25 +50,25 @@ func (i *afCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afCounter) Unwrap() instrument.Observable {
|
||||
func (i *afCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableCounter)
|
||||
return ctr.(metric.Float64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afUpDownCounter struct {
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObservableUpDownCounterOption
|
||||
opts []metric.Float64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableUpDownCounter
|
||||
delegate atomic.Value //metric.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afUpDownCounter)(nil)
|
||||
var _ instrument.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
var _ metric.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
|
||||
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
||||
@ -80,25 +79,25 @@ func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afUpDownCounter) Unwrap() instrument.Observable {
|
||||
func (i *afUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableUpDownCounter)
|
||||
return ctr.(metric.Float64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afGauge struct {
|
||||
embedded.Float64ObservableGauge
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObservableGaugeOption
|
||||
opts []metric.Float64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableGauge
|
||||
delegate atomic.Value //metric.Float64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afGauge)(nil)
|
||||
var _ instrument.Float64ObservableGauge = (*afGauge)(nil)
|
||||
var _ metric.Float64ObservableGauge = (*afGauge)(nil)
|
||||
|
||||
func (i *afGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
||||
@ -109,25 +108,25 @@ func (i *afGauge) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afGauge) Unwrap() instrument.Observable {
|
||||
func (i *afGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableGauge)
|
||||
return ctr.(metric.Float64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiCounter struct {
|
||||
embedded.Int64ObservableCounter
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObservableCounterOption
|
||||
opts []metric.Int64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableCounter
|
||||
delegate atomic.Value //metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiCounter)(nil)
|
||||
var _ instrument.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
var _ metric.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
|
||||
func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
||||
@ -138,25 +137,25 @@ func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiCounter) Unwrap() instrument.Observable {
|
||||
func (i *aiCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableCounter)
|
||||
return ctr.(metric.Int64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiUpDownCounter struct {
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObservableUpDownCounterOption
|
||||
opts []metric.Int64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableUpDownCounter
|
||||
delegate atomic.Value //metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiUpDownCounter)(nil)
|
||||
var _ instrument.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
var _ metric.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
|
||||
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
||||
@ -167,25 +166,25 @@ func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiUpDownCounter) Unwrap() instrument.Observable {
|
||||
func (i *aiUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableUpDownCounter)
|
||||
return ctr.(metric.Int64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiGauge struct {
|
||||
embedded.Int64ObservableGauge
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObservableGaugeOption
|
||||
opts []metric.Int64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableGauge
|
||||
delegate atomic.Value //metric.Int64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiGauge)(nil)
|
||||
var _ instrument.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
var _ metric.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
|
||||
func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
||||
@ -196,9 +195,9 @@ func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiGauge) Unwrap() instrument.Observable {
|
||||
func (i *aiGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableGauge)
|
||||
return ctr.(metric.Int64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -208,12 +207,12 @@ type sfCounter struct {
|
||||
embedded.Float64Counter
|
||||
|
||||
name string
|
||||
opts []instrument.Float64CounterOption
|
||||
opts []metric.Float64CounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64Counter
|
||||
delegate atomic.Value //metric.Float64Counter
|
||||
}
|
||||
|
||||
var _ instrument.Float64Counter = (*sfCounter)(nil)
|
||||
var _ metric.Float64Counter = (*sfCounter)(nil)
|
||||
|
||||
func (i *sfCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Counter(i.name, i.opts...)
|
||||
@ -224,9 +223,9 @@ func (i *sfCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, opts ...instrument.AddOption) {
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Counter).Add(ctx, incr, opts...)
|
||||
ctr.(metric.Float64Counter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,12 +233,12 @@ type sfUpDownCounter struct {
|
||||
embedded.Float64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []instrument.Float64UpDownCounterOption
|
||||
opts []metric.Float64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64UpDownCounter
|
||||
delegate atomic.Value //metric.Float64UpDownCounter
|
||||
}
|
||||
|
||||
var _ instrument.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
var _ metric.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
|
||||
func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64UpDownCounter(i.name, i.opts...)
|
||||
@ -250,9 +249,9 @@ func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, opts ...instrument.AddOption) {
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64UpDownCounter).Add(ctx, incr, opts...)
|
||||
ctr.(metric.Float64UpDownCounter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,12 +259,12 @@ type sfHistogram struct {
|
||||
embedded.Float64Histogram
|
||||
|
||||
name string
|
||||
opts []instrument.Float64HistogramOption
|
||||
opts []metric.Float64HistogramOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64Histogram
|
||||
delegate atomic.Value //metric.Float64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Float64Histogram = (*sfHistogram)(nil)
|
||||
var _ metric.Float64Histogram = (*sfHistogram)(nil)
|
||||
|
||||
func (i *sfHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Histogram(i.name, i.opts...)
|
||||
@ -276,9 +275,9 @@ func (i *sfHistogram) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, opts ...instrument.RecordOption) {
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Histogram).Record(ctx, x, opts...)
|
||||
ctr.(metric.Float64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,12 +285,12 @@ type siCounter struct {
|
||||
embedded.Int64Counter
|
||||
|
||||
name string
|
||||
opts []instrument.Int64CounterOption
|
||||
opts []metric.Int64CounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64Counter
|
||||
delegate atomic.Value //metric.Int64Counter
|
||||
}
|
||||
|
||||
var _ instrument.Int64Counter = (*siCounter)(nil)
|
||||
var _ metric.Int64Counter = (*siCounter)(nil)
|
||||
|
||||
func (i *siCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Counter(i.name, i.opts...)
|
||||
@ -302,9 +301,9 @@ func (i *siCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, opts ...instrument.AddOption) {
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Counter).Add(ctx, x, opts...)
|
||||
ctr.(metric.Int64Counter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,12 +311,12 @@ type siUpDownCounter struct {
|
||||
embedded.Int64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []instrument.Int64UpDownCounterOption
|
||||
opts []metric.Int64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64UpDownCounter
|
||||
delegate atomic.Value //metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
var _ instrument.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
var _ metric.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
|
||||
func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64UpDownCounter(i.name, i.opts...)
|
||||
@ -328,9 +327,9 @@ func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, opts ...instrument.AddOption) {
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64UpDownCounter).Add(ctx, x, opts...)
|
||||
ctr.(metric.Int64UpDownCounter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,12 +337,12 @@ type siHistogram struct {
|
||||
embedded.Int64Histogram
|
||||
|
||||
name string
|
||||
opts []instrument.Int64HistogramOption
|
||||
opts []metric.Int64HistogramOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64Histogram
|
||||
delegate atomic.Value //metric.Int64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Int64Histogram = (*siHistogram)(nil)
|
||||
var _ metric.Int64Histogram = (*siHistogram)(nil)
|
||||
|
||||
func (i *siHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Histogram(i.name, i.opts...)
|
||||
@ -354,8 +353,8 @@ func (i *siHistogram) setDelegate(m metric.Meter) {
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, opts ...instrument.RecordOption) {
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Histogram).Record(ctx, x, opts...)
|
||||
ctr.(metric.Int64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
)
|
||||
|
||||
@ -151,7 +150,7 @@ func TestSyncInstrumentSetDelegateRace(t *testing.T) {
|
||||
type testCountingFloatInstrument struct {
|
||||
count int
|
||||
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
embedded.Float64Counter
|
||||
embedded.Float64UpDownCounter
|
||||
embedded.Float64Histogram
|
||||
@ -163,17 +162,17 @@ type testCountingFloatInstrument struct {
|
||||
func (i *testCountingFloatInstrument) observe() {
|
||||
i.count++
|
||||
}
|
||||
func (i *testCountingFloatInstrument) Add(context.Context, float64, ...instrument.AddOption) {
|
||||
func (i *testCountingFloatInstrument) Add(context.Context, float64, ...metric.AddOption) {
|
||||
i.count++
|
||||
}
|
||||
func (i *testCountingFloatInstrument) Record(context.Context, float64, ...instrument.RecordOption) {
|
||||
func (i *testCountingFloatInstrument) Record(context.Context, float64, ...metric.RecordOption) {
|
||||
i.count++
|
||||
}
|
||||
|
||||
type testCountingIntInstrument struct {
|
||||
count int
|
||||
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
embedded.Int64Counter
|
||||
embedded.Int64UpDownCounter
|
||||
embedded.Int64Histogram
|
||||
@ -185,9 +184,9 @@ type testCountingIntInstrument struct {
|
||||
func (i *testCountingIntInstrument) observe() {
|
||||
i.count++
|
||||
}
|
||||
func (i *testCountingIntInstrument) Add(context.Context, int64, ...instrument.AddOption) {
|
||||
func (i *testCountingIntInstrument) Add(context.Context, int64, ...metric.AddOption) {
|
||||
i.count++
|
||||
}
|
||||
func (i *testCountingIntInstrument) Record(context.Context, int64, ...instrument.RecordOption) {
|
||||
func (i *testCountingIntInstrument) Record(context.Context, int64, ...metric.RecordOption) {
|
||||
i.count++
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// meterProvider is a placeholder for a configured SDK MeterProvider.
|
||||
@ -147,7 +146,7 @@ func (m *meter) setDelegate(provider metric.MeterProvider) {
|
||||
m.registry.Init()
|
||||
}
|
||||
|
||||
func (m *meter) Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
|
||||
func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Counter(name, options...)
|
||||
}
|
||||
@ -158,7 +157,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64CounterOpti
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64UpDownCounter(name, options...)
|
||||
}
|
||||
@ -169,7 +168,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64UpDow
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64Histogram(name string, options ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
|
||||
func (m *meter) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Histogram(name, options...)
|
||||
}
|
||||
@ -180,7 +179,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Histogram
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableCounter(name, options...)
|
||||
}
|
||||
@ -191,7 +190,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
@ -202,7 +201,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableGauge(name, options...)
|
||||
}
|
||||
@ -213,7 +212,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Counter(name string, options ...instrument.Float64CounterOption) (instrument.Float64Counter, error) {
|
||||
func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Counter(name, options...)
|
||||
}
|
||||
@ -224,7 +223,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Counter
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64UpDownCounter(name, options...)
|
||||
}
|
||||
@ -235,7 +234,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64U
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Histogram(name string, options ...instrument.Float64HistogramOption) (instrument.Float64Histogram, error) {
|
||||
func (m *meter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Histogram(name, options...)
|
||||
}
|
||||
@ -246,7 +245,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Histo
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableCounter(name, options...)
|
||||
}
|
||||
@ -257,7 +256,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
@ -268,7 +267,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableGauge(name, options...)
|
||||
}
|
||||
@ -280,7 +279,7 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6
|
||||
}
|
||||
|
||||
// RegisterCallback captures the function that will be called during Collect.
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Observable) (metric.Registration, error) {
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable) (metric.Registration, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
insts = unwrapInstruments(insts)
|
||||
return del.RegisterCallback(f, insts...)
|
||||
@ -301,11 +300,11 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Observab
|
||||
}
|
||||
|
||||
type wrapped interface {
|
||||
unwrap() instrument.Observable
|
||||
unwrap() metric.Observable
|
||||
}
|
||||
|
||||
func unwrapInstruments(instruments []instrument.Observable) []instrument.Observable {
|
||||
out := make([]instrument.Observable, 0, len(instruments))
|
||||
func unwrapInstruments(instruments []metric.Observable) []metric.Observable {
|
||||
out := make([]metric.Observable, 0, len(instruments))
|
||||
|
||||
for _, inst := range instruments {
|
||||
if in, ok := inst.(wrapped); ok {
|
||||
@ -321,7 +320,7 @@ func unwrapInstruments(instruments []instrument.Observable) []instrument.Observa
|
||||
type registration struct {
|
||||
embedded.Registration
|
||||
|
||||
instruments []instrument.Observable
|
||||
instruments []metric.Observable
|
||||
function metric.Callback
|
||||
|
||||
unreg func() error
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
)
|
||||
|
||||
@ -118,7 +117,7 @@ func TestUnregisterRace(t *testing.T) {
|
||||
close(finish)
|
||||
}
|
||||
|
||||
func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (instrument.Float64Counter, instrument.Float64ObservableCounter) {
|
||||
func testSetupAllInstrumentTypes(t *testing.T, m metric.Meter) (metric.Float64Counter, metric.Float64ObservableCounter) {
|
||||
afcounter, err := m.Float64ObservableCounter("test_Async_Counter")
|
||||
require.NoError(t, err)
|
||||
_, err = m.Float64ObservableUpDownCounter("test_Async_UpDownCounter")
|
||||
|
@ -19,7 +19,6 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
type testMeterProvider struct {
|
||||
@ -56,68 +55,68 @@ type testMeter struct {
|
||||
callbacks []metric.Callback
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
|
||||
func (m *testMeter) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
m.siCount++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
|
||||
func (m *testMeter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
m.siUDCount++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64Histogram(name string, options ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
|
||||
func (m *testMeter) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
m.siHist++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
|
||||
func (m *testMeter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
m.aiCount++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
m.aiUDCount++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
|
||||
func (m *testMeter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
m.aiGauge++
|
||||
return &testCountingIntInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64Counter(name string, options ...instrument.Float64CounterOption) (instrument.Float64Counter, error) {
|
||||
func (m *testMeter) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
m.sfCount++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
|
||||
func (m *testMeter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
m.sfUDCount++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64Histogram(name string, options ...instrument.Float64HistogramOption) (instrument.Float64Histogram, error) {
|
||||
func (m *testMeter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
m.sfHist++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
|
||||
func (m *testMeter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
m.afCount++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
m.afUDCount++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
|
||||
func (m *testMeter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
m.afGauge++
|
||||
return &testCountingFloatInstrument{}, nil
|
||||
}
|
||||
|
||||
// RegisterCallback captures the function that will be called during Collect.
|
||||
func (m *testMeter) RegisterCallback(f metric.Callback, i ...instrument.Observable) (metric.Registration, error) {
|
||||
func (m *testMeter) RegisterCallback(f metric.Callback, i ...metric.Observable) (metric.Registration, error) {
|
||||
m.callbacks = append(m.callbacks, f)
|
||||
return testReg{
|
||||
f: func(idx int) func() {
|
||||
@ -156,14 +155,14 @@ type observationRecorder struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (o observationRecorder) ObserveFloat64(i instrument.Float64Observable, value float64, _ ...instrument.ObserveOption) {
|
||||
func (o observationRecorder) ObserveFloat64(i metric.Float64Observable, value float64, _ ...metric.ObserveOption) {
|
||||
iImpl, ok := i.(*testCountingFloatInstrument)
|
||||
if ok {
|
||||
iImpl.observe()
|
||||
}
|
||||
}
|
||||
|
||||
func (o observationRecorder) ObserveInt64(i instrument.Int64Observable, value int64, _ ...instrument.ObserveOption) {
|
||||
func (o observationRecorder) ObserveInt64(i metric.Int64Observable, value int64, _ ...metric.ObserveOption) {
|
||||
iImpl, ok := i.(*testCountingIntInstrument)
|
||||
if ok {
|
||||
iImpl.observe()
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// MeterProvider provides access to named Meter instances, for instrumenting
|
||||
@ -53,56 +52,56 @@ type Meter interface {
|
||||
// Int64Counter returns a new instrument identified by name and configured
|
||||
// with options. The instrument is used to synchronously record increasing
|
||||
// int64 measurements during a computational operation.
|
||||
Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error)
|
||||
Int64Counter(name string, options ...Int64CounterOption) (Int64Counter, 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.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error)
|
||||
Int64UpDownCounter(name string, options ...Int64UpDownCounterOption) (Int64UpDownCounter, 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.Int64HistogramOption) (instrument.Int64Histogram, error)
|
||||
Int64Histogram(name string, options ...Int64HistogramOption) (Int64Histogram, 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.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error)
|
||||
Int64ObservableCounter(name string, options ...Int64ObservableCounterOption) (Int64ObservableCounter, 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.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error)
|
||||
Int64ObservableUpDownCounter(name string, options ...Int64ObservableUpDownCounterOption) (Int64ObservableUpDownCounter, 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.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error)
|
||||
Int64ObservableGauge(name string, options ...Int64ObservableGaugeOption) (Int64ObservableGauge, error)
|
||||
|
||||
// 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.
|
||||
Float64Counter(name string, options ...instrument.Float64CounterOption) (instrument.Float64Counter, error)
|
||||
Float64Counter(name string, options ...Float64CounterOption) (Float64Counter, error)
|
||||
// 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.
|
||||
Float64UpDownCounter(name string, options ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error)
|
||||
Float64UpDownCounter(name string, options ...Float64UpDownCounterOption) (Float64UpDownCounter, error)
|
||||
// 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.Float64HistogramOption) (instrument.Float64Histogram, error)
|
||||
Float64Histogram(name string, options ...Float64HistogramOption) (Float64Histogram, 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.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error)
|
||||
Float64ObservableCounter(name string, options ...Float64ObservableCounterOption) (Float64ObservableCounter, 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.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error)
|
||||
Float64ObservableUpDownCounter(name string, options ...Float64ObservableUpDownCounterOption) (Float64ObservableUpDownCounter, 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.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error)
|
||||
Float64ObservableGauge(name string, options ...Float64ObservableGaugeOption) (Float64ObservableGauge, error)
|
||||
|
||||
// RegisterCallback registers f to be called during the collection of a
|
||||
// measurement cycle.
|
||||
@ -115,7 +114,7 @@ type Meter interface {
|
||||
//
|
||||
// If no instruments are passed, f should not be registered nor called
|
||||
// during collection.
|
||||
RegisterCallback(f Callback, instruments ...instrument.Observable) (Registration, error)
|
||||
RegisterCallback(f Callback, instruments ...Observable) (Registration, error)
|
||||
}
|
||||
|
||||
// Callback is a function registered with a Meter that makes observations for
|
||||
@ -141,9 +140,9 @@ type Observer interface {
|
||||
embedded.Observer
|
||||
|
||||
// ObserveFloat64 records the float64 value for obsrv.
|
||||
ObserveFloat64(obsrv instrument.Float64Observable, value float64, opts ...instrument.ObserveOption)
|
||||
ObserveFloat64(obsrv Float64Observable, value float64, opts ...ObserveOption)
|
||||
// ObserveInt64 records the int64 value for obsrv.
|
||||
ObserveInt64(obsrv instrument.Int64Observable, value int64, opts ...instrument.ObserveOption)
|
||||
ObserveInt64(obsrv Int64Observable, value int64, opts ...ObserveOption)
|
||||
}
|
||||
|
||||
// Registration is an token representing the unique registration of a callback
|
||||
|
@ -28,30 +28,29 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
var (
|
||||
// Compile-time check this implements the OpenTelemetry API.
|
||||
|
||||
_ metric.MeterProvider = MeterProvider{}
|
||||
_ metric.Meter = Meter{}
|
||||
_ metric.Observer = Observer{}
|
||||
_ metric.Registration = Registration{}
|
||||
_ instrument.Int64Counter = Int64Counter{}
|
||||
_ instrument.Float64Counter = Float64Counter{}
|
||||
_ instrument.Int64UpDownCounter = Int64UpDownCounter{}
|
||||
_ instrument.Float64UpDownCounter = Float64UpDownCounter{}
|
||||
_ instrument.Int64Histogram = Int64Histogram{}
|
||||
_ instrument.Float64Histogram = Float64Histogram{}
|
||||
_ instrument.Int64ObservableCounter = Int64ObservableCounter{}
|
||||
_ instrument.Float64ObservableCounter = Float64ObservableCounter{}
|
||||
_ instrument.Int64ObservableGauge = Int64ObservableGauge{}
|
||||
_ instrument.Float64ObservableGauge = Float64ObservableGauge{}
|
||||
_ instrument.Int64ObservableUpDownCounter = Int64ObservableUpDownCounter{}
|
||||
_ instrument.Float64ObservableUpDownCounter = Float64ObservableUpDownCounter{}
|
||||
_ instrument.Int64Observer = Int64Observer{}
|
||||
_ instrument.Float64Observer = Float64Observer{}
|
||||
_ metric.MeterProvider = MeterProvider{}
|
||||
_ metric.Meter = Meter{}
|
||||
_ metric.Observer = Observer{}
|
||||
_ metric.Registration = Registration{}
|
||||
_ metric.Int64Counter = Int64Counter{}
|
||||
_ metric.Float64Counter = Float64Counter{}
|
||||
_ metric.Int64UpDownCounter = Int64UpDownCounter{}
|
||||
_ metric.Float64UpDownCounter = Float64UpDownCounter{}
|
||||
_ metric.Int64Histogram = Int64Histogram{}
|
||||
_ metric.Float64Histogram = Float64Histogram{}
|
||||
_ metric.Int64ObservableCounter = Int64ObservableCounter{}
|
||||
_ metric.Float64ObservableCounter = Float64ObservableCounter{}
|
||||
_ metric.Int64ObservableGauge = Int64ObservableGauge{}
|
||||
_ metric.Float64ObservableGauge = Float64ObservableGauge{}
|
||||
_ metric.Int64ObservableUpDownCounter = Int64ObservableUpDownCounter{}
|
||||
_ metric.Float64ObservableUpDownCounter = Float64ObservableUpDownCounter{}
|
||||
_ metric.Int64Observer = Int64Observer{}
|
||||
_ metric.Float64Observer = Float64Observer{}
|
||||
)
|
||||
|
||||
// MeterProvider is an OpenTelemetry No-Op MeterProvider.
|
||||
@ -72,78 +71,78 @@ type Meter struct{ embedded.Meter }
|
||||
|
||||
// Int64Counter returns a Counter used to record int64 measurements that
|
||||
// produces no telemetry.
|
||||
func (Meter) Int64Counter(string, ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
|
||||
func (Meter) Int64Counter(string, ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
return Int64Counter{}, nil
|
||||
}
|
||||
|
||||
// Int64UpDownCounter returns an UpDownCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Int64UpDownCounter(string, ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
|
||||
func (Meter) Int64UpDownCounter(string, ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
return Int64UpDownCounter{}, nil
|
||||
}
|
||||
|
||||
// Int64Histogram returns a Histogram used to record int64 measurements that
|
||||
// produces no telemetry.
|
||||
func (Meter) Int64Histogram(string, ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
|
||||
func (Meter) Int64Histogram(string, ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
return Int64Histogram{}, nil
|
||||
}
|
||||
|
||||
// Int64ObservableCounter returns an ObservableCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Int64ObservableCounter(string, ...instrument.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
|
||||
func (Meter) Int64ObservableCounter(string, ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
return Int64ObservableCounter{}, nil
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounter returns an ObservableUpDownCounter used to
|
||||
// record int64 measurements that produces no telemetry.
|
||||
func (Meter) Int64ObservableUpDownCounter(string, ...instrument.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
func (Meter) Int64ObservableUpDownCounter(string, ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
return Int64ObservableUpDownCounter{}, nil
|
||||
}
|
||||
|
||||
// Int64ObservableGauge returns an ObservableGauge used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Int64ObservableGauge(string, ...instrument.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
|
||||
func (Meter) Int64ObservableGauge(string, ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
return Int64ObservableGauge{}, nil
|
||||
}
|
||||
|
||||
// Float64Counter returns a Counter used to record int64 measurements that
|
||||
// produces no telemetry.
|
||||
func (Meter) Float64Counter(string, ...instrument.Float64CounterOption) (instrument.Float64Counter, error) {
|
||||
func (Meter) Float64Counter(string, ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
return Float64Counter{}, nil
|
||||
}
|
||||
|
||||
// Float64UpDownCounter returns an UpDownCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Float64UpDownCounter(string, ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
|
||||
func (Meter) Float64UpDownCounter(string, ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
return Float64UpDownCounter{}, nil
|
||||
}
|
||||
|
||||
// Float64Histogram returns a Histogram used to record int64 measurements that
|
||||
// produces no telemetry.
|
||||
func (Meter) Float64Histogram(string, ...instrument.Float64HistogramOption) (instrument.Float64Histogram, error) {
|
||||
func (Meter) Float64Histogram(string, ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
return Float64Histogram{}, nil
|
||||
}
|
||||
|
||||
// Float64ObservableCounter returns an ObservableCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableCounter(string, ...instrument.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
|
||||
func (Meter) Float64ObservableCounter(string, ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
return Float64ObservableCounter{}, nil
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounter returns an ObservableUpDownCounter used to
|
||||
// record int64 measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableUpDownCounter(string, ...instrument.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
func (Meter) Float64ObservableUpDownCounter(string, ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
return Float64ObservableUpDownCounter{}, nil
|
||||
}
|
||||
|
||||
// Float64ObservableGauge returns an ObservableGauge used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableGauge(string, ...instrument.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
|
||||
func (Meter) Float64ObservableGauge(string, ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
return Float64ObservableGauge{}, nil
|
||||
}
|
||||
|
||||
// RegisterCallback performs no operation.
|
||||
func (Meter) RegisterCallback(metric.Callback, ...instrument.Observable) (metric.Registration, error) {
|
||||
func (Meter) RegisterCallback(metric.Callback, ...metric.Observable) (metric.Registration, error) {
|
||||
return Registration{}, nil
|
||||
}
|
||||
|
||||
@ -152,11 +151,11 @@ func (Meter) RegisterCallback(metric.Callback, ...instrument.Observable) (metric
|
||||
type Observer struct{ embedded.Observer }
|
||||
|
||||
// ObserveFloat64 performs no operation.
|
||||
func (Observer) ObserveFloat64(instrument.Float64Observable, float64, ...instrument.ObserveOption) {
|
||||
func (Observer) ObserveFloat64(metric.Float64Observable, float64, ...metric.ObserveOption) {
|
||||
}
|
||||
|
||||
// ObserveInt64 performs no operation.
|
||||
func (Observer) ObserveInt64(instrument.Int64Observable, int64, ...instrument.ObserveOption) {
|
||||
func (Observer) ObserveInt64(metric.Int64Observable, int64, ...metric.ObserveOption) {
|
||||
}
|
||||
|
||||
// Registration is the registration of a Callback with a No-Op Meter.
|
||||
@ -172,82 +171,82 @@ func (Registration) Unregister() error { return nil }
|
||||
type Int64Counter struct{ embedded.Int64Counter }
|
||||
|
||||
// Add performs no operation.
|
||||
func (Int64Counter) Add(context.Context, int64, ...instrument.AddOption) {}
|
||||
func (Int64Counter) Add(context.Context, int64, ...metric.AddOption) {}
|
||||
|
||||
// Float64Counter is an OpenTelemetry Counter used to record float64
|
||||
// measurements. It produces no telemetry.
|
||||
type Float64Counter struct{ embedded.Float64Counter }
|
||||
|
||||
// Add performs no operation.
|
||||
func (Float64Counter) Add(context.Context, float64, ...instrument.AddOption) {}
|
||||
func (Float64Counter) Add(context.Context, float64, ...metric.AddOption) {}
|
||||
|
||||
// Int64UpDownCounter is an OpenTelemetry UpDownCounter used to record int64
|
||||
// measurements. It produces no telemetry.
|
||||
type Int64UpDownCounter struct{ embedded.Int64UpDownCounter }
|
||||
|
||||
// Add performs no operation.
|
||||
func (Int64UpDownCounter) Add(context.Context, int64, ...instrument.AddOption) {}
|
||||
func (Int64UpDownCounter) Add(context.Context, int64, ...metric.AddOption) {}
|
||||
|
||||
// Float64UpDownCounter is an OpenTelemetry UpDownCounter used to record
|
||||
// float64 measurements. It produces no telemetry.
|
||||
type Float64UpDownCounter struct{ embedded.Float64UpDownCounter }
|
||||
|
||||
// Add performs no operation.
|
||||
func (Float64UpDownCounter) Add(context.Context, float64, ...instrument.AddOption) {}
|
||||
func (Float64UpDownCounter) Add(context.Context, float64, ...metric.AddOption) {}
|
||||
|
||||
// Int64Histogram is an OpenTelemetry Histogram used to record int64
|
||||
// measurements. It produces no telemetry.
|
||||
type Int64Histogram struct{ embedded.Int64Histogram }
|
||||
|
||||
// Record performs no operation.
|
||||
func (Int64Histogram) Record(context.Context, int64, ...instrument.RecordOption) {}
|
||||
func (Int64Histogram) Record(context.Context, int64, ...metric.RecordOption) {}
|
||||
|
||||
// Float64Histogram is an OpenTelemetry Histogram used to record float64
|
||||
// measurements. It produces no telemetry.
|
||||
type Float64Histogram struct{ embedded.Float64Histogram }
|
||||
|
||||
// Record performs no operation.
|
||||
func (Float64Histogram) Record(context.Context, float64, ...instrument.RecordOption) {}
|
||||
func (Float64Histogram) Record(context.Context, float64, ...metric.RecordOption) {}
|
||||
|
||||
// Int64ObservableCounter is an OpenTelemetry ObservableCounter used to record
|
||||
// int64 measurements. It produces no telemetry.
|
||||
type Int64ObservableCounter struct {
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
embedded.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// Float64ObservableCounter is an OpenTelemetry ObservableCounter used to record
|
||||
// float64 measurements. It produces no telemetry.
|
||||
type Float64ObservableCounter struct {
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
embedded.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// Int64ObservableGauge is an OpenTelemetry ObservableGauge used to record
|
||||
// int64 measurements. It produces no telemetry.
|
||||
type Int64ObservableGauge struct {
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
embedded.Int64ObservableGauge
|
||||
}
|
||||
|
||||
// Float64ObservableGauge is an OpenTelemetry ObservableGauge used to record
|
||||
// float64 measurements. It produces no telemetry.
|
||||
type Float64ObservableGauge struct {
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
embedded.Float64ObservableGauge
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounter is an OpenTelemetry ObservableUpDownCounter
|
||||
// used to record int64 measurements. It produces no telemetry.
|
||||
type Int64ObservableUpDownCounter struct {
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounter is an OpenTelemetry ObservableUpDownCounter
|
||||
// used to record float64 measurements. It produces no telemetry.
|
||||
type Float64ObservableUpDownCounter struct {
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
@ -255,11 +254,11 @@ type Float64ObservableUpDownCounter struct {
|
||||
type Int64Observer struct{ embedded.Int64Observer }
|
||||
|
||||
// Observe performs no operation.
|
||||
func (Int64Observer) Observe(int64, ...instrument.ObserveOption) {}
|
||||
func (Int64Observer) Observe(int64, ...metric.ObserveOption) {}
|
||||
|
||||
// Float64Observer is a recorder of float64 measurements that performs no
|
||||
// operation.
|
||||
type Float64Observer struct{ embedded.Float64Observer }
|
||||
|
||||
// Observe performs no operation.
|
||||
func (Float64Observer) Observe(float64, ...instrument.ObserveOption) {}
|
||||
func (Float64Observer) Observe(float64, ...metric.ObserveOption) {}
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
func TestImplementationNoPanics(t *testing.T) {
|
||||
@ -45,59 +44,59 @@ func TestImplementationNoPanics(t *testing.T) {
|
||||
))
|
||||
t.Run("Int64Counter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64Counter{}),
|
||||
reflect.TypeOf((*instrument.Int64Counter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64Counter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64Counter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64Counter{}),
|
||||
reflect.TypeOf((*instrument.Float64Counter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64Counter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64UpDownCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64UpDownCounter{}),
|
||||
reflect.TypeOf((*instrument.Int64UpDownCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64UpDownCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64UpDownCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64UpDownCounter{}),
|
||||
reflect.TypeOf((*instrument.Float64UpDownCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64UpDownCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64Histogram", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64Histogram{}),
|
||||
reflect.TypeOf((*instrument.Int64Histogram)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64Histogram)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64Histogram", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64Histogram{}),
|
||||
reflect.TypeOf((*instrument.Float64Histogram)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64Histogram)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64ObservableCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64ObservableCounter{}),
|
||||
reflect.TypeOf((*instrument.Int64ObservableCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64ObservableCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64ObservableCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64ObservableCounter{}),
|
||||
reflect.TypeOf((*instrument.Float64ObservableCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64ObservableCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64ObservableGauge", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64ObservableGauge{}),
|
||||
reflect.TypeOf((*instrument.Int64ObservableGauge)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64ObservableGauge)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64ObservableGauge", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64ObservableGauge{}),
|
||||
reflect.TypeOf((*instrument.Float64ObservableGauge)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64ObservableGauge)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64ObservableUpDownCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64ObservableUpDownCounter{}),
|
||||
reflect.TypeOf((*instrument.Int64ObservableUpDownCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64ObservableUpDownCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64ObservableUpDownCounter", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64ObservableUpDownCounter{}),
|
||||
reflect.TypeOf((*instrument.Float64ObservableUpDownCounter)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64ObservableUpDownCounter)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Int64Observer", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Int64Observer{}),
|
||||
reflect.TypeOf((*instrument.Int64Observer)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Int64Observer)(nil)).Elem(),
|
||||
))
|
||||
t.Run("Float64Observer", assertAllExportedMethodNoPanic(
|
||||
reflect.ValueOf(Float64Observer{}),
|
||||
reflect.TypeOf((*instrument.Float64Observer)(nil)).Elem(),
|
||||
reflect.TypeOf((*metric.Float64Observer)(nil)).Elem(),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"testing"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"testing"
|
@ -23,7 +23,6 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
)
|
||||
@ -67,7 +66,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Int64Counter", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.AddOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.AddOption{metric.WithAttributeSet(s)}
|
||||
return func() { iCtr.Add(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -76,7 +75,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Float64Counter", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.AddOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.AddOption{metric.WithAttributeSet(s)}
|
||||
return func() { fCtr.Add(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -85,7 +84,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Int64UpDownCounter", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.AddOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.AddOption{metric.WithAttributeSet(s)}
|
||||
return func() { iUDCtr.Add(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -94,7 +93,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Float64UpDownCounter", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.AddOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.AddOption{metric.WithAttributeSet(s)}
|
||||
return func() { fUDCtr.Add(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -103,7 +102,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Int64Histogram", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.RecordOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.RecordOption{metric.WithAttributeSet(s)}
|
||||
return func() { iHist.Record(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -112,7 +111,7 @@ func benchSyncViews(views ...View) func(*testing.B) {
|
||||
assert.NoError(b, err)
|
||||
b.Run("Float64Histogram", benchMeasAttrs(func() measF {
|
||||
return func(s attribute.Set) func() {
|
||||
o := []instrument.RecordOption{instrument.WithAttributeSet(s)}
|
||||
o := []metric.RecordOption{metric.WithAttributeSet(s)}
|
||||
return func() { fHist.Record(ctx, 1, o...) }
|
||||
}
|
||||
}()))
|
||||
@ -174,7 +173,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64Counter")
|
||||
i, err := m.Int64Counter("int64-counter")
|
||||
assert.NoError(b, err)
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Int64Counter/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -182,7 +181,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Int64Counter("int64-counter")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -191,7 +190,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64Counter")
|
||||
i, err := m.Float64Counter("float64-counter")
|
||||
assert.NoError(b, err)
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Float64Counter/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -199,7 +198,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Float64Counter("float64-counter")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -208,7 +207,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64UpDownCounter")
|
||||
i, err := m.Int64UpDownCounter("int64-up-down-counter")
|
||||
assert.NoError(b, err)
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Int64UpDownCounter/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -216,7 +215,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Int64UpDownCounter("int64-up-down-counter")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -225,7 +224,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64UpDownCounter")
|
||||
i, err := m.Float64UpDownCounter("float64-up-down-counter")
|
||||
assert.NoError(b, err)
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Float64UpDownCounter/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -233,7 +232,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Float64UpDownCounter("float64-up-down-counter")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Add(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Add(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -242,7 +241,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64Histogram")
|
||||
i, err := m.Int64Histogram("int64-histogram")
|
||||
assert.NoError(b, err)
|
||||
i.Record(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Record(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Int64Histogram/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -250,7 +249,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Int64Histogram("int64-histogram")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Record(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Record(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -259,7 +258,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64Histogram")
|
||||
i, err := m.Float64Histogram("float64-histogram")
|
||||
assert.NoError(b, err)
|
||||
i.Record(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Record(ctx, 1, metric.WithAttributeSet(s))
|
||||
return r
|
||||
}))
|
||||
b.Run("Float64Histogram/10", benchCollectAttrs(func(s attribute.Set) Reader {
|
||||
@ -267,7 +266,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
i, err := m.Float64Histogram("float64-histogram")
|
||||
assert.NoError(b, err)
|
||||
for n := 0; n < 10; n++ {
|
||||
i.Record(ctx, 1, instrument.WithAttributeSet(s))
|
||||
i.Record(ctx, 1, metric.WithAttributeSet(s))
|
||||
}
|
||||
return r
|
||||
}))
|
||||
@ -276,7 +275,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64ObservableCounter")
|
||||
_, err := m.Int64ObservableCounter(
|
||||
"int64-observable-counter",
|
||||
instrument.WithInt64Callback(int64Cback(s)),
|
||||
metric.WithInt64Callback(int64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -286,7 +285,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64ObservableCounter")
|
||||
_, err := m.Float64ObservableCounter(
|
||||
"float64-observable-counter",
|
||||
instrument.WithFloat64Callback(float64Cback(s)),
|
||||
metric.WithFloat64Callback(float64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -296,7 +295,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64ObservableUpDownCounter")
|
||||
_, err := m.Int64ObservableUpDownCounter(
|
||||
"int64-observable-up-down-counter",
|
||||
instrument.WithInt64Callback(int64Cback(s)),
|
||||
metric.WithInt64Callback(int64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -306,7 +305,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64ObservableUpDownCounter")
|
||||
_, err := m.Float64ObservableUpDownCounter(
|
||||
"float64-observable-up-down-counter",
|
||||
instrument.WithFloat64Callback(float64Cback(s)),
|
||||
metric.WithFloat64Callback(float64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -316,7 +315,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Int64ObservableGauge")
|
||||
_, err := m.Int64ObservableGauge(
|
||||
"int64-observable-gauge",
|
||||
instrument.WithInt64Callback(int64Cback(s)),
|
||||
metric.WithInt64Callback(int64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -326,7 +325,7 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
m, r := setup("benchCollectViews/Float64ObservableGauge")
|
||||
_, err := m.Float64ObservableGauge(
|
||||
"float64-observable-gauge",
|
||||
instrument.WithFloat64Callback(float64Cback(s)),
|
||||
metric.WithFloat64Callback(float64Cback(s)),
|
||||
)
|
||||
assert.NoError(b, err)
|
||||
return r
|
||||
@ -334,17 +333,17 @@ func benchCollectViews(views ...View) func(*testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func int64Cback(s attribute.Set) instrument.Int64Callback {
|
||||
opt := []instrument.ObserveOption{instrument.WithAttributeSet(s)}
|
||||
return func(_ context.Context, o instrument.Int64Observer) error {
|
||||
func int64Cback(s attribute.Set) metric.Int64Callback {
|
||||
opt := []metric.ObserveOption{metric.WithAttributeSet(s)}
|
||||
return func(_ context.Context, o metric.Int64Observer) error {
|
||||
o.Observe(1, opt...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func float64Cback(s attribute.Set) instrument.Float64Callback {
|
||||
opt := []instrument.ObserveOption{instrument.WithAttributeSet(s)}
|
||||
return func(_ context.Context, o instrument.Float64Observer) error {
|
||||
func float64Cback(s attribute.Set) metric.Float64Callback {
|
||||
opt := []metric.ObserveOption{metric.WithAttributeSet(s)}
|
||||
return func(_ context.Context, o metric.Float64Observer) error {
|
||||
o.Observe(1, opt...)
|
||||
return nil
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal"
|
||||
@ -178,17 +178,17 @@ type int64Inst struct {
|
||||
embedded.Int64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Int64Counter = (*int64Inst)(nil)
|
||||
var _ instrument.Int64UpDownCounter = (*int64Inst)(nil)
|
||||
var _ instrument.Int64Histogram = (*int64Inst)(nil)
|
||||
var _ metric.Int64Counter = (*int64Inst)(nil)
|
||||
var _ metric.Int64UpDownCounter = (*int64Inst)(nil)
|
||||
var _ metric.Int64Histogram = (*int64Inst)(nil)
|
||||
|
||||
func (i *int64Inst) Add(ctx context.Context, val int64, opts ...instrument.AddOption) {
|
||||
c := instrument.NewAddConfig(opts)
|
||||
func (i *int64Inst) Add(ctx context.Context, val int64, opts ...metric.AddOption) {
|
||||
c := metric.NewAddConfig(opts)
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
func (i *int64Inst) Record(ctx context.Context, val int64, opts ...instrument.RecordOption) {
|
||||
c := instrument.NewRecordConfig(opts)
|
||||
func (i *int64Inst) Record(ctx context.Context, val int64, opts ...metric.RecordOption) {
|
||||
c := metric.NewRecordConfig(opts)
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
@ -209,17 +209,17 @@ type float64Inst struct {
|
||||
embedded.Float64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Float64Counter = (*float64Inst)(nil)
|
||||
var _ instrument.Float64UpDownCounter = (*float64Inst)(nil)
|
||||
var _ instrument.Float64Histogram = (*float64Inst)(nil)
|
||||
var _ metric.Float64Counter = (*float64Inst)(nil)
|
||||
var _ metric.Float64UpDownCounter = (*float64Inst)(nil)
|
||||
var _ metric.Float64Histogram = (*float64Inst)(nil)
|
||||
|
||||
func (i *float64Inst) Add(ctx context.Context, val float64, opts ...instrument.AddOption) {
|
||||
c := instrument.NewAddConfig(opts)
|
||||
func (i *float64Inst) Add(ctx context.Context, val float64, opts ...metric.AddOption) {
|
||||
c := metric.NewAddConfig(opts)
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
func (i *float64Inst) Record(ctx context.Context, val float64, opts ...instrument.RecordOption) {
|
||||
c := instrument.NewRecordConfig(opts)
|
||||
func (i *float64Inst) Record(ctx context.Context, val float64, opts ...metric.RecordOption) {
|
||||
c := metric.NewRecordConfig(opts)
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ type observablID[N int64 | float64] struct {
|
||||
}
|
||||
|
||||
type float64Observable struct {
|
||||
instrument.Float64Observable
|
||||
metric.Float64Observable
|
||||
*observable[float64]
|
||||
|
||||
embedded.Float64ObservableCounter
|
||||
@ -250,9 +250,9 @@ type float64Observable struct {
|
||||
embedded.Float64ObservableGauge
|
||||
}
|
||||
|
||||
var _ instrument.Float64ObservableCounter = float64Observable{}
|
||||
var _ instrument.Float64ObservableUpDownCounter = float64Observable{}
|
||||
var _ instrument.Float64ObservableGauge = float64Observable{}
|
||||
var _ metric.Float64ObservableCounter = float64Observable{}
|
||||
var _ metric.Float64ObservableUpDownCounter = float64Observable{}
|
||||
var _ metric.Float64ObservableGauge = float64Observable{}
|
||||
|
||||
func newFloat64Observable(scope instrumentation.Scope, kind InstrumentKind, name, desc, u string, agg []internal.Aggregator[float64]) float64Observable {
|
||||
return float64Observable{
|
||||
@ -261,7 +261,7 @@ func newFloat64Observable(scope instrumentation.Scope, kind InstrumentKind, name
|
||||
}
|
||||
|
||||
type int64Observable struct {
|
||||
instrument.Int64Observable
|
||||
metric.Int64Observable
|
||||
*observable[int64]
|
||||
|
||||
embedded.Int64ObservableCounter
|
||||
@ -269,9 +269,9 @@ type int64Observable struct {
|
||||
embedded.Int64ObservableGauge
|
||||
}
|
||||
|
||||
var _ instrument.Int64ObservableCounter = int64Observable{}
|
||||
var _ instrument.Int64ObservableUpDownCounter = int64Observable{}
|
||||
var _ instrument.Int64ObservableGauge = int64Observable{}
|
||||
var _ metric.Int64ObservableCounter = int64Observable{}
|
||||
var _ metric.Int64ObservableUpDownCounter = int64Observable{}
|
||||
var _ metric.Int64ObservableGauge = int64Observable{}
|
||||
|
||||
func newInt64Observable(scope instrumentation.Scope, kind InstrumentKind, name, desc, u string, agg []internal.Aggregator[int64]) int64Observable {
|
||||
return int64Observable{
|
||||
@ -280,7 +280,7 @@ func newInt64Observable(scope instrumentation.Scope, kind InstrumentKind, name,
|
||||
}
|
||||
|
||||
type observable[N int64 | float64] struct {
|
||||
instrument.Observable
|
||||
metric.Observable
|
||||
observablID[N]
|
||||
|
||||
aggregators []internal.Aggregator[N]
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
)
|
||||
@ -31,7 +31,7 @@ type meter struct {
|
||||
aggregations []metricdata.Aggregation
|
||||
}
|
||||
|
||||
func (p *meter) Int64Counter(string, ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
|
||||
func (p *meter) Int64Counter(string, ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
// This is an example of how a meter 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
|
||||
@ -47,7 +47,7 @@ func (p *meter) Int64Counter(string, ...instrument.Int64CounterOption) (instrume
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (p *meter) Int64UpDownCounter(string, ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
|
||||
func (p *meter) Int64UpDownCounter(string, ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
// This is an example of how a meter would create an aggregator for a new
|
||||
// up-down counter. At this point the provider would determine the
|
||||
// aggregation and temporality to used based on the Reader and View
|
||||
@ -64,7 +64,7 @@ func (p *meter) Int64UpDownCounter(string, ...instrument.Int64UpDownCounterOptio
|
||||
return upDownCount, nil
|
||||
}
|
||||
|
||||
func (p *meter) Int64Histogram(string, ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
|
||||
func (p *meter) Int64Histogram(string, ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
// This is an example of how a meter would create an aggregator for a new
|
||||
// histogram. At this point the provider would determine the aggregation
|
||||
// and temporality to used based on the Reader and View configuration.
|
||||
@ -94,8 +94,8 @@ type inst struct {
|
||||
embedded.Int64Histogram
|
||||
}
|
||||
|
||||
func (inst) Add(context.Context, int64, ...instrument.AddOption) {}
|
||||
func (inst) Record(context.Context, int64, ...instrument.RecordOption) {}
|
||||
func (inst) Add(context.Context, int64, ...metric.AddOption) {}
|
||||
func (inst) Record(context.Context, int64, ...metric.RecordOption) {}
|
||||
|
||||
func Example() {
|
||||
m := meter{}
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal"
|
||||
)
|
||||
@ -60,8 +59,8 @@ var _ metric.Meter = (*meter)(nil)
|
||||
// Int64Counter returns a new instrument identified by name and configured with
|
||||
// options. The instrument is used to synchronously record increasing int64
|
||||
// measurements during a computational operation.
|
||||
func (m *meter) Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
|
||||
cfg := instrument.NewInt64CounterConfig(options...)
|
||||
func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
cfg := metric.NewInt64CounterConfig(options...)
|
||||
const kind = InstrumentKindCounter
|
||||
return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -69,8 +68,8 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64CounterOpti
|
||||
// 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.
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
|
||||
cfg := instrument.NewInt64UpDownCounterConfig(options...)
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
cfg := metric.NewInt64UpDownCounterConfig(options...)
|
||||
const kind = InstrumentKindUpDownCounter
|
||||
return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -78,8 +77,8 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64UpDow
|
||||
// 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.Int64HistogramOption) (instrument.Int64Histogram, error) {
|
||||
cfg := instrument.NewInt64HistogramConfig(options...)
|
||||
func (m *meter) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
cfg := metric.NewInt64HistogramConfig(options...)
|
||||
const kind = InstrumentKindHistogram
|
||||
return m.int64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -87,8 +86,8 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Histogram
|
||||
// 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.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
|
||||
cfg := instrument.NewInt64ObservableCounterConfig(options...)
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
cfg := metric.NewInt64ObservableCounterConfig(options...)
|
||||
const kind = InstrumentKindObservableCounter
|
||||
p := int64ObservProvider{m.int64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -102,8 +101,8 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O
|
||||
// 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.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
cfg := instrument.NewInt64ObservableUpDownCounterConfig(options...)
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
cfg := metric.NewInt64ObservableUpDownCounterConfig(options...)
|
||||
const kind = InstrumentKindObservableUpDownCounter
|
||||
p := int64ObservProvider{m.int64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -117,8 +116,8 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.
|
||||
// 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.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
|
||||
cfg := instrument.NewInt64ObservableGaugeConfig(options...)
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
cfg := metric.NewInt64ObservableGaugeConfig(options...)
|
||||
const kind = InstrumentKindObservableGauge
|
||||
p := int64ObservProvider{m.int64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -132,8 +131,8 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs
|
||||
// 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.Float64CounterOption) (instrument.Float64Counter, error) {
|
||||
cfg := instrument.NewFloat64CounterConfig(options...)
|
||||
func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
cfg := metric.NewFloat64CounterConfig(options...)
|
||||
const kind = InstrumentKindCounter
|
||||
return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -141,8 +140,8 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Counter
|
||||
// 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.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
|
||||
cfg := instrument.NewFloat64UpDownCounterConfig(options...)
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
cfg := metric.NewFloat64UpDownCounterConfig(options...)
|
||||
const kind = InstrumentKindUpDownCounter
|
||||
return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -150,8 +149,8 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64U
|
||||
// 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.Float64HistogramOption) (instrument.Float64Histogram, error) {
|
||||
cfg := instrument.NewFloat64HistogramConfig(options...)
|
||||
func (m *meter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
cfg := metric.NewFloat64HistogramConfig(options...)
|
||||
const kind = InstrumentKindHistogram
|
||||
return m.float64IP.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
}
|
||||
@ -159,8 +158,8 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Histo
|
||||
// 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.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
|
||||
cfg := instrument.NewFloat64ObservableCounterConfig(options...)
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
cfg := metric.NewFloat64ObservableCounterConfig(options...)
|
||||
const kind = InstrumentKindObservableCounter
|
||||
p := float64ObservProvider{m.float64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -174,8 +173,8 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa
|
||||
// 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.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
cfg := instrument.NewFloat64ObservableUpDownCounterConfig(options...)
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
cfg := metric.NewFloat64ObservableUpDownCounterConfig(options...)
|
||||
const kind = InstrumentKindObservableUpDownCounter
|
||||
p := float64ObservProvider{m.float64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -189,8 +188,8 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen
|
||||
// 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.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
|
||||
cfg := instrument.NewFloat64ObservableGaugeConfig(options...)
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
cfg := metric.NewFloat64ObservableGaugeConfig(options...)
|
||||
const kind = InstrumentKindObservableGauge
|
||||
p := float64ObservProvider{m.float64IP}
|
||||
inst, err := p.lookup(kind, name, cfg.Description(), cfg.Unit())
|
||||
@ -211,7 +210,7 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6
|
||||
// returned if other instrument are provided.
|
||||
//
|
||||
// The returned Registration can be used to unregister f.
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Observable) (metric.Registration, error) {
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable) (metric.Registration, error) {
|
||||
if len(insts) == 0 {
|
||||
// Don't allocate a observer if not needed.
|
||||
return noopRegister{}, nil
|
||||
@ -222,7 +221,7 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Observab
|
||||
for _, inst := range insts {
|
||||
// Unwrap any global.
|
||||
if u, ok := inst.(interface {
|
||||
Unwrap() instrument.Observable
|
||||
Unwrap() metric.Observable
|
||||
}); ok {
|
||||
inst = u.Unwrap()
|
||||
}
|
||||
@ -296,13 +295,13 @@ var (
|
||||
errUnregObserver = errors.New("observable instrument not registered for callback")
|
||||
)
|
||||
|
||||
func (r observer) ObserveFloat64(o instrument.Float64Observable, v float64, opts ...instrument.ObserveOption) {
|
||||
func (r observer) ObserveFloat64(o metric.Float64Observable, v float64, opts ...metric.ObserveOption) {
|
||||
var oImpl float64Observable
|
||||
switch conv := o.(type) {
|
||||
case float64Observable:
|
||||
oImpl = conv
|
||||
case interface {
|
||||
Unwrap() instrument.Observable
|
||||
Unwrap() metric.Observable
|
||||
}:
|
||||
// Unwrap any global.
|
||||
async := conv.Unwrap()
|
||||
@ -325,17 +324,17 @@ func (r observer) ObserveFloat64(o instrument.Float64Observable, v float64, opts
|
||||
)
|
||||
return
|
||||
}
|
||||
c := instrument.NewObserveConfig(opts)
|
||||
c := metric.NewObserveConfig(opts)
|
||||
oImpl.observe(v, c.Attributes())
|
||||
}
|
||||
|
||||
func (r observer) ObserveInt64(o instrument.Int64Observable, v int64, opts ...instrument.ObserveOption) {
|
||||
func (r observer) ObserveInt64(o metric.Int64Observable, v int64, opts ...metric.ObserveOption) {
|
||||
var oImpl int64Observable
|
||||
switch conv := o.(type) {
|
||||
case int64Observable:
|
||||
oImpl = conv
|
||||
case interface {
|
||||
Unwrap() instrument.Observable
|
||||
Unwrap() metric.Observable
|
||||
}:
|
||||
// Unwrap any global.
|
||||
async := conv.Unwrap()
|
||||
@ -358,7 +357,7 @@ func (r observer) ObserveInt64(o instrument.Int64Observable, v int64, opts ...in
|
||||
)
|
||||
return
|
||||
}
|
||||
c := instrument.NewObserveConfig(opts)
|
||||
c := metric.NewObserveConfig(opts)
|
||||
oImpl.observe(v, c.Attributes())
|
||||
}
|
||||
|
||||
@ -431,7 +430,7 @@ func (p int64ObservProvider) lookup(kind InstrumentKind, name, desc, u string) (
|
||||
return newInt64Observable(p.scope, kind, name, desc, u, aggs), err
|
||||
}
|
||||
|
||||
func (p int64ObservProvider) registerCallbacks(inst int64Observable, cBacks []instrument.Int64Callback) {
|
||||
func (p int64ObservProvider) registerCallbacks(inst int64Observable, cBacks []metric.Int64Callback) {
|
||||
if inst.observable == nil || len(inst.aggregators) == 0 {
|
||||
// Drop aggregator.
|
||||
return
|
||||
@ -442,7 +441,7 @@ func (p int64ObservProvider) registerCallbacks(inst int64Observable, cBacks []in
|
||||
}
|
||||
}
|
||||
|
||||
func (p int64ObservProvider) callback(i int64Observable, f instrument.Int64Callback) func(context.Context) error {
|
||||
func (p int64ObservProvider) callback(i int64Observable, f metric.Int64Callback) func(context.Context) error {
|
||||
inst := int64Observer{int64Observable: i}
|
||||
return func(ctx context.Context) error { return f(ctx, inst) }
|
||||
}
|
||||
@ -452,8 +451,8 @@ type int64Observer struct {
|
||||
int64Observable
|
||||
}
|
||||
|
||||
func (o int64Observer) Observe(val int64, opts ...instrument.ObserveOption) {
|
||||
c := instrument.NewObserveConfig(opts)
|
||||
func (o int64Observer) Observe(val int64, opts ...metric.ObserveOption) {
|
||||
c := metric.NewObserveConfig(opts)
|
||||
o.observe(val, c.Attributes())
|
||||
}
|
||||
|
||||
@ -464,7 +463,7 @@ func (p float64ObservProvider) lookup(kind InstrumentKind, name, desc, u string)
|
||||
return newFloat64Observable(p.scope, kind, name, desc, u, aggs), err
|
||||
}
|
||||
|
||||
func (p float64ObservProvider) registerCallbacks(inst float64Observable, cBacks []instrument.Float64Callback) {
|
||||
func (p float64ObservProvider) registerCallbacks(inst float64Observable, cBacks []metric.Float64Callback) {
|
||||
if inst.observable == nil || len(inst.aggregators) == 0 {
|
||||
// Drop aggregator.
|
||||
return
|
||||
@ -475,7 +474,7 @@ func (p float64ObservProvider) registerCallbacks(inst float64Observable, cBacks
|
||||
}
|
||||
}
|
||||
|
||||
func (p float64ObservProvider) callback(i float64Observable, f instrument.Float64Callback) func(context.Context) error {
|
||||
func (p float64ObservProvider) callback(i float64Observable, f metric.Float64Callback) func(context.Context) error {
|
||||
inst := float64Observer{float64Observable: i}
|
||||
return func(ctx context.Context) error { return f(ctx, inst) }
|
||||
}
|
||||
@ -485,7 +484,7 @@ type float64Observer struct {
|
||||
float64Observable
|
||||
}
|
||||
|
||||
func (o float64Observer) Observe(val float64, opts ...instrument.ObserveOption) {
|
||||
c := instrument.NewObserveConfig(opts)
|
||||
func (o float64Observer) Observe(val float64, opts ...metric.ObserveOption) {
|
||||
c := metric.NewObserveConfig(opts)
|
||||
o.observe(val, c.Attributes())
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/aggregation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
@ -170,7 +169,7 @@ func TestCallbackUnregisterConcurrency(t *testing.T) {
|
||||
// Instruments should produce correct ResourceMetrics.
|
||||
func TestMeterCreatesInstruments(t *testing.T) {
|
||||
attrs := attribute.NewSet(attribute.String("name", "alice"))
|
||||
opt := instrument.WithAttributeSet(attrs)
|
||||
opt := metric.WithAttributeSet(attrs)
|
||||
testCases := []struct {
|
||||
name string
|
||||
fn func(*testing.T, metric.Meter)
|
||||
@ -179,11 +178,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableInt64Count",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Int64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Int64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
ctr, err := m.Int64ObservableCounter("aint", instrument.WithInt64Callback(cback))
|
||||
ctr, err := m.Int64ObservableCounter("aint", metric.WithInt64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveInt64(ctr, 3)
|
||||
@ -206,11 +205,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableInt64UpDownCount",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Int64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Int64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
ctr, err := m.Int64ObservableUpDownCounter("aint", instrument.WithInt64Callback(cback))
|
||||
ctr, err := m.Int64ObservableUpDownCounter("aint", metric.WithInt64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveInt64(ctr, 11)
|
||||
@ -233,11 +232,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableInt64Gauge",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Int64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Int64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
gauge, err := m.Int64ObservableGauge("agauge", instrument.WithInt64Callback(cback))
|
||||
gauge, err := m.Int64ObservableGauge("agauge", metric.WithInt64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveInt64(gauge, 11)
|
||||
@ -258,11 +257,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableFloat64Count",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Float64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Float64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
ctr, err := m.Float64ObservableCounter("afloat", instrument.WithFloat64Callback(cback))
|
||||
ctr, err := m.Float64ObservableCounter("afloat", metric.WithFloat64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveFloat64(ctr, 3)
|
||||
@ -285,11 +284,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableFloat64UpDownCount",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Float64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Float64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
ctr, err := m.Float64ObservableUpDownCounter("afloat", instrument.WithFloat64Callback(cback))
|
||||
ctr, err := m.Float64ObservableUpDownCounter("afloat", metric.WithFloat64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveFloat64(ctr, 11)
|
||||
@ -312,11 +311,11 @@ func TestMeterCreatesInstruments(t *testing.T) {
|
||||
{
|
||||
name: "ObservableFloat64Gauge",
|
||||
fn: func(t *testing.T, m metric.Meter) {
|
||||
cback := func(_ context.Context, o instrument.Float64Observer) error {
|
||||
cback := func(_ context.Context, o metric.Float64Observer) error {
|
||||
o.Observe(4, opt)
|
||||
return nil
|
||||
}
|
||||
gauge, err := m.Float64ObservableGauge("agauge", instrument.WithFloat64Callback(cback))
|
||||
gauge, err := m.Float64ObservableGauge("agauge", metric.WithFloat64Callback(cback))
|
||||
assert.NoError(t, err)
|
||||
_, err = m.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
||||
o.ObserveFloat64(gauge, 11)
|
||||
@ -490,7 +489,7 @@ func TestRegisterNonSDKObserverErrors(t *testing.T) {
|
||||
mp := NewMeterProvider(WithReader(rdr))
|
||||
meter := mp.Meter("scope")
|
||||
|
||||
type obsrv struct{ instrument.Observable }
|
||||
type obsrv struct{ metric.Observable }
|
||||
o := obsrv{}
|
||||
|
||||
_, err := meter.RegisterCallback(
|
||||
@ -547,9 +546,9 @@ func TestCallbackObserverNonRegistered(t *testing.T) {
|
||||
fCtr, err := m2.Float64ObservableCounter("float64 ctr")
|
||||
require.NoError(t, err)
|
||||
|
||||
type int64Obsrv struct{ instrument.Int64Observable }
|
||||
type int64Obsrv struct{ metric.Int64Observable }
|
||||
int64Foreign := int64Obsrv{}
|
||||
type float64Obsrv struct{ instrument.Float64Observable }
|
||||
type float64Obsrv struct{ metric.Float64Observable }
|
||||
float64Foreign := float64Obsrv{}
|
||||
|
||||
_, err = m1.RegisterCallback(
|
||||
@ -887,11 +886,11 @@ func TestAttributeFilter(t *testing.T) {
|
||||
|
||||
func testAttributeFilter(temporality metricdata.Temporality) func(*testing.T) {
|
||||
fooBar := attribute.NewSet(attribute.String("foo", "bar"))
|
||||
withFooBar := instrument.WithAttributeSet(fooBar)
|
||||
withFooBar := metric.WithAttributeSet(fooBar)
|
||||
v1 := attribute.NewSet(attribute.String("foo", "bar"), attribute.Int("version", 1))
|
||||
withV1 := instrument.WithAttributeSet(v1)
|
||||
withV1 := metric.WithAttributeSet(v1)
|
||||
v2 := attribute.NewSet(attribute.String("foo", "bar"), attribute.Int("version", 2))
|
||||
withV2 := instrument.WithAttributeSet(v2)
|
||||
withV2 := metric.WithAttributeSet(v2)
|
||||
testcases := []struct {
|
||||
name string
|
||||
register func(t *testing.T, mtr metric.Meter) error
|
||||
@ -1273,10 +1272,10 @@ func TestObservableExample(t *testing.T) {
|
||||
meter := mp.Meter(scopeName)
|
||||
|
||||
observations := make(map[attribute.Set]int64)
|
||||
_, err := meter.Int64ObservableCounter(instName, instrument.WithInt64Callback(
|
||||
func(_ context.Context, o instrument.Int64Observer) error {
|
||||
_, err := meter.Int64ObservableCounter(instName, metric.WithInt64Callback(
|
||||
func(_ context.Context, o metric.Int64Observer) error {
|
||||
for attrSet, val := range observations {
|
||||
o.Observe(val, instrument.WithAttributeSet(attrSet))
|
||||
o.Observe(val, metric.WithAttributeSet(attrSet))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -1477,21 +1476,21 @@ func TestObservableExample(t *testing.T) {
|
||||
}
|
||||
|
||||
var (
|
||||
aiCounter instrument.Int64ObservableCounter
|
||||
aiUpDownCounter instrument.Int64ObservableUpDownCounter
|
||||
aiGauge instrument.Int64ObservableGauge
|
||||
aiCounter metric.Int64ObservableCounter
|
||||
aiUpDownCounter metric.Int64ObservableUpDownCounter
|
||||
aiGauge metric.Int64ObservableGauge
|
||||
|
||||
afCounter instrument.Float64ObservableCounter
|
||||
afUpDownCounter instrument.Float64ObservableUpDownCounter
|
||||
afGauge instrument.Float64ObservableGauge
|
||||
afCounter metric.Float64ObservableCounter
|
||||
afUpDownCounter metric.Float64ObservableUpDownCounter
|
||||
afGauge metric.Float64ObservableGauge
|
||||
|
||||
siCounter instrument.Int64Counter
|
||||
siUpDownCounter instrument.Int64UpDownCounter
|
||||
siHistogram instrument.Int64Histogram
|
||||
siCounter metric.Int64Counter
|
||||
siUpDownCounter metric.Int64UpDownCounter
|
||||
siHistogram metric.Int64Histogram
|
||||
|
||||
sfCounter instrument.Float64Counter
|
||||
sfUpDownCounter instrument.Float64UpDownCounter
|
||||
sfHistogram instrument.Float64Histogram
|
||||
sfCounter metric.Float64Counter
|
||||
sfUpDownCounter metric.Float64UpDownCounter
|
||||
sfHistogram metric.Float64Histogram
|
||||
)
|
||||
|
||||
func BenchmarkInstrumentCreation(b *testing.B) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user