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
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package o11ytailsampler
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/otel-collector/processor/o11ytailsampler/internal/metadata"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/component/componenttest"
|
|
"go.opentelemetry.io/collector/confmap/confmaptest"
|
|
"go.opentelemetry.io/collector/consumer/consumertest"
|
|
"go.opentelemetry.io/collector/processor/processortest"
|
|
)
|
|
|
|
func TestCreateDefaultConfig(t *testing.T) {
|
|
cfg := createDefaultConfig()
|
|
assert.NotNil(t, cfg, "failed to create default config")
|
|
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
|
|
}
|
|
|
|
func TestCreateProcessor(t *testing.T) {
|
|
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))
|
|
|
|
params := processortest.NewNopSettings(metadata.Type)
|
|
tp, err := factory.CreateTraces(context.Background(), params, cfg, consumertest.NewNop())
|
|
assert.NotNil(t, tp)
|
|
assert.NoError(t, err, "cannot create trace processor")
|
|
|
|
// this will cause the processor to properly initialize, so that we can later shutdown and
|
|
// have all the go routines cleanly shut down
|
|
assert.NoError(t, tp.Start(context.Background(), componenttest.NewNopHost()))
|
|
assert.NoError(t, tp.Shutdown(context.Background()))
|
|
}
|