-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
73 lines (61 loc) · 2.03 KB
/
config_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package servicegraphprocessor
import (
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/connector"
"go.opentelemetry.io/collector/otelcol/otelcoltest"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor/internal/metadata"
)
func TestLoadConfig(t *testing.T) {
// Prepare
factories, err := otelcoltest.NopFactories()
require.NoError(t, err)
factories.Processors[metadata.Type] = NewFactory()
factories.Connectors[metadata.Type] = newConnectorFactory()
// Test
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-config.yaml"), factories)
// Verify
require.NoError(t, err)
require.NotNil(t, cfg)
assert.Equal(t,
&Config{
MetricsExporter: "metrics",
LatencyHistogramBuckets: []time.Duration{1, 2, 3, 4, 5},
Dimensions: []string{"dimension-1", "dimension-2"},
Store: StoreConfig{
TTL: time.Second,
MaxItems: 10,
},
CacheLoop: 2 * time.Minute,
StoreExpirationLoop: 10 * time.Second,
VirtualNodePeerAttributes: []string{"db.name", "rpc.service"},
},
cfg.Processors[component.NewID(metadata.Type)],
)
cfg, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-connector-config.yaml"), factories)
// Verify
require.NoError(t, err)
require.NotNil(t, cfg)
assert.Equal(t,
&Config{
LatencyHistogramBuckets: []time.Duration{1, 2, 3, 4, 5},
Dimensions: []string{"dimension-1", "dimension-2"},
Store: StoreConfig{
TTL: time.Second,
MaxItems: 10,
},
CacheLoop: time.Minute,
StoreExpirationLoop: 2 * time.Second,
},
cfg.Connectors[component.NewID(metadata.Type)],
)
}
func newConnectorFactory() connector.Factory {
return NewConnectorFactoryFunc("servicegraph", component.StabilityLevelAlpha)()
}