Skip to content

Commit

Permalink
Add test for multi-inst view error (#4308)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Jul 12, 2023
1 parent 35636fc commit fcc6709
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sdk/metric/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/go-logr/logr"
"github.com/go-logr/logr/funcr"
"github.com/go-logr/logr/testr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -466,6 +467,20 @@ func TestNewViewAggregationErrorLogged(t *testing.T) {
assert.Equal(t, 1, l.ErrorN())
}

func TestNewViewMultiInstMatchErrorLogged(t *testing.T) {
var got string
otel.SetLogger(funcr.New(func(_, args string) {
got = args
}, funcr.Options{Verbosity: 6}))

_ = NewView(Instrument{
Name: "*", // Wildcard match name (multiple instruments).
}, Stream{
Name: "non-empty",
})
assert.Contains(t, got, errMultiInst.Error())
}

func ExampleNewView() {
// Create a view that renames the "latency" instrument from the v0.34.0
// version of the "http" instrumentation library as "request.latency".
Expand Down

0 comments on commit fcc6709

Please sign in to comment.