From fcc67096b563b4ddfa5761f409a169a9b5f6cbf3 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 12 Jul 2023 15:01:14 -0700 Subject: [PATCH] Add test for multi-inst view error (#4308) --- sdk/metric/view_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sdk/metric/view_test.go b/sdk/metric/view_test.go index 03ae5e7e7..439e7819c 100644 --- a/sdk/metric/view_test.go +++ b/sdk/metric/view_test.go @@ -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" @@ -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".