You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-05 00:28:58 +02:00
Rename Kind from the api/metric
package (#1240)
* Update metric Kind to InstrumentKind * Update all the other modules with Kind rename * Update metric Descriptor with instrument Kind rename * Update other modules with Descriptor method rename * Update OTLP exporter test field name * Rename kind filenames * Add changes to CHANGELOG * Fix documentation for Grouping and PrecomputedSum
This commit is contained in:
@ -18,6 +18,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
- Move the `go.opentelemetry.io/otel/api/trace/tracetest` package into `go.opentelemetry.io/otel/oteltest`. (#1229)
|
- Move the `go.opentelemetry.io/otel/api/trace/tracetest` package into `go.opentelemetry.io/otel/oteltest`. (#1229)
|
||||||
- OTLP Exporter supports OTLP v0.5.0. (#1230)
|
- OTLP Exporter supports OTLP v0.5.0. (#1230)
|
||||||
- The Sampler is now called on local child spans. (#1233)
|
- The Sampler is now called on local child spans. (#1233)
|
||||||
|
- The `Kind` type from the `go.opentelemetry.io/otel/api/metric` package was renamed to `InstrumentKind` to more specifically describe what it is and avoid semantic ambiguity. (#1240)
|
||||||
|
- The `MetricKind` method of the `Descriptor` type in the `go.opentelemetry.io/otel/api/metric` package was renamed to `Descriptor.InstrumentKind`.
|
||||||
|
This matches the returned type and fixes misuse of the term metric. (#1240)
|
||||||
- Move test harness from the `go.opentelemetry.io/otel/api/apitest` package into `go.opentelemetry.io/otel/oteltest`. (#1241)
|
- Move test harness from the `go.opentelemetry.io/otel/api/apitest` package into `go.opentelemetry.io/otel/oteltest`. (#1241)
|
||||||
- Rename `MergeItererator` to `MergeIterator` in the `go.opentelemetry.io/otel/label` package. (#1244)
|
- Rename `MergeItererator` to `MergeIterator` in the `go.opentelemetry.io/otel/label` package. (#1244)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
var Must = metric.Must
|
var Must = metric.Must
|
||||||
|
|
||||||
func checkSyncBatches(ctx context.Context, t *testing.T, labels []label.KeyValue, mock *mockTest.MeterImpl, nkind metric.NumberKind, mkind metric.Kind, instrument metric.InstrumentImpl, expected ...float64) {
|
func checkSyncBatches(ctx context.Context, t *testing.T, labels []label.KeyValue, mock *mockTest.MeterImpl, nkind metric.NumberKind, mkind metric.InstrumentKind, instrument metric.InstrumentImpl, expected ...float64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
batchesCount := len(mock.MeasurementBatches)
|
batchesCount := len(mock.MeasurementBatches)
|
||||||
@ -131,7 +131,7 @@ func TestCounter(t *testing.T) {
|
|||||||
boundInstrument := c.Bind(labels...)
|
boundInstrument := c.Bind(labels...)
|
||||||
boundInstrument.Add(ctx, -742)
|
boundInstrument.Add(ctx, -742)
|
||||||
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.CounterKind, c.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.CounterInstrumentKind, c.SyncImpl(),
|
||||||
1994.1, -742, 42,
|
1994.1, -742, 42,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -144,7 +144,7 @@ func TestCounter(t *testing.T) {
|
|||||||
boundInstrument := c.Bind(labels...)
|
boundInstrument := c.Bind(labels...)
|
||||||
boundInstrument.Add(ctx, 4200)
|
boundInstrument.Add(ctx, 4200)
|
||||||
meter.RecordBatch(ctx, labels, c.Measurement(420000))
|
meter.RecordBatch(ctx, labels, c.Measurement(420000))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.CounterKind, c.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.CounterInstrumentKind, c.SyncImpl(),
|
||||||
42, 4200, 420000,
|
42, 4200, 420000,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ func TestCounter(t *testing.T) {
|
|||||||
boundInstrument := c.Bind(labels...)
|
boundInstrument := c.Bind(labels...)
|
||||||
boundInstrument.Add(ctx, -100)
|
boundInstrument.Add(ctx, -100)
|
||||||
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
meter.RecordBatch(ctx, labels, c.Measurement(42))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.UpDownCounterKind, c.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.UpDownCounterInstrumentKind, c.SyncImpl(),
|
||||||
100, -100, 42,
|
100, -100, 42,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -171,7 +171,7 @@ func TestCounter(t *testing.T) {
|
|||||||
boundInstrument := c.Bind(labels...)
|
boundInstrument := c.Bind(labels...)
|
||||||
boundInstrument.Add(ctx, -76)
|
boundInstrument.Add(ctx, -76)
|
||||||
meter.RecordBatch(ctx, labels, c.Measurement(-100.1))
|
meter.RecordBatch(ctx, labels, c.Measurement(-100.1))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.UpDownCounterKind, c.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.UpDownCounterInstrumentKind, c.SyncImpl(),
|
||||||
100.1, -76, -100.1,
|
100.1, -76, -100.1,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -187,7 +187,7 @@ func TestValueRecorder(t *testing.T) {
|
|||||||
boundInstrument := m.Bind(labels...)
|
boundInstrument := m.Bind(labels...)
|
||||||
boundInstrument.Record(ctx, 0)
|
boundInstrument.Record(ctx, 0)
|
||||||
meter.RecordBatch(ctx, labels, m.Measurement(-100.5))
|
meter.RecordBatch(ctx, labels, m.Measurement(-100.5))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.ValueRecorderKind, m.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Float64NumberKind, metric.ValueRecorderInstrumentKind, m.SyncImpl(),
|
||||||
42, 0, -100.5,
|
42, 0, -100.5,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -200,7 +200,7 @@ func TestValueRecorder(t *testing.T) {
|
|||||||
boundInstrument := m.Bind(labels...)
|
boundInstrument := m.Bind(labels...)
|
||||||
boundInstrument.Record(ctx, 80)
|
boundInstrument.Record(ctx, 80)
|
||||||
meter.RecordBatch(ctx, labels, m.Measurement(0))
|
meter.RecordBatch(ctx, labels, m.Measurement(0))
|
||||||
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.ValueRecorderKind, m.SyncImpl(),
|
checkSyncBatches(ctx, t, labels, mockSDK, metric.Int64NumberKind, metric.ValueRecorderInstrumentKind, m.SyncImpl(),
|
||||||
173, 80, 0,
|
173, 80, 0,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -214,7 +214,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(42.1, labels...)
|
result.Observe(42.1, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.ValueObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.ValueObserverInstrumentKind, o.AsyncImpl(),
|
||||||
42.1,
|
42.1,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -225,7 +225,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(-142, labels...)
|
result.Observe(-142, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.ValueObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.ValueObserverInstrumentKind, o.AsyncImpl(),
|
||||||
-142,
|
-142,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -236,7 +236,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(42.1, labels...)
|
result.Observe(42.1, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.SumObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.SumObserverInstrumentKind, o.AsyncImpl(),
|
||||||
42.1,
|
42.1,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -247,7 +247,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(-142, labels...)
|
result.Observe(-142, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.SumObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.SumObserverInstrumentKind, o.AsyncImpl(),
|
||||||
-142,
|
-142,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -258,7 +258,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(42.1, labels...)
|
result.Observe(42.1, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.UpDownSumObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Float64NumberKind, metric.UpDownSumObserverInstrumentKind, o.AsyncImpl(),
|
||||||
42.1,
|
42.1,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -269,7 +269,7 @@ func TestObserverInstruments(t *testing.T) {
|
|||||||
result.Observe(-142, labels...)
|
result.Observe(-142, labels...)
|
||||||
})
|
})
|
||||||
mockSDK.RunAsyncInstruments()
|
mockSDK.RunAsyncInstruments()
|
||||||
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.UpDownSumObserverKind, o.AsyncImpl(),
|
checkObserverBatch(t, labels, mockSDK, metric.Int64NumberKind, metric.UpDownSumObserverInstrumentKind, o.AsyncImpl(),
|
||||||
-142,
|
-142,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -320,7 +320,7 @@ func TestBatchObserverInstruments(t *testing.T) {
|
|||||||
require.Equal(t, 0, m2.Number.CompareNumber(metric.Float64NumberKind, mockTest.ResolveNumberByKind(t, metric.Float64NumberKind, 42)))
|
require.Equal(t, 0, m2.Number.CompareNumber(metric.Float64NumberKind, mockTest.ResolveNumberByKind(t, metric.Float64NumberKind, 42)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkObserverBatch(t *testing.T, labels []label.KeyValue, mock *mockTest.MeterImpl, nkind metric.NumberKind, mkind metric.Kind, observer metric.AsyncImpl, expected float64) {
|
func checkObserverBatch(t *testing.T, labels []label.KeyValue, mock *mockTest.MeterImpl, nkind metric.NumberKind, mkind metric.InstrumentKind, observer metric.AsyncImpl, expected float64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
assert.Len(t, mock.MeasurementBatches, 1)
|
assert.Len(t, mock.MeasurementBatches, 1)
|
||||||
if len(mock.MeasurementBatches) < 1 {
|
if len(mock.MeasurementBatches) < 1 {
|
||||||
@ -337,7 +337,7 @@ func checkObserverBatch(t *testing.T, labels []label.KeyValue, mock *mockTest.Me
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
measurement := got.Measurements[0]
|
measurement := got.Measurements[0]
|
||||||
require.Equal(t, mkind, measurement.Instrument.Descriptor().MetricKind())
|
require.Equal(t, mkind, measurement.Instrument.Descriptor().InstrumentKind())
|
||||||
assert.Equal(t, o, measurement.Instrument.Implementation().(*mockTest.Async))
|
assert.Equal(t, o, measurement.Instrument.Implementation().(*mockTest.Async))
|
||||||
ft := mockTest.ResolveNumberByKind(t, nkind, expected)
|
ft := mockTest.ResolveNumberByKind(t, nkind, expected)
|
||||||
assert.Equal(t, 0, measurement.Number.CompareNumber(nkind, ft))
|
assert.Equal(t, 0, measurement.Number.CompareNumber(nkind, ft))
|
||||||
|
@ -20,19 +20,19 @@ import "go.opentelemetry.io/otel/unit"
|
|||||||
// including its name, metric kind, number kind, and the configurable
|
// including its name, metric kind, number kind, and the configurable
|
||||||
// options.
|
// options.
|
||||||
type Descriptor struct {
|
type Descriptor struct {
|
||||||
name string
|
name string
|
||||||
kind Kind
|
instrumentKind InstrumentKind
|
||||||
numberKind NumberKind
|
numberKind NumberKind
|
||||||
config InstrumentConfig
|
config InstrumentConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDescriptor returns a Descriptor with the given contents.
|
// NewDescriptor returns a Descriptor with the given contents.
|
||||||
func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...InstrumentOption) Descriptor {
|
func NewDescriptor(name string, ikind InstrumentKind, nkind NumberKind, opts ...InstrumentOption) Descriptor {
|
||||||
return Descriptor{
|
return Descriptor{
|
||||||
name: name,
|
name: name,
|
||||||
kind: mkind,
|
instrumentKind: ikind,
|
||||||
numberKind: nkind,
|
numberKind: nkind,
|
||||||
config: NewInstrumentConfig(opts...),
|
config: NewInstrumentConfig(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ func (d Descriptor) Name() string {
|
|||||||
return d.name
|
return d.name
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetricKind returns the specific kind of instrument.
|
// InstrumentKind returns the specific kind of instrument.
|
||||||
func (d Descriptor) MetricKind() Kind {
|
func (d Descriptor) InstrumentKind() InstrumentKind {
|
||||||
return d.kind
|
return d.instrumentKind
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description provides a human-readable description of the metric
|
// Description provides a human-readable description of the metric
|
||||||
|
80
api/metric/instrumentkind.go
Normal file
80
api/metric/instrumentkind.go
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
//go:generate stringer -type=InstrumentKind
|
||||||
|
|
||||||
|
package metric
|
||||||
|
|
||||||
|
// InstrumentKind describes the kind of instrument.
|
||||||
|
type InstrumentKind int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ValueRecorderInstrumentKind indicates a ValueRecorder instrument.
|
||||||
|
ValueRecorderInstrumentKind InstrumentKind = iota
|
||||||
|
// ValueObserverInstrumentKind indicates an ValueObserver instrument.
|
||||||
|
ValueObserverInstrumentKind
|
||||||
|
|
||||||
|
// CounterInstrumentKind indicates a Counter instrument.
|
||||||
|
CounterInstrumentKind
|
||||||
|
// UpDownCounterInstrumentKind indicates a UpDownCounter instrument.
|
||||||
|
UpDownCounterInstrumentKind
|
||||||
|
|
||||||
|
// SumObserverInstrumentKind indicates a SumObserver instrument.
|
||||||
|
SumObserverInstrumentKind
|
||||||
|
// UpDownSumObserverInstrumentKind indicates a UpDownSumObserver
|
||||||
|
// instrument.
|
||||||
|
UpDownSumObserverInstrumentKind
|
||||||
|
)
|
||||||
|
|
||||||
|
// Synchronous returns whether this is a synchronous kind of instrument.
|
||||||
|
func (k InstrumentKind) Synchronous() bool {
|
||||||
|
switch k {
|
||||||
|
case CounterInstrumentKind, UpDownCounterInstrumentKind, ValueRecorderInstrumentKind:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asynchronous returns whether this is an asynchronous kind of instrument.
|
||||||
|
func (k InstrumentKind) Asynchronous() bool {
|
||||||
|
return !k.Synchronous()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).
|
||||||
|
func (k InstrumentKind) Adding() bool {
|
||||||
|
switch k {
|
||||||
|
case CounterInstrumentKind, UpDownCounterInstrumentKind, SumObserverInstrumentKind, UpDownSumObserverInstrumentKind:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grouping returns whether this kind of instrument groups its inputs (as opposed to Adding).
|
||||||
|
func (k InstrumentKind) Grouping() bool {
|
||||||
|
return !k.Adding()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monotonic returns whether this kind of instrument exposes a non-decreasing sum.
|
||||||
|
func (k InstrumentKind) Monotonic() bool {
|
||||||
|
switch k {
|
||||||
|
case CounterInstrumentKind, SumObserverInstrumentKind:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrecomputedSum returns whether this kind of instrument receives precomputed sums.
|
||||||
|
func (k InstrumentKind) PrecomputedSum() bool {
|
||||||
|
return k.Adding() && k.Asynchronous()
|
||||||
|
}
|
28
api/metric/instrumentkind_string.go
Normal file
28
api/metric/instrumentkind_string.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Code generated by "stringer -type=InstrumentKind"; DO NOT EDIT.
|
||||||
|
|
||||||
|
package metric
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
|
func _() {
|
||||||
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||||
|
// Re-run the stringer command to generate them again.
|
||||||
|
var x [1]struct{}
|
||||||
|
_ = x[ValueRecorderInstrumentKind-0]
|
||||||
|
_ = x[ValueObserverInstrumentKind-1]
|
||||||
|
_ = x[CounterInstrumentKind-2]
|
||||||
|
_ = x[UpDownCounterInstrumentKind-3]
|
||||||
|
_ = x[SumObserverInstrumentKind-4]
|
||||||
|
_ = x[UpDownSumObserverInstrumentKind-5]
|
||||||
|
}
|
||||||
|
|
||||||
|
const _InstrumentKind_name = "ValueRecorderInstrumentKindValueObserverInstrumentKindCounterInstrumentKindUpDownCounterInstrumentKindSumObserverInstrumentKindUpDownSumObserverInstrumentKind"
|
||||||
|
|
||||||
|
var _InstrumentKind_index = [...]uint8{0, 27, 54, 75, 102, 127, 158}
|
||||||
|
|
||||||
|
func (i InstrumentKind) String() string {
|
||||||
|
if i < 0 || i >= InstrumentKind(len(_InstrumentKind_index)-1) {
|
||||||
|
return "InstrumentKind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
|
}
|
||||||
|
return _InstrumentKind_name[_InstrumentKind_index[i]:_InstrumentKind_index[i+1]]
|
||||||
|
}
|
@ -23,49 +23,49 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
syncKinds = []metric.Kind{
|
syncKinds = []metric.InstrumentKind{
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.UpDownCounterKind,
|
metric.UpDownCounterInstrumentKind,
|
||||||
}
|
}
|
||||||
asyncKinds = []metric.Kind{
|
asyncKinds = []metric.InstrumentKind{
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
metric.SumObserverKind,
|
metric.SumObserverInstrumentKind,
|
||||||
metric.UpDownSumObserverKind,
|
metric.UpDownSumObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
addingKinds = []metric.Kind{
|
addingKinds = []metric.InstrumentKind{
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.UpDownCounterKind,
|
metric.UpDownCounterInstrumentKind,
|
||||||
metric.SumObserverKind,
|
metric.SumObserverInstrumentKind,
|
||||||
metric.UpDownSumObserverKind,
|
metric.UpDownSumObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
groupingKinds = []metric.Kind{
|
groupingKinds = []metric.InstrumentKind{
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
monotonicKinds = []metric.Kind{
|
monotonicKinds = []metric.InstrumentKind{
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.SumObserverKind,
|
metric.SumObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
nonMonotonicKinds = []metric.Kind{
|
nonMonotonicKinds = []metric.InstrumentKind{
|
||||||
metric.UpDownCounterKind,
|
metric.UpDownCounterInstrumentKind,
|
||||||
metric.UpDownSumObserverKind,
|
metric.UpDownSumObserverInstrumentKind,
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
precomputedSumKinds = []metric.Kind{
|
precomputedSumKinds = []metric.InstrumentKind{
|
||||||
metric.SumObserverKind,
|
metric.SumObserverInstrumentKind,
|
||||||
metric.UpDownSumObserverKind,
|
metric.UpDownSumObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
nonPrecomputedSumKinds = []metric.Kind{
|
nonPrecomputedSumKinds = []metric.InstrumentKind{
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.UpDownCounterKind,
|
metric.UpDownCounterInstrumentKind,
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -1,79 +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.
|
|
||||||
|
|
||||||
//go:generate stringer -type=Kind
|
|
||||||
|
|
||||||
package metric
|
|
||||||
|
|
||||||
// Kind describes the kind of instrument.
|
|
||||||
type Kind int8
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ValueRecorderKind indicates a ValueRecorder instrument.
|
|
||||||
ValueRecorderKind Kind = iota
|
|
||||||
// ValueObserverKind indicates an ValueObserver instrument.
|
|
||||||
ValueObserverKind
|
|
||||||
|
|
||||||
// CounterKind indicates a Counter instrument.
|
|
||||||
CounterKind
|
|
||||||
// UpDownCounterKind indicates a UpDownCounter instrument.
|
|
||||||
UpDownCounterKind
|
|
||||||
|
|
||||||
// SumObserverKind indicates a SumObserver instrument.
|
|
||||||
SumObserverKind
|
|
||||||
// UpDownSumObserverKind indicates a UpDownSumObserver instrument.
|
|
||||||
UpDownSumObserverKind
|
|
||||||
)
|
|
||||||
|
|
||||||
// Synchronous returns whether this is a synchronous kind of instrument.
|
|
||||||
func (k Kind) Synchronous() bool {
|
|
||||||
switch k {
|
|
||||||
case CounterKind, UpDownCounterKind, ValueRecorderKind:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asynchronous returns whether this is an asynchronous kind of instrument.
|
|
||||||
func (k Kind) Asynchronous() bool {
|
|
||||||
return !k.Synchronous()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).
|
|
||||||
func (k Kind) Adding() bool {
|
|
||||||
switch k {
|
|
||||||
case CounterKind, UpDownCounterKind, SumObserverKind, UpDownSumObserverKind:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adding returns whether this kind of instrument groups its inputs (as opposed to Adding).
|
|
||||||
func (k Kind) Grouping() bool {
|
|
||||||
return !k.Adding()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Monotonic returns whether this kind of instrument exposes a non-decreasing sum.
|
|
||||||
func (k Kind) Monotonic() bool {
|
|
||||||
switch k {
|
|
||||||
case CounterKind, SumObserverKind:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cumulative returns whether this kind of instrument receives precomputed sums.
|
|
||||||
func (k Kind) PrecomputedSum() bool {
|
|
||||||
return k.Adding() && k.Asynchronous()
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
// Code generated by "stringer -type=Kind"; DO NOT EDIT.
|
|
||||||
|
|
||||||
package metric
|
|
||||||
|
|
||||||
import "strconv"
|
|
||||||
|
|
||||||
func _() {
|
|
||||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
||||||
// Re-run the stringer command to generate them again.
|
|
||||||
var x [1]struct{}
|
|
||||||
_ = x[ValueRecorderKind-0]
|
|
||||||
_ = x[ValueObserverKind-1]
|
|
||||||
_ = x[CounterKind-2]
|
|
||||||
_ = x[UpDownCounterKind-3]
|
|
||||||
_ = x[SumObserverKind-4]
|
|
||||||
_ = x[UpDownSumObserverKind-5]
|
|
||||||
}
|
|
||||||
|
|
||||||
const _Kind_name = "ValueRecorderKindValueObserverKindCounterKindUpDownCounterKindSumObserverKindUpDownSumObserverKind"
|
|
||||||
|
|
||||||
var _Kind_index = [...]uint8{0, 17, 34, 45, 62, 77, 98}
|
|
||||||
|
|
||||||
func (i Kind) String() string {
|
|
||||||
if i < 0 || i >= Kind(len(_Kind_index)-1) {
|
|
||||||
return "Kind(" + strconv.FormatInt(int64(i), 10) + ")"
|
|
||||||
}
|
|
||||||
return _Kind_name[_Kind_index[i]:_Kind_index[i+1]]
|
|
||||||
}
|
|
@ -74,7 +74,7 @@ func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver {
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error) {
|
func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error) {
|
||||||
return wrapInt64CounterInstrument(
|
return wrapInt64CounterInstrument(
|
||||||
m.newSync(name, CounterKind, Int64NumberKind, options))
|
m.newSync(name, CounterInstrumentKind, Int64NumberKind, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64Counter creates a new floating point Counter with the
|
// NewFloat64Counter creates a new floating point Counter with the
|
||||||
@ -83,7 +83,7 @@ func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64C
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error) {
|
func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error) {
|
||||||
return wrapFloat64CounterInstrument(
|
return wrapFloat64CounterInstrument(
|
||||||
m.newSync(name, CounterKind, Float64NumberKind, options))
|
m.newSync(name, CounterInstrumentKind, Float64NumberKind, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInt64UpDownCounter creates a new integer UpDownCounter instrument with the
|
// NewInt64UpDownCounter creates a new integer UpDownCounter instrument with the
|
||||||
@ -92,7 +92,7 @@ func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Floa
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error) {
|
func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error) {
|
||||||
return wrapInt64UpDownCounterInstrument(
|
return wrapInt64UpDownCounterInstrument(
|
||||||
m.newSync(name, UpDownCounterKind, Int64NumberKind, options))
|
m.newSync(name, UpDownCounterInstrumentKind, Int64NumberKind, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64UpDownCounter creates a new floating point UpDownCounter with the
|
// NewFloat64UpDownCounter creates a new floating point UpDownCounter with the
|
||||||
@ -101,7 +101,7 @@ func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error) {
|
func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error) {
|
||||||
return wrapFloat64UpDownCounterInstrument(
|
return wrapFloat64UpDownCounterInstrument(
|
||||||
m.newSync(name, UpDownCounterKind, Float64NumberKind, options))
|
m.newSync(name, UpDownCounterInstrumentKind, Float64NumberKind, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInt64ValueRecorder creates a new integer ValueRecorder instrument with the
|
// NewInt64ValueRecorder creates a new integer ValueRecorder instrument with the
|
||||||
@ -110,7 +110,7 @@ func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption)
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewInt64ValueRecorder(name string, opts ...InstrumentOption) (Int64ValueRecorder, error) {
|
func (m Meter) NewInt64ValueRecorder(name string, opts ...InstrumentOption) (Int64ValueRecorder, error) {
|
||||||
return wrapInt64ValueRecorderInstrument(
|
return wrapInt64ValueRecorderInstrument(
|
||||||
m.newSync(name, ValueRecorderKind, Int64NumberKind, opts))
|
m.newSync(name, ValueRecorderInstrumentKind, Int64NumberKind, opts))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64ValueRecorder creates a new floating point ValueRecorder with the
|
// NewFloat64ValueRecorder creates a new floating point ValueRecorder with the
|
||||||
@ -119,7 +119,7 @@ func (m Meter) NewInt64ValueRecorder(name string, opts ...InstrumentOption) (Int
|
|||||||
// duplicate registration).
|
// duplicate registration).
|
||||||
func (m Meter) NewFloat64ValueRecorder(name string, opts ...InstrumentOption) (Float64ValueRecorder, error) {
|
func (m Meter) NewFloat64ValueRecorder(name string, opts ...InstrumentOption) (Float64ValueRecorder, error) {
|
||||||
return wrapFloat64ValueRecorderInstrument(
|
return wrapFloat64ValueRecorderInstrument(
|
||||||
m.newSync(name, ValueRecorderKind, Float64NumberKind, opts))
|
m.newSync(name, ValueRecorderInstrumentKind, Float64NumberKind, opts))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInt64ValueObserver creates a new integer ValueObserver instrument
|
// NewInt64ValueObserver creates a new integer ValueObserver instrument
|
||||||
@ -131,7 +131,7 @@ func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverFunc, op
|
|||||||
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64ValueObserverInstrument(
|
return wrapInt64ValueObserverInstrument(
|
||||||
m.newAsync(name, ValueObserverKind, Int64NumberKind, opts,
|
m.newAsync(name, ValueObserverInstrumentKind, Int64NumberKind, opts,
|
||||||
newInt64AsyncRunner(callback)))
|
newInt64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverFunc
|
|||||||
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64ValueObserverInstrument(
|
return wrapFloat64ValueObserverInstrument(
|
||||||
m.newAsync(name, ValueObserverKind, Float64NumberKind, opts,
|
m.newAsync(name, ValueObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
newFloat64AsyncRunner(callback)))
|
newFloat64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverFunc, opts
|
|||||||
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64SumObserverInstrument(
|
return wrapInt64SumObserverInstrument(
|
||||||
m.newAsync(name, SumObserverKind, Int64NumberKind, opts,
|
m.newAsync(name, SumObserverInstrumentKind, Int64NumberKind, opts,
|
||||||
newInt64AsyncRunner(callback)))
|
newInt64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverFunc,
|
|||||||
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64SumObserverInstrument(
|
return wrapFloat64SumObserverInstrument(
|
||||||
m.newAsync(name, SumObserverKind, Float64NumberKind, opts,
|
m.newAsync(name, SumObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
newFloat64AsyncRunner(callback)))
|
newFloat64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc
|
|||||||
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64UpDownSumObserverInstrument(
|
return wrapInt64UpDownSumObserverInstrument(
|
||||||
m.newAsync(name, UpDownSumObserverKind, Int64NumberKind, opts,
|
m.newAsync(name, UpDownSumObserverInstrumentKind, Int64NumberKind, opts,
|
||||||
newInt64AsyncRunner(callback)))
|
newInt64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ func (m Meter) NewFloat64UpDownSumObserver(name string, callback Float64Observer
|
|||||||
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64UpDownSumObserverInstrument(
|
return wrapFloat64UpDownSumObserverInstrument(
|
||||||
m.newAsync(name, UpDownSumObserverKind, Float64NumberKind, opts,
|
m.newAsync(name, UpDownSumObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
newFloat64AsyncRunner(callback)))
|
newFloat64AsyncRunner(callback)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ func (b BatchObserver) NewInt64ValueObserver(name string, opts ...InstrumentOpti
|
|||||||
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64ValueObserverInstrument(
|
return wrapInt64ValueObserverInstrument(
|
||||||
b.meter.newAsync(name, ValueObserverKind, Int64NumberKind, opts, b.runner))
|
b.meter.newAsync(name, ValueObserverInstrumentKind, Int64NumberKind, opts, b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64ValueObserver creates a new floating point ValueObserver with
|
// NewFloat64ValueObserver creates a new floating point ValueObserver with
|
||||||
@ -221,7 +221,7 @@ func (b BatchObserver) NewFloat64ValueObserver(name string, opts ...InstrumentOp
|
|||||||
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64ValueObserverInstrument(
|
return wrapFloat64ValueObserverInstrument(
|
||||||
b.meter.newAsync(name, ValueObserverKind, Float64NumberKind, opts,
|
b.meter.newAsync(name, ValueObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
b.runner))
|
b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ func (b BatchObserver) NewInt64SumObserver(name string, opts ...InstrumentOption
|
|||||||
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64SumObserverInstrument(
|
return wrapInt64SumObserverInstrument(
|
||||||
b.meter.newAsync(name, SumObserverKind, Int64NumberKind, opts, b.runner))
|
b.meter.newAsync(name, SumObserverInstrumentKind, Int64NumberKind, opts, b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64SumObserver creates a new floating point SumObserver with
|
// NewFloat64SumObserver creates a new floating point SumObserver with
|
||||||
@ -246,7 +246,7 @@ func (b BatchObserver) NewFloat64SumObserver(name string, opts ...InstrumentOpti
|
|||||||
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64SumObserverInstrument(
|
return wrapFloat64SumObserverInstrument(
|
||||||
b.meter.newAsync(name, SumObserverKind, Float64NumberKind, opts,
|
b.meter.newAsync(name, SumObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
b.runner))
|
b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ func (b BatchObserver) NewInt64UpDownSumObserver(name string, opts ...Instrument
|
|||||||
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapInt64UpDownSumObserverInstrument(
|
return wrapInt64UpDownSumObserverInstrument(
|
||||||
b.meter.newAsync(name, UpDownSumObserverKind, Int64NumberKind, opts, b.runner))
|
b.meter.newAsync(name, UpDownSumObserverInstrumentKind, Int64NumberKind, opts, b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
|
// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
|
||||||
@ -271,7 +271,7 @@ func (b BatchObserver) NewFloat64UpDownSumObserver(name string, opts ...Instrume
|
|||||||
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||||
}
|
}
|
||||||
return wrapFloat64UpDownSumObserverInstrument(
|
return wrapFloat64UpDownSumObserverInstrument(
|
||||||
b.meter.newAsync(name, UpDownSumObserverKind, Float64NumberKind, opts,
|
b.meter.newAsync(name, UpDownSumObserverInstrumentKind, Float64NumberKind, opts,
|
||||||
b.runner))
|
b.runner))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ func (m Meter) MeterImpl() MeterImpl {
|
|||||||
// newAsync constructs one new asynchronous instrument.
|
// newAsync constructs one new asynchronous instrument.
|
||||||
func (m Meter) newAsync(
|
func (m Meter) newAsync(
|
||||||
name string,
|
name string,
|
||||||
mkind Kind,
|
mkind InstrumentKind,
|
||||||
nkind NumberKind,
|
nkind NumberKind,
|
||||||
opts []InstrumentOption,
|
opts []InstrumentOption,
|
||||||
runner AsyncRunner,
|
runner AsyncRunner,
|
||||||
@ -303,7 +303,7 @@ func (m Meter) newAsync(
|
|||||||
// newSync constructs one new synchronous instrument.
|
// newSync constructs one new synchronous instrument.
|
||||||
func (m Meter) newSync(
|
func (m Meter) newSync(
|
||||||
name string,
|
name string,
|
||||||
metricKind Kind,
|
metricKind InstrumentKind,
|
||||||
numberKind NumberKind,
|
numberKind NumberKind,
|
||||||
opts []InstrumentOption,
|
opts []InstrumentOption,
|
||||||
) (
|
) (
|
||||||
|
@ -95,14 +95,14 @@ func NewMetricKindMismatchError(desc metric.Descriptor) error {
|
|||||||
desc.InstrumentationName(),
|
desc.InstrumentationName(),
|
||||||
desc.InstrumentationVersion(),
|
desc.InstrumentationVersion(),
|
||||||
desc.NumberKind(),
|
desc.NumberKind(),
|
||||||
desc.MetricKind(),
|
desc.InstrumentKind(),
|
||||||
ErrMetricKindMismatch)
|
ErrMetricKindMismatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatible determines whether two metric.Descriptors are considered
|
// Compatible determines whether two metric.Descriptors are considered
|
||||||
// the same for the purpose of uniqueness checking.
|
// the same for the purpose of uniqueness checking.
|
||||||
func Compatible(candidate, existing metric.Descriptor) bool {
|
func Compatible(candidate, existing metric.Descriptor) bool {
|
||||||
return candidate.MetricKind() == existing.MetricKind() &&
|
return candidate.InstrumentKind() == existing.InstrumentKind() &&
|
||||||
candidate.NumberKind() == existing.NumberKind()
|
candidate.NumberKind() == existing.NumberKind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ func TestMinMaxSumCountValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMinMaxSumCountDatapoints(t *testing.T) {
|
func TestMinMaxSumCountDatapoints(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("", metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
mmsc, ckpt := metrictest.Unslice2(minmaxsumcount.New(2, &desc))
|
mmsc, ckpt := metrictest.Unslice2(minmaxsumcount.New(2, &desc))
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ func TestMinMaxSumCountPropagatesErrors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSumIntDataPoints(t *testing.T) {
|
func TestSumIntDataPoints(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("", metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
s, ckpt := metrictest.Unslice2(sumAgg.New(2))
|
s, ckpt := metrictest.Unslice2(sumAgg.New(2))
|
||||||
assert.NoError(t, s.Update(context.Background(), metric.Number(1), &desc))
|
assert.NoError(t, s.Update(context.Background(), metric.Number(1), &desc))
|
||||||
@ -181,7 +181,7 @@ func TestSumIntDataPoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSumFloatDataPoints(t *testing.T) {
|
func TestSumFloatDataPoints(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("", metric.ValueRecorderKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("", metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
s, ckpt := metrictest.Unslice2(sumAgg.New(2))
|
s, ckpt := metrictest.Unslice2(sumAgg.New(2))
|
||||||
assert.NoError(t, s.Update(context.Background(), metric.NewFloat64Number(1), &desc))
|
assert.NoError(t, s.Update(context.Background(), metric.NewFloat64Number(1), &desc))
|
||||||
@ -207,7 +207,7 @@ func TestSumFloatDataPoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLastValueIntDataPoints(t *testing.T) {
|
func TestLastValueIntDataPoints(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("", metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
s, ckpt := metrictest.Unslice2(lvAgg.New(2))
|
s, ckpt := metrictest.Unslice2(lvAgg.New(2))
|
||||||
assert.NoError(t, s.Update(context.Background(), metric.Number(100), &desc))
|
assert.NoError(t, s.Update(context.Background(), metric.Number(100), &desc))
|
||||||
@ -233,7 +233,7 @@ func TestLastValueIntDataPoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSumErrUnknownValueType(t *testing.T) {
|
func TestSumErrUnknownValueType(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("", metric.ValueRecorderKind, metric.NumberKind(-1))
|
desc := metric.NewDescriptor("", metric.ValueRecorderInstrumentKind, metric.NumberKind(-1))
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
s := &sumAgg.New(1)[0]
|
s := &sumAgg.New(1)[0]
|
||||||
record := export.NewRecord(&desc, &labels, nil, s, intervalStart, intervalEnd)
|
record := export.NewRecord(&desc, &labels, nil, s, intervalStart, intervalEnd)
|
||||||
@ -318,7 +318,7 @@ var _ aggregation.MinMaxSumCount = &testErrMinMaxSumCount{}
|
|||||||
|
|
||||||
func TestRecordAggregatorIncompatibleErrors(t *testing.T) {
|
func TestRecordAggregatorIncompatibleErrors(t *testing.T) {
|
||||||
makeMpb := func(kind aggregation.Kind, agg aggregation.Aggregation) (*metricpb.Metric, error) {
|
makeMpb := func(kind aggregation.Kind, agg aggregation.Aggregation) (*metricpb.Metric, error) {
|
||||||
desc := metric.NewDescriptor("things", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("things", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
res := resource.New()
|
res := resource.New()
|
||||||
test := &testAgg{
|
test := &testAgg{
|
||||||
@ -355,7 +355,7 @@ func TestRecordAggregatorIncompatibleErrors(t *testing.T) {
|
|||||||
|
|
||||||
func TestRecordAggregatorUnexpectedErrors(t *testing.T) {
|
func TestRecordAggregatorUnexpectedErrors(t *testing.T) {
|
||||||
makeMpb := func(kind aggregation.Kind, agg aggregation.Aggregation) (*metricpb.Metric, error) {
|
makeMpb := func(kind aggregation.Kind, agg aggregation.Aggregation) (*metricpb.Metric, error) {
|
||||||
desc := metric.NewDescriptor("things", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("things", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
labels := label.NewSet()
|
labels := label.NewSet()
|
||||||
res := resource.New()
|
res := resource.New()
|
||||||
return Record(export.NewRecord(&desc, &labels, res, agg, intervalStart, intervalEnd))
|
return Record(export.NewRecord(&desc, &labels, res, agg, intervalStart, intervalEnd))
|
||||||
|
@ -130,22 +130,22 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
labels := []label.KeyValue{label.Bool("test", true)}
|
labels := []label.KeyValue{label.Bool("test", true)}
|
||||||
|
|
||||||
type data struct {
|
type data struct {
|
||||||
iKind metric.Kind
|
iKind metric.InstrumentKind
|
||||||
nKind metricapi.NumberKind
|
nKind metricapi.NumberKind
|
||||||
val int64
|
val int64
|
||||||
}
|
}
|
||||||
instruments := map[string]data{
|
instruments := map[string]data{
|
||||||
"test-int64-counter": {metric.CounterKind, metricapi.Int64NumberKind, 1},
|
"test-int64-counter": {metric.CounterInstrumentKind, metricapi.Int64NumberKind, 1},
|
||||||
"test-float64-counter": {metric.CounterKind, metricapi.Float64NumberKind, 1},
|
"test-float64-counter": {metric.CounterInstrumentKind, metricapi.Float64NumberKind, 1},
|
||||||
"test-int64-valuerecorder": {metric.ValueRecorderKind, metricapi.Int64NumberKind, 2},
|
"test-int64-valuerecorder": {metric.ValueRecorderInstrumentKind, metricapi.Int64NumberKind, 2},
|
||||||
"test-float64-valuerecorder": {metric.ValueRecorderKind, metricapi.Float64NumberKind, 2},
|
"test-float64-valuerecorder": {metric.ValueRecorderInstrumentKind, metricapi.Float64NumberKind, 2},
|
||||||
"test-int64-valueobserver": {metric.ValueObserverKind, metricapi.Int64NumberKind, 3},
|
"test-int64-valueobserver": {metric.ValueObserverInstrumentKind, metricapi.Int64NumberKind, 3},
|
||||||
"test-float64-valueobserver": {metric.ValueObserverKind, metricapi.Float64NumberKind, 3},
|
"test-float64-valueobserver": {metric.ValueObserverInstrumentKind, metricapi.Float64NumberKind, 3},
|
||||||
}
|
}
|
||||||
for name, data := range instruments {
|
for name, data := range instruments {
|
||||||
data := data
|
data := data
|
||||||
switch data.iKind {
|
switch data.iKind {
|
||||||
case metric.CounterKind:
|
case metric.CounterInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
metricapi.Must(meter).NewInt64Counter(name).Add(ctx, data.val, labels...)
|
metricapi.Must(meter).NewInt64Counter(name).Add(ctx, data.val, labels...)
|
||||||
@ -154,7 +154,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
default:
|
default:
|
||||||
assert.Failf(t, "unsupported number testing kind", data.nKind.String())
|
assert.Failf(t, "unsupported number testing kind", data.nKind.String())
|
||||||
}
|
}
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
metricapi.Must(meter).NewInt64ValueRecorder(name).Record(ctx, data.val, labels...)
|
metricapi.Must(meter).NewInt64ValueRecorder(name).Record(ctx, data.val, labels...)
|
||||||
@ -163,7 +163,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
default:
|
default:
|
||||||
assert.Failf(t, "unsupported number testing kind", data.nKind.String())
|
assert.Failf(t, "unsupported number testing kind", data.nKind.String())
|
||||||
}
|
}
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
metricapi.Must(meter).NewInt64ValueObserver(name,
|
metricapi.Must(meter).NewInt64ValueObserver(name,
|
||||||
@ -245,7 +245,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
seen[m.Name] = struct{}{}
|
seen[m.Name] = struct{}{}
|
||||||
|
|
||||||
switch data.iKind {
|
switch data.iKind {
|
||||||
case metric.CounterKind:
|
case metric.CounterInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
if dp := m.GetIntSum().DataPoints; assert.Len(t, dp, 1) {
|
if dp := m.GetIntSum().DataPoints; assert.Len(t, dp, 1) {
|
||||||
@ -258,7 +258,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
default:
|
default:
|
||||||
assert.Failf(t, "invalid number kind", data.nKind.String())
|
assert.Failf(t, "invalid number kind", data.nKind.String())
|
||||||
}
|
}
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
if dp := m.GetIntGauge().DataPoints; assert.Len(t, dp, 1) {
|
if dp := m.GetIntGauge().DataPoints; assert.Len(t, dp, 1) {
|
||||||
@ -271,7 +271,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
|||||||
default:
|
default:
|
||||||
assert.Failf(t, "invalid number kind", data.nKind.String())
|
assert.Failf(t, "invalid number kind", data.nKind.String())
|
||||||
}
|
}
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
switch data.nKind {
|
switch data.nKind {
|
||||||
case metricapi.Int64NumberKind:
|
case metricapi.Int64NumberKind:
|
||||||
assert.NotNil(t, m.GetIntHistogram())
|
assert.NotNil(t, m.GetIntHistogram())
|
||||||
|
@ -93,7 +93,7 @@ func (m *checkpointSet) ForEach(_ metricsdk.ExportKindSelector, fn func(metricsd
|
|||||||
|
|
||||||
type record struct {
|
type record struct {
|
||||||
name string
|
name string
|
||||||
mKind metric.Kind
|
iKind metric.InstrumentKind
|
||||||
nKind metric.NumberKind
|
nKind metric.NumberKind
|
||||||
resource *resource.Resource
|
resource *resource.Resource
|
||||||
opts []metric.InstrumentOption
|
opts []metric.InstrumentOption
|
||||||
@ -162,7 +162,7 @@ func TestNoGroupingExport(t *testing.T) {
|
|||||||
[]record{
|
[]record{
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
@ -170,7 +170,7 @@ func TestNoGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
@ -217,7 +217,7 @@ func TestNoGroupingExport(t *testing.T) {
|
|||||||
func TestValuerecorderMetricGroupingExport(t *testing.T) {
|
func TestValuerecorderMetricGroupingExport(t *testing.T) {
|
||||||
r := record{
|
r := record{
|
||||||
"valuerecorder",
|
"valuerecorder",
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
@ -286,7 +286,7 @@ func TestValuerecorderMetricGroupingExport(t *testing.T) {
|
|||||||
func TestCountInt64MetricGroupingExport(t *testing.T) {
|
func TestCountInt64MetricGroupingExport(t *testing.T) {
|
||||||
r := record{
|
r := record{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
@ -335,7 +335,7 @@ func TestCountInt64MetricGroupingExport(t *testing.T) {
|
|||||||
func TestCountFloat64MetricGroupingExport(t *testing.T) {
|
func TestCountFloat64MetricGroupingExport(t *testing.T) {
|
||||||
r := record{
|
r := record{
|
||||||
"float64-count",
|
"float64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Float64NumberKind,
|
metric.Float64NumberKind,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
@ -405,7 +405,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
|
|||||||
[]record{
|
[]record{
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
nil,
|
nil,
|
||||||
@ -413,7 +413,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
nil,
|
nil,
|
||||||
@ -421,7 +421,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
nil,
|
nil,
|
||||||
@ -429,7 +429,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstB,
|
testInstB,
|
||||||
nil,
|
nil,
|
||||||
@ -522,7 +522,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
[]record{
|
[]record{
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
countingLib1,
|
countingLib1,
|
||||||
@ -530,7 +530,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
countingLib2,
|
countingLib2,
|
||||||
@ -538,7 +538,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
countingLib1,
|
countingLib1,
|
||||||
@ -546,7 +546,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
countingLib1,
|
countingLib1,
|
||||||
@ -554,7 +554,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstA,
|
testInstA,
|
||||||
summingLib,
|
summingLib,
|
||||||
@ -562,7 +562,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"int64-count",
|
"int64-count",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.Int64NumberKind,
|
metric.Int64NumberKind,
|
||||||
testInstB,
|
testInstB,
|
||||||
countingLib1,
|
countingLib1,
|
||||||
@ -713,12 +713,12 @@ func runMetricExportTest(t *testing.T, exp *Exporter, rs []record, expected []me
|
|||||||
recs := map[label.Distinct][]metricsdk.Record{}
|
recs := map[label.Distinct][]metricsdk.Record{}
|
||||||
resources := map[label.Distinct]*resource.Resource{}
|
resources := map[label.Distinct]*resource.Resource{}
|
||||||
for _, r := range rs {
|
for _, r := range rs {
|
||||||
desc := metric.NewDescriptor(r.name, r.mKind, r.nKind, r.opts...)
|
desc := metric.NewDescriptor(r.name, r.iKind, r.nKind, r.opts...)
|
||||||
labs := label.NewSet(r.labels...)
|
labs := label.NewSet(r.labels...)
|
||||||
|
|
||||||
var agg, ckpt metricsdk.Aggregator
|
var agg, ckpt metricsdk.Aggregator
|
||||||
switch r.mKind {
|
switch r.iKind {
|
||||||
case metric.CounterKind:
|
case metric.CounterInstrumentKind:
|
||||||
agg, ckpt = metrictest.Unslice2(sum.New(2))
|
agg, ckpt = metrictest.Unslice2(sum.New(2))
|
||||||
default:
|
default:
|
||||||
agg, ckpt = metrictest.Unslice2(histogram.New(2, &desc, testHistogramBoundaries))
|
agg, ckpt = metrictest.Unslice2(histogram.New(2, &desc, testHistogramBoundaries))
|
||||||
|
@ -99,7 +99,7 @@ func TestStdoutTimestamp(t *testing.T) {
|
|||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
|
|
||||||
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ func TestStdoutCounterFormat(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
|
|
||||||
cagg, ckpt := metrictest.Unslice2(sum.New(2))
|
cagg, ckpt := metrictest.Unslice2(sum.New(2))
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ func TestStdoutLastValueFormat(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueObserverInstrumentKind, metric.Float64NumberKind)
|
||||||
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
||||||
|
|
||||||
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
|
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
|
||||||
@ -175,7 +175,7 @@ func TestStdoutMinMaxSumCount(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueRecorderKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
|
|
||||||
magg, ckpt := metrictest.Unslice2(minmaxsumcount.New(2, &desc))
|
magg, ckpt := metrictest.Unslice2(minmaxsumcount.New(2, &desc))
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ func TestStdoutValueRecorderFormat(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueRecorderKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
aagg, ckpt := metrictest.Unslice2(array.New(2))
|
aagg, ckpt := metrictest.Unslice2(array.New(2))
|
||||||
|
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
@ -234,7 +234,7 @@ func TestStdoutValueRecorderFormat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStdoutNoData(t *testing.T) {
|
func TestStdoutNoData(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueRecorderKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
|
|
||||||
runTwoAggs := func(agg, ckpt export.Aggregator) {
|
runTwoAggs := func(agg, ckpt export.Aggregator) {
|
||||||
t.Run(fmt.Sprintf("%T", agg), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%T", agg), func(t *testing.T) {
|
||||||
@ -263,7 +263,7 @@ func TestStdoutLastValueNotSet(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
checkpointSet := metrictest.NewCheckpointSet(testResource)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueObserverInstrumentKind, metric.Float64NumberKind)
|
||||||
|
|
||||||
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
||||||
require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc))
|
require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc))
|
||||||
@ -314,7 +314,7 @@ func TestStdoutResource(t *testing.T) {
|
|||||||
|
|
||||||
checkpointSet := metrictest.NewCheckpointSet(tc.res)
|
checkpointSet := metrictest.NewCheckpointSet(tc.res)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind)
|
desc := metric.NewDescriptor("test.name", metric.ValueObserverInstrumentKind, metric.Float64NumberKind)
|
||||||
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))
|
||||||
|
|
||||||
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
|
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
|
||||||
|
@ -37,16 +37,16 @@ func TestExportKindIncludes(t *testing.T) {
|
|||||||
require.False(t, DeltaExporter.Includes(PassThroughExporter|CumulativeExporter))
|
require.False(t, DeltaExporter.Includes(PassThroughExporter|CumulativeExporter))
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaMemoryKinds = []metric.Kind{
|
var deltaMemoryKinds = []metric.InstrumentKind{
|
||||||
metric.SumObserverKind,
|
metric.SumObserverInstrumentKind,
|
||||||
metric.UpDownSumObserverKind,
|
metric.UpDownSumObserverInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
var cumulativeMemoryKinds = []metric.Kind{
|
var cumulativeMemoryKinds = []metric.InstrumentKind{
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.UpDownCounterKind,
|
metric.UpDownCounterInstrumentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExportKindMemoryRequired(t *testing.T) {
|
func TestExportKindMemoryRequired(t *testing.T) {
|
||||||
|
@ -385,14 +385,14 @@ func (kind ExportKind) ExportKindFor(_ *metric.Descriptor, _ aggregation.Kind) E
|
|||||||
|
|
||||||
// MemoryRequired returns whether an exporter of this kind requires
|
// MemoryRequired returns whether an exporter of this kind requires
|
||||||
// memory to export correctly.
|
// memory to export correctly.
|
||||||
func (kind ExportKind) MemoryRequired(mkind metric.Kind) bool {
|
func (kind ExportKind) MemoryRequired(mkind metric.InstrumentKind) bool {
|
||||||
switch mkind {
|
switch mkind {
|
||||||
case metric.ValueRecorderKind, metric.ValueObserverKind,
|
case metric.ValueRecorderInstrumentKind, metric.ValueObserverInstrumentKind,
|
||||||
metric.CounterKind, metric.UpDownCounterKind:
|
metric.CounterInstrumentKind, metric.UpDownCounterInstrumentKind:
|
||||||
// Delta-oriented instruments:
|
// Delta-oriented instruments:
|
||||||
return kind.Includes(CumulativeExporter)
|
return kind.Includes(CumulativeExporter)
|
||||||
|
|
||||||
case metric.SumObserverKind, metric.UpDownSumObserverKind:
|
case metric.SumObserverInstrumentKind, metric.UpDownSumObserverInstrumentKind:
|
||||||
// Cumulative-oriented instruments:
|
// Cumulative-oriented instruments:
|
||||||
return kind.Includes(DeltaExporter)
|
return kind.Includes(DeltaExporter)
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ func RangeTest(number metric.Number, descriptor *metric.Descriptor) error {
|
|||||||
return aggregation.ErrNaNInput
|
return aggregation.ErrNaNInput
|
||||||
}
|
}
|
||||||
|
|
||||||
switch descriptor.MetricKind() {
|
switch descriptor.InstrumentKind() {
|
||||||
case metric.CounterKind, metric.SumObserverKind:
|
case metric.CounterInstrumentKind, metric.SumObserverInstrumentKind:
|
||||||
if number.IsNegative(numberKind) {
|
if number.IsNegative(numberKind) {
|
||||||
return aggregation.ErrNegativeInput
|
return aggregation.ErrNegativeInput
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func TestRangeTest(t *testing.T) {
|
|||||||
t.Run(nkind.String(), func(t *testing.T) {
|
t.Run(nkind.String(), func(t *testing.T) {
|
||||||
desc := metric.NewDescriptor(
|
desc := metric.NewDescriptor(
|
||||||
"name",
|
"name",
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
nkind,
|
nkind,
|
||||||
)
|
)
|
||||||
testRangeNegative(t, &desc)
|
testRangeNegative(t, &desc)
|
||||||
@ -85,10 +85,10 @@ func TestRangeTest(t *testing.T) {
|
|||||||
func TestNaNTest(t *testing.T) {
|
func TestNaNTest(t *testing.T) {
|
||||||
for _, nkind := range []metric.NumberKind{metric.Float64NumberKind, metric.Int64NumberKind} {
|
for _, nkind := range []metric.NumberKind{metric.Float64NumberKind, metric.Int64NumberKind} {
|
||||||
t.Run(nkind.String(), func(t *testing.T) {
|
t.Run(nkind.String(), func(t *testing.T) {
|
||||||
for _, mkind := range []metric.Kind{
|
for _, mkind := range []metric.InstrumentKind{
|
||||||
metric.CounterKind,
|
metric.CounterInstrumentKind,
|
||||||
metric.ValueRecorderKind,
|
metric.ValueRecorderInstrumentKind,
|
||||||
metric.ValueObserverKind,
|
metric.ValueObserverInstrumentKind,
|
||||||
} {
|
} {
|
||||||
desc := metric.NewDescriptor(
|
desc := metric.NewDescriptor(
|
||||||
"name",
|
"name",
|
||||||
|
@ -53,7 +53,7 @@ func newProfiles() []Profile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAggregatorTest(mkind metric.Kind, nkind metric.NumberKind) *metric.Descriptor {
|
func NewAggregatorTest(mkind metric.InstrumentKind, nkind metric.NumberKind) *metric.Descriptor {
|
||||||
desc := metric.NewDescriptor("test.name", mkind, nkind)
|
desc := metric.NewDescriptor("test.name", mkind, nkind)
|
||||||
return &desc
|
return &desc
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func new4() (_, _, _, _ *Aggregator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
|
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
agg, ckpt := new2()
|
agg, ckpt := new2()
|
||||||
|
|
||||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||||
@ -129,7 +129,7 @@ type mergeTest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
|
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4()
|
agg1, agg2, ckpt1, ckpt2 := new4()
|
||||||
|
|
||||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||||
@ -225,7 +225,7 @@ func TestArrayErrors(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, err, aggregation.ErrNoData)
|
require.Equal(t, err, aggregation.ErrNoData)
|
||||||
|
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
aggregatortest.CheckedUpdate(t, agg, metric.Number(0), descriptor)
|
aggregatortest.CheckedUpdate(t, agg, metric.Number(0), descriptor)
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ func TestArrayErrors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestArrayFloat64(t *testing.T) {
|
func TestArrayFloat64(t *testing.T) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
|
|
||||||
fpsf := func(sign int) []float64 {
|
fpsf := func(sign int) []float64 {
|
||||||
// Check behavior of a bunch of odd floating
|
// Check behavior of a bunch of odd floating
|
||||||
|
@ -66,7 +66,7 @@ func checkZero(t *testing.T, agg *Aggregator, desc *metric.Descriptor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
|
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
agg, ckpt := new2(descriptor)
|
agg, ckpt := new2(descriptor)
|
||||||
|
|
||||||
all := aggregatortest.NewNumbers(profile.NumberKind)
|
all := aggregatortest.NewNumbers(profile.NumberKind)
|
||||||
@ -127,7 +127,7 @@ type mergeTest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
|
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func benchmarkHistogramSearchFloat64(b *testing.B, size int) {
|
|||||||
for i := range values {
|
for i := range values {
|
||||||
values[i] = rand.Float64() * inputRange
|
values[i] = rand.Float64() * inputRange
|
||||||
}
|
}
|
||||||
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)
|
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, metric.Float64NumberKind)
|
||||||
agg := &histogram.New(1, desc, boundaries)[0]
|
agg := &histogram.New(1, desc, boundaries)[0]
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func benchmarkHistogramSearchInt64(b *testing.B, size int) {
|
|||||||
for i := range values {
|
for i := range values {
|
||||||
values[i] = int64(rand.Float64() * inputRange)
|
values[i] = int64(rand.Float64() * inputRange)
|
||||||
}
|
}
|
||||||
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
agg := &histogram.New(1, desc, boundaries)[0]
|
agg := &histogram.New(1, desc, boundaries)[0]
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ func TestHistogramPositiveAndNegative(t *testing.T) {
|
|||||||
|
|
||||||
// Validates count, sum and buckets for a given profile and policy
|
// Validates count, sum and buckets for a given profile and policy
|
||||||
func testHistogram(t *testing.T, profile aggregatortest.Profile, policy policy) {
|
func testHistogram(t *testing.T, profile aggregatortest.Profile, policy policy) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg, ckpt := new2(descriptor)
|
agg, ckpt := new2(descriptor)
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func testHistogram(t *testing.T, profile aggregatortest.Profile, policy policy)
|
|||||||
|
|
||||||
func TestHistogramInitial(t *testing.T) {
|
func TestHistogramInitial(t *testing.T) {
|
||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg := &histogram.New(1, descriptor, boundaries)[0]
|
agg := &histogram.New(1, descriptor, boundaries)[0]
|
||||||
buckets, err := agg.Histogram()
|
buckets, err := agg.Histogram()
|
||||||
@ -167,7 +167,7 @@ func TestHistogramInitial(t *testing.T) {
|
|||||||
|
|
||||||
func TestHistogramMerge(t *testing.T) {
|
func TestHistogramMerge(t *testing.T) {
|
||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ func TestHistogramMerge(t *testing.T) {
|
|||||||
|
|
||||||
func TestHistogramNotSet(t *testing.T) {
|
func TestHistogramNotSet(t *testing.T) {
|
||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg, ckpt := new2(descriptor)
|
agg, ckpt := new2(descriptor)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ func TestLastValueUpdate(t *testing.T) {
|
|||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
agg, ckpt := new2()
|
agg, ckpt := new2()
|
||||||
|
|
||||||
record := aggregatortest.NewAggregatorTest(metric.ValueObserverKind, profile.NumberKind)
|
record := aggregatortest.NewAggregatorTest(metric.ValueObserverInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
var last metric.Number
|
var last metric.Number
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
@ -93,7 +93,7 @@ func TestLastValueMerge(t *testing.T) {
|
|||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4()
|
agg1, agg2, ckpt1, ckpt2 := new4()
|
||||||
|
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueObserverKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueObserverInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
first1 := profile.Random(+1)
|
first1 := profile.Random(+1)
|
||||||
first2 := profile.Random(+1)
|
first2 := profile.Random(+1)
|
||||||
@ -124,7 +124,7 @@ func TestLastValueMerge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLastValueNotSet(t *testing.T) {
|
func TestLastValueNotSet(t *testing.T) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueObserverKind, metric.Int64NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
|
|
||||||
g, ckpt := new2()
|
g, ckpt := new2()
|
||||||
require.NoError(t, g.SynchronizedMove(ckpt, descriptor))
|
require.NoError(t, g.SynchronizedMove(ckpt, descriptor))
|
||||||
|
@ -108,7 +108,7 @@ func checkZero(t *testing.T, agg *Aggregator, desc *metric.Descriptor) {
|
|||||||
|
|
||||||
// Validates min, max, sum and count for a given profile and policy
|
// Validates min, max, sum and count for a given profile and policy
|
||||||
func minMaxSumCount(t *testing.T, profile aggregatortest.Profile, policy policy) {
|
func minMaxSumCount(t *testing.T, profile aggregatortest.Profile, policy policy) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg, ckpt := new2(descriptor)
|
agg, ckpt := new2(descriptor)
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ func minMaxSumCount(t *testing.T, profile aggregatortest.Profile, policy policy)
|
|||||||
|
|
||||||
func TestMinMaxSumCountMerge(t *testing.T) {
|
func TestMinMaxSumCountMerge(t *testing.T) {
|
||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
agg1, agg2, ckpt1, ckpt2 := new4(descriptor)
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ func TestMinMaxSumCountMerge(t *testing.T) {
|
|||||||
|
|
||||||
func TestMaxSumCountNotSet(t *testing.T) {
|
func TestMaxSumCountNotSet(t *testing.T) {
|
||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
alloc := New(2, descriptor)
|
alloc := New(2, descriptor)
|
||||||
agg, ckpt := &alloc[0], &alloc[1]
|
agg, ckpt := &alloc[0], &alloc[1]
|
||||||
|
@ -65,7 +65,7 @@ func TestCounterSum(t *testing.T) {
|
|||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
agg, ckpt := new2()
|
agg, ckpt := new2()
|
||||||
|
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.CounterKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.CounterInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
sum := metric.Number(0)
|
sum := metric.Number(0)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
@ -89,7 +89,7 @@ func TestValueRecorderSum(t *testing.T) {
|
|||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
agg, ckpt := new2()
|
agg, ckpt := new2()
|
||||||
|
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
sum := metric.Number(0)
|
sum := metric.Number(0)
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ func TestCounterMerge(t *testing.T) {
|
|||||||
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
|
||||||
agg1, agg2, ckpt1, ckpt2 := new4()
|
agg1, agg2, ckpt1, ckpt2 := new4()
|
||||||
|
|
||||||
descriptor := aggregatortest.NewAggregatorTest(metric.CounterKind, profile.NumberKind)
|
descriptor := aggregatortest.NewAggregatorTest(metric.CounterInstrumentKind, profile.NumberKind)
|
||||||
|
|
||||||
sum := metric.Number(0)
|
sum := metric.Number(0)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStressInt64Histogram(t *testing.T) {
|
func TestStressInt64Histogram(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("some_metric", metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("some_metric", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
|
|
||||||
alloc := histogram.New(2, &desc, []float64{25, 50, 75})
|
alloc := histogram.New(2, &desc, []float64{25, 50, 75})
|
||||||
h, ckpt := &alloc[0], &alloc[1]
|
h, ckpt := &alloc[0], &alloc[1]
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStressInt64MinMaxSumCount(t *testing.T) {
|
func TestStressInt64MinMaxSumCount(t *testing.T) {
|
||||||
desc := metric.NewDescriptor("some_metric", metric.ValueRecorderKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("some_metric", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
alloc := minmaxsumcount.New(2, &desc)
|
alloc := minmaxsumcount.New(2, &desc)
|
||||||
mmsc, ckpt := &alloc[0], &alloc[1]
|
mmsc, ckpt := &alloc[0], &alloc[1]
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ func (b *Processor) Process(accum export.Accumulation) error {
|
|||||||
// Check if there is an existing value.
|
// Check if there is an existing value.
|
||||||
value, ok := b.state.values[key]
|
value, ok := b.state.values[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
stateful := b.ExportKindFor(desc, agg.Aggregation().Kind()).MemoryRequired(desc.MetricKind())
|
stateful := b.ExportKindFor(desc, agg.Aggregation().Kind()).MemoryRequired(desc.InstrumentKind())
|
||||||
|
|
||||||
newValue := &stateValue{
|
newValue := &stateValue{
|
||||||
labels: accum.Labels(),
|
labels: accum.Labels(),
|
||||||
@ -170,7 +170,7 @@ func (b *Processor) Process(accum export.Accumulation) error {
|
|||||||
current: agg,
|
current: agg,
|
||||||
}
|
}
|
||||||
if stateful {
|
if stateful {
|
||||||
if desc.MetricKind().PrecomputedSum() {
|
if desc.InstrumentKind().PrecomputedSum() {
|
||||||
// If we know we need to compute deltas, allocate two aggregators.
|
// If we know we need to compute deltas, allocate two aggregators.
|
||||||
b.AggregatorFor(desc, &newValue.cumulative, &newValue.delta)
|
b.AggregatorFor(desc, &newValue.cumulative, &newValue.delta)
|
||||||
} else {
|
} else {
|
||||||
@ -207,7 +207,7 @@ func (b *Processor) Process(accum export.Accumulation) error {
|
|||||||
// instrument reports a PrecomputedSum to a DeltaExporter or
|
// instrument reports a PrecomputedSum to a DeltaExporter or
|
||||||
// the reverse, a non-PrecomputedSum instrument with a
|
// the reverse, a non-PrecomputedSum instrument with a
|
||||||
// CumulativeExporter. This logic is encapsulated in
|
// CumulativeExporter. This logic is encapsulated in
|
||||||
// ExportKind.MemoryRequired(MetricKind).
|
// ExportKind.MemoryRequired(InstrumentKind).
|
||||||
//
|
//
|
||||||
// Case (b) occurs when the variable `sameCollection` is true,
|
// Case (b) occurs when the variable `sameCollection` is true,
|
||||||
// indicating that the stateKey for Accumulation has already
|
// indicating that the stateKey for Accumulation has already
|
||||||
@ -272,7 +272,7 @@ func (b *Processor) FinishCollection() error {
|
|||||||
defer func() { b.finishedCollection++ }()
|
defer func() { b.finishedCollection++ }()
|
||||||
|
|
||||||
for key, value := range b.values {
|
for key, value := range b.values {
|
||||||
mkind := key.descriptor.MetricKind()
|
mkind := key.descriptor.InstrumentKind()
|
||||||
stale := value.updated != b.finishedCollection
|
stale := value.updated != b.finishedCollection
|
||||||
stateless := !value.stateful
|
stateless := !value.stateful
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ func (b *state) ForEach(exporter export.ExportKindSelector, f func(export.Record
|
|||||||
return ErrInconsistentState
|
return ErrInconsistentState
|
||||||
}
|
}
|
||||||
for key, value := range b.values {
|
for key, value := range b.values {
|
||||||
mkind := key.descriptor.MetricKind()
|
mkind := key.descriptor.InstrumentKind()
|
||||||
|
|
||||||
var agg aggregation.Aggregation
|
var agg aggregation.Aggregation
|
||||||
var start time.Time
|
var start time.Time
|
||||||
|
@ -40,7 +40,7 @@ func TestProcessor(t *testing.T) {
|
|||||||
kind export.ExportKind
|
kind export.ExportKind
|
||||||
}
|
}
|
||||||
type instrumentCase struct {
|
type instrumentCase struct {
|
||||||
kind metric.Kind
|
kind metric.InstrumentKind
|
||||||
}
|
}
|
||||||
type numberCase struct {
|
type numberCase struct {
|
||||||
kind metric.NumberKind
|
kind metric.NumberKind
|
||||||
@ -56,12 +56,12 @@ func TestProcessor(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
t.Run(tc.kind.String(), func(t *testing.T) {
|
t.Run(tc.kind.String(), func(t *testing.T) {
|
||||||
for _, ic := range []instrumentCase{
|
for _, ic := range []instrumentCase{
|
||||||
{kind: metric.CounterKind},
|
{kind: metric.CounterInstrumentKind},
|
||||||
{kind: metric.UpDownCounterKind},
|
{kind: metric.UpDownCounterInstrumentKind},
|
||||||
{kind: metric.ValueRecorderKind},
|
{kind: metric.ValueRecorderInstrumentKind},
|
||||||
{kind: metric.SumObserverKind},
|
{kind: metric.SumObserverInstrumentKind},
|
||||||
{kind: metric.UpDownSumObserverKind},
|
{kind: metric.UpDownSumObserverInstrumentKind},
|
||||||
{kind: metric.ValueObserverKind},
|
{kind: metric.ValueObserverInstrumentKind},
|
||||||
} {
|
} {
|
||||||
t.Run(ic.kind.String(), func(t *testing.T) {
|
t.Run(ic.kind.String(), func(t *testing.T) {
|
||||||
for _, nc := range []numberCase{
|
for _, nc := range []numberCase{
|
||||||
@ -114,7 +114,7 @@ func updateFor(t *testing.T, desc *metric.Descriptor, selector export.Aggregator
|
|||||||
func testProcessor(
|
func testProcessor(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ekind export.ExportKind,
|
ekind export.ExportKind,
|
||||||
mkind metric.Kind,
|
mkind metric.InstrumentKind,
|
||||||
nkind metric.NumberKind,
|
nkind metric.NumberKind,
|
||||||
akind aggregation.Kind,
|
akind aggregation.Kind,
|
||||||
) {
|
) {
|
||||||
@ -295,7 +295,7 @@ func TestBasicInconsistent(t *testing.T) {
|
|||||||
// Test no start
|
// Test no start
|
||||||
b = basic.New(processorTest.AggregatorSelector(), export.PassThroughExporter)
|
b = basic.New(processorTest.AggregatorSelector(), export.PassThroughExporter)
|
||||||
|
|
||||||
desc := metric.NewDescriptor("inst", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("inst", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
||||||
require.Equal(t, basic.ErrInconsistentState, b.Process(accum))
|
require.Equal(t, basic.ErrInconsistentState, b.Process(accum))
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ func TestBasicTimestamps(t *testing.T) {
|
|||||||
b := basic.New(processorTest.AggregatorSelector(), export.PassThroughExporter)
|
b := basic.New(processorTest.AggregatorSelector(), export.PassThroughExporter)
|
||||||
afterNew := time.Now()
|
afterNew := time.Now()
|
||||||
|
|
||||||
desc := metric.NewDescriptor("inst", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("inst", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
||||||
|
|
||||||
b.StartCollection()
|
b.StartCollection()
|
||||||
@ -364,7 +364,7 @@ func TestStatefulNoMemoryCumulative(t *testing.T) {
|
|||||||
res := resource.New(label.String("R", "V"))
|
res := resource.New(label.String("R", "V"))
|
||||||
ekind := export.CumulativeExporter
|
ekind := export.CumulativeExporter
|
||||||
|
|
||||||
desc := metric.NewDescriptor("inst.sum", metric.CounterKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("inst.sum", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
selector := processorTest.AggregatorSelector()
|
selector := processorTest.AggregatorSelector()
|
||||||
|
|
||||||
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
||||||
@ -398,7 +398,7 @@ func TestStatefulNoMemoryDelta(t *testing.T) {
|
|||||||
res := resource.New(label.String("R", "V"))
|
res := resource.New(label.String("R", "V"))
|
||||||
ekind := export.DeltaExporter
|
ekind := export.DeltaExporter
|
||||||
|
|
||||||
desc := metric.NewDescriptor("inst.sum", metric.SumObserverKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("inst.sum", metric.SumObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
selector := processorTest.AggregatorSelector()
|
selector := processorTest.AggregatorSelector()
|
||||||
|
|
||||||
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
||||||
@ -436,7 +436,7 @@ func TestMultiObserverSum(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
|
|
||||||
res := resource.New(label.String("R", "V"))
|
res := resource.New(label.String("R", "V"))
|
||||||
desc := metric.NewDescriptor("observe.sum", metric.SumObserverKind, metric.Int64NumberKind)
|
desc := metric.NewDescriptor("observe.sum", metric.SumObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
selector := processorTest.AggregatorSelector()
|
selector := processorTest.AggregatorSelector()
|
||||||
|
|
||||||
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
processor := basic.New(selector, ekind, basic.WithMemory(false))
|
||||||
|
@ -95,10 +95,10 @@ func lastValueAggs(aggPtrs []*export.Aggregator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (selectorInexpensive) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
func (selectorInexpensive) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
||||||
switch descriptor.MetricKind() {
|
switch descriptor.InstrumentKind() {
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
lastValueAggs(aggPtrs)
|
lastValueAggs(aggPtrs)
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
aggs := minmaxsumcount.New(len(aggPtrs), descriptor)
|
aggs := minmaxsumcount.New(len(aggPtrs), descriptor)
|
||||||
for i := range aggPtrs {
|
for i := range aggPtrs {
|
||||||
*aggPtrs[i] = &aggs[i]
|
*aggPtrs[i] = &aggs[i]
|
||||||
@ -109,10 +109,10 @@ func (selectorInexpensive) AggregatorFor(descriptor *metric.Descriptor, aggPtrs
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s selectorSketch) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
func (s selectorSketch) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
||||||
switch descriptor.MetricKind() {
|
switch descriptor.InstrumentKind() {
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
lastValueAggs(aggPtrs)
|
lastValueAggs(aggPtrs)
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
aggs := ddsketch.New(len(aggPtrs), descriptor, s.config)
|
aggs := ddsketch.New(len(aggPtrs), descriptor, s.config)
|
||||||
for i := range aggPtrs {
|
for i := range aggPtrs {
|
||||||
*aggPtrs[i] = &aggs[i]
|
*aggPtrs[i] = &aggs[i]
|
||||||
@ -123,10 +123,10 @@ func (s selectorSketch) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (selectorExact) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
func (selectorExact) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
||||||
switch descriptor.MetricKind() {
|
switch descriptor.InstrumentKind() {
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
lastValueAggs(aggPtrs)
|
lastValueAggs(aggPtrs)
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
aggs := array.New(len(aggPtrs))
|
aggs := array.New(len(aggPtrs))
|
||||||
for i := range aggPtrs {
|
for i := range aggPtrs {
|
||||||
*aggPtrs[i] = &aggs[i]
|
*aggPtrs[i] = &aggs[i]
|
||||||
@ -137,10 +137,10 @@ func (selectorExact) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s selectorHistogram) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
func (s selectorHistogram) AggregatorFor(descriptor *metric.Descriptor, aggPtrs ...*export.Aggregator) {
|
||||||
switch descriptor.MetricKind() {
|
switch descriptor.InstrumentKind() {
|
||||||
case metric.ValueObserverKind:
|
case metric.ValueObserverInstrumentKind:
|
||||||
lastValueAggs(aggPtrs)
|
lastValueAggs(aggPtrs)
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
aggs := histogram.New(len(aggPtrs), descriptor, s.boundaries)
|
aggs := histogram.New(len(aggPtrs), descriptor, s.boundaries)
|
||||||
for i := range aggPtrs {
|
for i := range aggPtrs {
|
||||||
*aggPtrs[i] = &aggs[i]
|
*aggPtrs[i] = &aggs[i]
|
||||||
|
@ -31,12 +31,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testCounterDesc = metric.NewDescriptor("counter", metric.CounterKind, metric.Int64NumberKind)
|
testCounterDesc = metric.NewDescriptor("counter", metric.CounterInstrumentKind, metric.Int64NumberKind)
|
||||||
testUpDownCounterDesc = metric.NewDescriptor("updowncounter", metric.UpDownCounterKind, metric.Int64NumberKind)
|
testUpDownCounterDesc = metric.NewDescriptor("updowncounter", metric.UpDownCounterInstrumentKind, metric.Int64NumberKind)
|
||||||
testSumObserverDesc = metric.NewDescriptor("sumobserver", metric.SumObserverKind, metric.Int64NumberKind)
|
testSumObserverDesc = metric.NewDescriptor("sumobserver", metric.SumObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
testUpDownSumObserverDesc = metric.NewDescriptor("updownsumobserver", metric.UpDownSumObserverKind, metric.Int64NumberKind)
|
testUpDownSumObserverDesc = metric.NewDescriptor("updownsumobserver", metric.UpDownSumObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
testValueRecorderDesc = metric.NewDescriptor("valuerecorder", metric.ValueRecorderKind, metric.Int64NumberKind)
|
testValueRecorderDesc = metric.NewDescriptor("valuerecorder", metric.ValueRecorderInstrumentKind, metric.Int64NumberKind)
|
||||||
testValueObserverDesc = metric.NewDescriptor("valueobserver", metric.ValueObserverKind, metric.Int64NumberKind)
|
testValueObserverDesc = metric.NewDescriptor("valueobserver", metric.ValueObserverInstrumentKind, metric.Int64NumberKind)
|
||||||
)
|
)
|
||||||
|
|
||||||
func oneAgg(sel export.AggregatorSelector, desc *metric.Descriptor) export.Aggregator {
|
func oneAgg(sel export.AggregatorSelector, desc *metric.Descriptor) export.Aggregator {
|
||||||
|
@ -264,14 +264,14 @@ func (f *testFixture) Process(accumulation export.Accumulation) error {
|
|||||||
actual, _ := f.received.LoadOrStore(key, f.impl.newStore())
|
actual, _ := f.received.LoadOrStore(key, f.impl.newStore())
|
||||||
|
|
||||||
agg := accumulation.Aggregator()
|
agg := accumulation.Aggregator()
|
||||||
switch accumulation.Descriptor().MetricKind() {
|
switch accumulation.Descriptor().InstrumentKind() {
|
||||||
case metric.CounterKind:
|
case metric.CounterInstrumentKind:
|
||||||
sum, err := agg.(aggregation.Sum).Sum()
|
sum, err := agg.(aggregation.Sum).Sum()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.T.Fatal("Sum error: ", err)
|
f.T.Fatal("Sum error: ", err)
|
||||||
}
|
}
|
||||||
f.impl.storeCollect(actual, sum, time.Time{})
|
f.impl.storeCollect(actual, sum, time.Time{})
|
||||||
case metric.ValueRecorderKind:
|
case metric.ValueRecorderInstrumentKind:
|
||||||
lv, ts, err := agg.(aggregation.LastValue).LastValue()
|
lv, ts, err := agg.(aggregation.LastValue).LastValue()
|
||||||
if err != nil && err != aggregation.ErrNoData {
|
if err != nil && err != aggregation.ErrNoData {
|
||||||
f.T.Fatal("Last value error: ", err)
|
f.T.Fatal("Last value error: ", err)
|
||||||
|
Reference in New Issue
Block a user