Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8sprocessor): add ignored pod names as config parameter #354

Merged
merged 5 commits into from
Dec 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(k8sprocessor): remove default exclusion rules
pmalek committed Dec 16, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit dd2b2d709633bc9fc6a2b271982f871161522269
8 changes: 1 addition & 7 deletions pkg/processor/k8sprocessor/README.md
Original file line number Diff line number Diff line change
@@ -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
20 changes: 1 addition & 19 deletions pkg/processor/k8sprocessor/config_test.go
Original file line number Diff line number Diff line change
@@ -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,
)
14 changes: 0 additions & 14 deletions pkg/processor/k8sprocessor/options.go
Original file line number Diff line number Diff line change
@@ -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)},
10 changes: 1 addition & 9 deletions pkg/processor/k8sprocessor/options_test.go
Original file line number Diff line number Diff line change
@@ -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",