Skip to content

Commit

Permalink
feat(k8sprocessor): remove default exclusion rules
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Dec 16, 2021
1 parent ced2535 commit d1db6ef
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 49 deletions.
8 changes: 1 addition & 7 deletions pkg/processor/k8sprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@ processors:
# Configure a list of exclusion rules. For now it's possible to specify
# a list of pod name regexes who's records should not be enriched with metadata.
#
# Default:
# pods:
# - name: jaeger-agent
# - name: jaeger-collector
# - name: otel-collector
# - name: otel-agent
# - name: collection-sumologic-otelcol
# By default this list is empty.
pods:
- name: jaeger-agent
- name: my-agent
Expand Down
20 changes: 1 addition & 19 deletions pkg/processor/k8sprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,7 @@ func TestLoadConfig(t *testing.T) {
&Config{
ProcessorSettings: config.NewProcessorSettings(config.NewComponentID(typeStr)),
APIConfig: k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeServiceAccount},
Exclude: ExcludeConfig{
Pods: nil,
// NOTE: this will not work as expected because k8sprocessor uses
// options pattern passing only the "changed as we go" config, so
// setting a default would override the passed around config and then
// the config would get overwritten second time with options.
// Becasuse of that we don't set exclude by default but we rely on
// options to set it, i.e. via WithExcludes (which would also set
// the default values if nothing was set.)
//
// []ExcludePodConfig{
// {Name: "jaeger-agent"},
// {Name: "jaeger-collector"},
// {Name: "otel-collector"},
// {Name: "otel-agent"},
// {Name: "collection-sumologic-otelcol"},
// },
},
Extract: ExtractConfig{Delimiter: ", "},
Extract: ExtractConfig{Delimiter: ", "},
},
p0,
)
Expand Down
14 changes: 0 additions & 14 deletions pkg/processor/k8sprocessor/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,26 +366,12 @@ func WithDelimiter(delimiter string) Option {
}
}

var defaultExcludes = ExcludeConfig{
Pods: []ExcludePodConfig{
{Name: "jaeger-agent"},
{Name: "jaeger-collector"},
{Name: "otel-collector"},
{Name: "otel-agent"},
{Name: "collection-sumologic-otelcol"},
},
}

// WithExcludes allows specifying pods to exclude
func WithExcludes(excludeConfig ExcludeConfig) Option {
return func(p *kubernetesprocessor) error {
excludes := kube.Excludes{}
names := excludeConfig.Pods

if len(names) == 0 {
names = defaultExcludes.Pods
}

for _, name := range names {
excludes.Pods = append(excludes.Pods, kube.ExcludePods{
Name: regexp.MustCompile(name.Name)},
Expand Down
10 changes: 1 addition & 9 deletions pkg/processor/k8sprocessor/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,7 @@ func TestWithExcludes(t *testing.T) {
{
"default",
ExcludeConfig{},
kube.Excludes{
Pods: []kube.ExcludePods{
{Name: regexp.MustCompile(`jaeger-agent`)},
{Name: regexp.MustCompile(`jaeger-collector`)},
{Name: regexp.MustCompile(`otel-collector`)},
{Name: regexp.MustCompile(`otel-agent`)},
{Name: regexp.MustCompile(`collection-sumologic-otelcol`)},
},
},
kube.Excludes{},
},
{
"configured",
Expand Down

0 comments on commit d1db6ef

Please sign in to comment.