mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-10-30 18:26:25 +00:00
- Go module: github.com/SigNoz/signoz-otel-collector → github.com/hanzoai/otel-collector - All signoz-prefixed packages → o11y-prefixed - Docker: signoz/* → ghcr.io/hanzoai/otel-collector - ClickHouse exporter → Hanzo Datastore - Env vars: SIGNOZ_* → HANZO_* - Directory renames for all processor/receiver/exporter packages
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package o11ytailsampler
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/confmap/confmaptest"
|
|
|
|
"github.com/hanzoai/otel-collector/processor/o11ytailsampler/internal/metadata"
|
|
)
|
|
|
|
func TestLoadConfig(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "tail_sampling_config.yaml"))
|
|
require.NoError(t, err)
|
|
|
|
factory := NewFactory()
|
|
cfg := factory.CreateDefaultConfig()
|
|
|
|
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
|
|
require.NoError(t, err)
|
|
require.NoError(t, sub.Unmarshal(cfg))
|
|
|
|
assert.Equal(t,
|
|
cfg,
|
|
&Config{
|
|
// ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
|
DecisionWait: 10 * time.Second,
|
|
NumTraces: 100,
|
|
ExpectedNewTracesPerSec: 10,
|
|
PolicyCfgs: []PolicyGroupCfg{
|
|
{
|
|
BasePolicy: BasePolicy{
|
|
Name: "test-policy-1",
|
|
Type: PolicyGroup,
|
|
Priority: 1,
|
|
ProbabilisticCfg: ProbabilisticCfg{
|
|
SamplingPercentage: 100,
|
|
},
|
|
PolicyFilterCfg: PolicyFilterCfg{
|
|
StringAttributeCfgs: []StringAttributeCfg{
|
|
{Key: "source", Values: []string{"security"}},
|
|
},
|
|
},
|
|
},
|
|
SubPolicies: []BasePolicy{
|
|
{
|
|
Name: "condition-1",
|
|
Type: PolicyGroup,
|
|
Priority: 1,
|
|
PolicyFilterCfg: PolicyFilterCfg{
|
|
StringAttributeCfgs: []StringAttributeCfg{
|
|
{Key: "source", Values: []string{"security"}},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|