1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Replace view use from sdk/metric/view to sdk/metric (#3461)

* Replace view usage in sdk/metric

* Replace view use in stdoutmetric

* Replace view use in prometheus exporter

* Replace view use in otlpmetric exporters

* Replace view use in view example
This commit is contained in:
Tyler Yahn
2022-11-19 09:05:20 -08:00
committed by GitHub
parent b0618095a4
commit 037719b646
33 changed files with 320 additions and 408 deletions

View File

@@ -28,7 +28,6 @@ import (
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
"go.opentelemetry.io/otel/sdk/metric/view"
"go.opentelemetry.io/otel/sdk/resource"
)
@@ -134,18 +133,14 @@ func TestDefaultViewImplicit(t *testing.T) {
}
func testDefaultViewImplicit[N int64 | float64]() func(t *testing.T) {
scope := instrumentation.Scope{Name: "testing/lib"}
inst := instProviderKey{
inst := Instrument{
Name: "requests",
Description: "count of requests received",
Kind: view.SyncCounter,
Kind: InstrumentKindSyncCounter,
Unit: unit.Dimensionless,
}
return func(t *testing.T) {
reader := NewManualReader()
v, err := view.New(view.MatchInstrumentName("foo"), view.WithRename("bar"))
require.NoError(t, err)
tests := []struct {
name string
pipe *pipeline
@@ -156,14 +151,16 @@ func testDefaultViewImplicit[N int64 | float64]() func(t *testing.T) {
},
{
name: "NoMatchingView",
pipe: newPipeline(nil, reader, []view.View{v}),
pipe: newPipeline(nil, reader, []View{
NewView(Instrument{Name: "foo"}, Stream{Name: "bar"}),
}),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
c := newInstrumentCache[N](nil, nil)
i := newInserter(scope, test.pipe, c)
i := newInserter(test.pipe, c)
got, err := i.Instrument(inst)
require.NoError(t, err)
assert.Len(t, got, 1, "default view not applied")