forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtracing_test.go
50 lines (43 loc) · 1.31 KB
/
tracing_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package pluginconfig
import (
"testing"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewTracingCfg(t *testing.T) {
t.Run("empty", func(t *testing.T) {
cfg := setting.NewCfg()
tracingCfg, err := newTracingCfg(cfg)
require.NoError(t, err)
assert.False(t, tracingCfg.IsEnabled(), "tracing should be disabled")
assert.Empty(t, tracingCfg.OpenTelemetry.Address)
assert.Empty(t, tracingCfg.OpenTelemetry.Propagation)
})
t.Run("enabled", func(t *testing.T) {
for _, tc := range []struct {
name string
propagation string
}{
{"empty", ""},
{"jaeger", "jaeger"},
{"w3c", "w3c"},
{"multiple", "jaeger,w3c"},
} {
t.Run(tc.name, func(t *testing.T) {
const address = "127.0.0.1:4317"
cfg := setting.NewCfg()
otlpSect := cfg.Raw.Section("tracing.opentelemetry.otlp")
otlpSect.Key("address").SetValue(address)
if tc.propagation != "" {
otlpSect.Key("propagation").SetValue(tc.propagation)
}
tracingCfg, err := newTracingCfg(cfg)
require.NoError(t, err)
assert.True(t, tracingCfg.IsEnabled(), "tracing should be enabled")
assert.Equal(t, address, tracingCfg.OpenTelemetry.Address)
assert.Equal(t, tc.propagation, tracingCfg.OpenTelemetry.Propagation)
})
}
})
}