Skip to content

Commit

Permalink
[processors/resourcedetection] Wire docker in processor factory (#9372)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Boten <[email protected]>
  • Loading branch information
pmm-sumo and Alex Boten authored Apr 21, 2022
1 parent ad0e612 commit 3eda2f7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions processor/resourcedetectionprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions processor/resourcedetectionprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
Expand Down

0 comments on commit 3eda2f7

Please sign in to comment.