Skip to content

Commit

Permalink
[processor/filter] use generated header (open-telemetry#21030)
Browse files Browse the repository at this point in the history
use generated header
  • Loading branch information
TylerHelmuth committed Apr 17, 2023
1 parent a8e707a commit 7170933
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 28 deletions.
27 changes: 18 additions & 9 deletions processor/filterprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Filter Processor

| Status | |
| ------------------------ | --------------------- |
| Stability | [alpha] |
| Supported pipeline types | metrics, logs, traces |
| Distributions | [core], [contrib] |
<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [alpha] |
| Supported pipeline types | traces, metrics, logs |
| Distributions | [core], [contrib] |
| Warnings | [Orphaned Telemetry, Other](#warnings) |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

The filter processor can be configured to include or exclude:

Expand Down Expand Up @@ -385,6 +391,9 @@ processors:
- 'severity_number < SEVERITY_NUMBER_WARN'
```

[alpha]:https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[core]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
## Warnings

In general, understand your data before using the filter processor.

- When using the filterprocessor make sure you understand the look of your incoming data and test the configuration thoroughly. In general, use as specific a configuration as possible to lower the risk of the wrong data being dropped.
- [Orphaned Telemetry](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/standard-warnings.md#orphaned-telemetry): The processor allows dropping spans. Dropping a span may lead to orphaned spans if the dropped span is a parent. Dropping a span may lead to orphaned logs if the log references the dropped span.
17 changes: 9 additions & 8 deletions processor/filterprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset"
fsregexp "github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset/regexp"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor/internal/metadata"
)

// TestLoadingConfigRegexp tests loading testdata/config_strict.yaml
Expand Down Expand Up @@ -892,35 +893,35 @@ func TestLoadingConfigOTTL(t *testing.T) {
},
},
{
id: component.NewIDWithName(typeStr, "spans_mix_config"),
id: component.NewIDWithName(metadata.Type, "spans_mix_config"),
errorMessage: "cannot use ottl conditions and include/exclude for spans at the same time",
},
{
id: component.NewIDWithName(typeStr, "metrics_mix_config"),
id: component.NewIDWithName(metadata.Type, "metrics_mix_config"),
errorMessage: "cannot use ottl conditions and include/exclude for metrics at the same time",
},
{
id: component.NewIDWithName(typeStr, "logs_mix_config"),
id: component.NewIDWithName(metadata.Type, "logs_mix_config"),
errorMessage: "cannot use ottl conditions and include/exclude for logs at the same time",
},
{
id: component.NewIDWithName(typeStr, "bad_syntax_span"),
id: component.NewIDWithName(metadata.Type, "bad_syntax_span"),
errorMessage: "unable to parse OTTL statement: 1:25: unexpected token \"test\" (expected <string> \"]\")",
},
{
id: component.NewIDWithName(typeStr, "bad_syntax_spanevent"),
id: component.NewIDWithName(metadata.Type, "bad_syntax_spanevent"),
errorMessage: "unable to parse OTTL statement: 1:25: unexpected token \"test\" (expected <string> \"]\")",
},
{
id: component.NewIDWithName(typeStr, "bad_syntax_metric"),
id: component.NewIDWithName(metadata.Type, "bad_syntax_metric"),
errorMessage: "unable to parse OTTL statement: 1:34: unexpected token \"test\" (expected <string> \"]\")",
},
{
id: component.NewIDWithName(typeStr, "bad_syntax_datapoint"),
id: component.NewIDWithName(metadata.Type, "bad_syntax_datapoint"),
errorMessage: "unable to parse OTTL statement: 1:25: unexpected token \"test\" (expected <string> \"]\")",
},
{
id: component.NewIDWithName(typeStr, "bad_syntax_log"),
id: component.NewIDWithName(metadata.Type, "bad_syntax_log"),
errorMessage: "unable to parse OTTL statement: 1:25: unexpected token \"test\" (expected <string> \"]\")",
},
}
Expand Down
2 changes: 2 additions & 0 deletions processor/filterprocessor/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

// Package filterprocessor implements a processor for filtering
// (dropping) metrics and/or spans by various properties.
package filterprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor"
16 changes: 5 additions & 11 deletions processor/filterprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,19 @@ import (
"go.opentelemetry.io/collector/processor/processorhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
)

const (
// The value of "type" key in configuration.
typeStr = "filter"
// The stability level of the processor.
stability = component.StabilityLevelAlpha
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor/internal/metadata"
)

var processorCapabilities = consumer.Capabilities{MutatesData: true}

// NewFactory returns a new factory for the Filter processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
processor.WithMetrics(createMetricsProcessor, stability),
processor.WithLogs(createLogsProcessor, stability),
processor.WithTraces(createTracesProcessor, stability),
processor.WithMetrics(createMetricsProcessor, metadata.Stability),
processor.WithLogs(createLogsProcessor, metadata.Stability),
processor.WithTraces(createTracesProcessor, metadata.Stability),
)
}

Expand Down
12 changes: 12 additions & 0 deletions processor/filterprocessor/internal/metadata/generated_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions processor/filterprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: filter

status:
class: processor
stability: alpha
pipelines: [traces, metrics, logs]
distributions: [core,contrib]
warnings: [Orphaned Telemetry, Other]

0 comments on commit 7170933

Please sign in to comment.