From 3eda2f7964f52a5b85e3724863bf84ff10fd9110 Mon Sep 17 00:00:00 2001 From: Przemek Maciolek <58699843+pmm-sumo@users.noreply.github.com> Date: Thu, 21 Apr 2022 19:31:33 +0200 Subject: [PATCH] [processors/resourcedetection] Wire docker in processor factory (#9372) Co-authored-by: Alex Boten --- CHANGELOG.md | 3 +-- .../resourcedetectionprocessor/factory.go | 2 ++ .../factory_test.go | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e597387ae9..dd9aaa3482cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ - `pkg/translator/prometheusremotewrite`: Allow to disable sanitize metric labels (#8270) - `basicauthextension`: Implement `configauth.ClientAuthenticator` so that the extension can also be used as HTTP client basic authenticator.(#8847) - `cumulativetodeltaprocessor`: add new include/exclude configuration options with regex support (#8952) - - `cmd/mdatagen`: Update generated functions to have simple parse function to handle string parsing consistently and limit code duplication across receivers (#7574) - `attributesprocessor`: Support filter by severity (#9132) @@ -31,7 +30,7 @@ - `fluentforwardreceiver`: Release port on shutdown (#9111) - `prometheusexporter`: Prometheus fails to generate logs when prometheus exporter produced a check exception occurs. (#8949) - +- `resourcedetectionprocessor`: Wire docker detector (#9372) ## v0.49.0 diff --git a/processor/resourcedetectionprocessor/factory.go b/processor/resourcedetectionprocessor/factory.go index 448d260744c8..dc3f76176638 100644 --- a/processor/resourcedetectionprocessor/factory.go +++ b/processor/resourcedetectionprocessor/factory.go @@ -34,6 +34,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/azure" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/azure/aks" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/consul" + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/docker" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/env" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/gcp/gce" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/gcp/gke" @@ -62,6 +63,7 @@ func NewFactory() component.ProcessorFactory { aks.TypeStr: aks.NewDetector, azure.TypeStr: azure.NewDetector, consul.TypeStr: consul.NewDetector, + docker.TypeStr: docker.NewDetector, ec2.TypeStr: ec2.NewDetector, ecs.TypeStr: ecs.NewDetector, eks.TypeStr: eks.NewDetector, diff --git a/processor/resourcedetectionprocessor/factory_test.go b/processor/resourcedetectionprocessor/factory_test.go index b59260c59eb5..a978d516ea00 100644 --- a/processor/resourcedetectionprocessor/factory_test.go +++ b/processor/resourcedetectionprocessor/factory_test.go @@ -16,12 +16,14 @@ package resourcedetectionprocessor import ( "context" + "path/filepath" "testing" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/configtest" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/service/servicetest" ) func TestCreateDefaultConfig(t *testing.T) { @@ -47,6 +49,25 @@ func TestCreateProcessor(t *testing.T) { assert.NotNil(t, lp) } +func TestCreateConfigProcessors(t *testing.T) { + factory := NewFactory() + factories, _ := componenttest.NopFactories() + factories.Processors[typeStr] = factory + + cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories) + assert.NoError(t, err) + assert.NotNil(t, cfg) + + for k, v := range cfg.Processors { + // Check if all processor variations that are defined in test config can be actually created + t.Run(k.Name(), func(t *testing.T) { + tt, err := factory.CreateTracesProcessor(context.Background(), componenttest.NewNopProcessorCreateSettings(), v, consumertest.NewNop()) + assert.NoError(t, err) + assert.NotNil(t, tt) + }) + } +} + func TestInvalidConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig()