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
Move metric code to a separate package (#1321)
* Move metrics code to metric package * Update changelog
This commit is contained in:
@ -24,8 +24,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
|
||||
@ -41,7 +41,7 @@ func TestProcessor(t *testing.T) {
|
||||
kind export.ExportKind
|
||||
}
|
||||
type instrumentCase struct {
|
||||
kind otel.InstrumentKind
|
||||
kind metric.InstrumentKind
|
||||
}
|
||||
type numberCase struct {
|
||||
kind number.Kind
|
||||
@ -56,12 +56,12 @@ func TestProcessor(t *testing.T) {
|
||||
} {
|
||||
t.Run(tc.kind.String(), func(t *testing.T) {
|
||||
for _, ic := range []instrumentCase{
|
||||
{kind: otel.CounterInstrumentKind},
|
||||
{kind: otel.UpDownCounterInstrumentKind},
|
||||
{kind: otel.ValueRecorderInstrumentKind},
|
||||
{kind: otel.SumObserverInstrumentKind},
|
||||
{kind: otel.UpDownSumObserverInstrumentKind},
|
||||
{kind: otel.ValueObserverInstrumentKind},
|
||||
{kind: metric.CounterInstrumentKind},
|
||||
{kind: metric.UpDownCounterInstrumentKind},
|
||||
{kind: metric.ValueRecorderInstrumentKind},
|
||||
{kind: metric.SumObserverInstrumentKind},
|
||||
{kind: metric.UpDownSumObserverInstrumentKind},
|
||||
{kind: metric.ValueObserverInstrumentKind},
|
||||
} {
|
||||
t.Run(ic.kind.String(), func(t *testing.T) {
|
||||
for _, nc := range []numberCase{
|
||||
@ -102,7 +102,7 @@ func asNumber(nkind number.Kind, value int64) number.Number {
|
||||
return number.NewFloat64Number(float64(value))
|
||||
}
|
||||
|
||||
func updateFor(t *testing.T, desc *otel.Descriptor, selector export.AggregatorSelector, res *resource.Resource, value int64, labs ...label.KeyValue) export.Accumulation {
|
||||
func updateFor(t *testing.T, desc *metric.Descriptor, selector export.AggregatorSelector, res *resource.Resource, value int64, labs ...label.KeyValue) export.Accumulation {
|
||||
ls := label.NewSet(labs...)
|
||||
var agg export.Aggregator
|
||||
selector.AggregatorFor(desc, &agg)
|
||||
@ -114,7 +114,7 @@ func updateFor(t *testing.T, desc *otel.Descriptor, selector export.AggregatorSe
|
||||
func testProcessor(
|
||||
t *testing.T,
|
||||
ekind export.ExportKind,
|
||||
mkind otel.InstrumentKind,
|
||||
mkind metric.InstrumentKind,
|
||||
nkind number.Kind,
|
||||
akind aggregation.Kind,
|
||||
) {
|
||||
@ -131,8 +131,8 @@ func testProcessor(
|
||||
|
||||
instSuffix := fmt.Sprint(".", strings.ToLower(akind.String()))
|
||||
|
||||
desc1 := otel.NewDescriptor(fmt.Sprint("inst1", instSuffix), mkind, nkind)
|
||||
desc2 := otel.NewDescriptor(fmt.Sprint("inst2", instSuffix), mkind, nkind)
|
||||
desc1 := metric.NewDescriptor(fmt.Sprint("inst1", instSuffix), mkind, nkind)
|
||||
desc2 := metric.NewDescriptor(fmt.Sprint("inst2", instSuffix), mkind, nkind)
|
||||
|
||||
for nc := 0; nc < nCheckpoint; nc++ {
|
||||
|
||||
@ -258,7 +258,7 @@ func testProcessor(
|
||||
|
||||
type bogusExporter struct{}
|
||||
|
||||
func (bogusExporter) ExportKindFor(*otel.Descriptor, aggregation.Kind) export.ExportKind {
|
||||
func (bogusExporter) ExportKindFor(*metric.Descriptor, aggregation.Kind) export.ExportKind {
|
||||
return 1000000
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ func TestBasicInconsistent(t *testing.T) {
|
||||
// Test no start
|
||||
b = basic.New(processorTest.AggregatorSelector(), export.StatelessExportKindSelector())
|
||||
|
||||
desc := otel.NewDescriptor("inst", otel.CounterInstrumentKind, number.Int64Kind)
|
||||
desc := metric.NewDescriptor("inst", metric.CounterInstrumentKind, number.Int64Kind)
|
||||
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
||||
require.Equal(t, basic.ErrInconsistentState, b.Process(accum))
|
||||
|
||||
@ -318,7 +318,7 @@ func TestBasicTimestamps(t *testing.T) {
|
||||
b := basic.New(processorTest.AggregatorSelector(), export.StatelessExportKindSelector())
|
||||
afterNew := time.Now()
|
||||
|
||||
desc := otel.NewDescriptor("inst", otel.CounterInstrumentKind, number.Int64Kind)
|
||||
desc := metric.NewDescriptor("inst", metric.CounterInstrumentKind, number.Int64Kind)
|
||||
accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{})
|
||||
|
||||
b.StartCollection()
|
||||
@ -364,7 +364,7 @@ func TestStatefulNoMemoryCumulative(t *testing.T) {
|
||||
res := resource.NewWithAttributes(label.String("R", "V"))
|
||||
ekindSel := export.CumulativeExportKindSelector()
|
||||
|
||||
desc := otel.NewDescriptor("inst.sum", otel.CounterInstrumentKind, number.Int64Kind)
|
||||
desc := metric.NewDescriptor("inst.sum", metric.CounterInstrumentKind, number.Int64Kind)
|
||||
selector := processorTest.AggregatorSelector()
|
||||
|
||||
processor := basic.New(selector, ekindSel, basic.WithMemory(false))
|
||||
@ -398,7 +398,7 @@ func TestStatefulNoMemoryDelta(t *testing.T) {
|
||||
res := resource.NewWithAttributes(label.String("R", "V"))
|
||||
ekindSel := export.DeltaExportKindSelector()
|
||||
|
||||
desc := otel.NewDescriptor("inst.sum", otel.SumObserverInstrumentKind, number.Int64Kind)
|
||||
desc := metric.NewDescriptor("inst.sum", metric.SumObserverInstrumentKind, number.Int64Kind)
|
||||
selector := processorTest.AggregatorSelector()
|
||||
|
||||
processor := basic.New(selector, ekindSel, basic.WithMemory(false))
|
||||
@ -435,7 +435,7 @@ func TestMultiObserverSum(t *testing.T) {
|
||||
} {
|
||||
|
||||
res := resource.NewWithAttributes(label.String("R", "V"))
|
||||
desc := otel.NewDescriptor("observe.sum", otel.SumObserverInstrumentKind, number.Int64Kind)
|
||||
desc := metric.NewDescriptor("observe.sum", metric.SumObserverInstrumentKind, number.Int64Kind)
|
||||
selector := processorTest.AggregatorSelector()
|
||||
|
||||
processor := basic.New(selector, ekindSel, basic.WithMemory(false))
|
||||
|
Reference in New Issue
Block a user