From f0f8e91e5c353d315063e7fa3ae1631757404258 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 16 Nov 2021 01:32:24 -0800 Subject: [PATCH] Syntax cleanup Signed-off-by: John --- processor/filterprocessor/README.md | 2 +- processor/filterprocessor/config.go | 2 +- processor/filterprocessor/factory.go | 2 +- .../filterprocessor/filter_processor_traces.go | 13 +++++-------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/processor/filterprocessor/README.md b/processor/filterprocessor/README.md index 7ec6add59374..130726be204b 100644 --- a/processor/filterprocessor/README.md +++ b/processor/filterprocessor/README.md @@ -220,5 +220,5 @@ processors: - hello/world attributes: - Key: container.name - Value: (app_container_1|app_container_1) + Value: (app_container_1|app_container_2) ``` diff --git a/processor/filterprocessor/config.go b/processor/filterprocessor/config.go index 969e53386f21..70a08bb8d495 100644 --- a/processor/filterprocessor/config.go +++ b/processor/filterprocessor/config.go @@ -50,7 +50,7 @@ type MetricFilters struct { RegexpConfig *regexp.Config `mapstructure:"regexp"` } -// MetricFilters filters by Metric properties. +// SpanFilters filters by Span attributes and various other fields type SpanFilters struct { // Include match properties describe metrics that should be included in the Collector Service pipeline, // all other metrics should be dropped from further processing. diff --git a/processor/filterprocessor/factory.go b/processor/filterprocessor/factory.go index fbaaf89ab7f2..9bd74749c6df 100644 --- a/processor/filterprocessor/factory.go +++ b/processor/filterprocessor/factory.go @@ -87,7 +87,7 @@ func createTracesProcessor( cfg config.Processor, nextConsumer consumer.Traces, ) (component.TracesProcessor, error) { - fp, err := newFilterTracesProcessor(set.Logger, cfg.(*Config)) + fp, err := newFilterSpansProcessor(set.Logger, cfg.(*Config)) if err != nil { return nil, err } diff --git a/processor/filterprocessor/filter_processor_traces.go b/processor/filterprocessor/filter_processor_traces.go index a2de3474fdbf..c257b2dcb7c0 100644 --- a/processor/filterprocessor/filter_processor_traces.go +++ b/processor/filterprocessor/filter_processor_traces.go @@ -31,7 +31,7 @@ type filterSpanProcessor struct { logger *zap.Logger } -func newFilterTracesProcessor(logger *zap.Logger, cfg *Config) (*filterSpanProcessor, error) { +func newFilterSpansProcessor(logger *zap.Logger, cfg *Config) (*filterSpanProcessor, error) { inc, err := createSpanMatcher(cfg.Spans.Include) if err != nil { return nil, err @@ -48,9 +48,10 @@ func newFilterTracesProcessor(logger *zap.Logger, cfg *Config) (*filterSpanProce } excludeMatchType := "" - if cfg.Metrics.Exclude != nil { + if cfg.Spans.Exclude != nil { excludeMatchType = string(cfg.Spans.Exclude.MatchType) } + logger.Info( "Span filter configured", zap.String("include match_type", includeMatchType), @@ -66,18 +67,14 @@ func newFilterTracesProcessor(logger *zap.Logger, cfg *Config) (*filterSpanProce } func createSpanMatcher(sp *filterconfig.MatchProperties) (filterspan.Matcher, error) { - var matcher filterspan.Matcher - var err error if sp == nil { - panic("No Match Properties for Filter") + return nil, nil } - matcher, err = filterspan.NewMatcher(sp) - return matcher, err + return filterspan.NewMatcher(sp) } // processTraces filters the given spans of a traces based off the filterSpanProcessor's filters. func (fsp *filterSpanProcessor) processTraces(_ context.Context, pdt pdata.Traces) (pdata.Traces, error) { - for i := 0; i < pdt.ResourceSpans().Len(); i++ { resSpan := pdt.ResourceSpans().At(i) for x := 0; x < resSpan.InstrumentationLibrarySpans().Len(); x++ {