1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Add test for multi-inst view error (#4308)

This commit is contained in:
Tyler Yahn
2023-07-12 15:01:14 -07:00
committed by GitHub
parent 35636fc1ab
commit fcc67096b5
+15
View File
@@ -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".