Skip to content

Commit f6763a0

Browse files
authored
[internal/filter] Add bridge from filterlog to filterottl (#22789)
This PR adds a bridge between `filterlog.NewSkipExpr` and `filterottl.NewBoolExprForLog` behind a feature gate. With the feature gate enabled, any component using `filterlog.NewSkipExpr` will start using OTTL behind the scenes. Related to #18643 Related to #18642 Added tests comparing the output of the existing config and the bridge.
1 parent 3ed369c commit f6763a0

File tree

4 files changed

+1345
-39
lines changed

4 files changed

+1345
-39
lines changed

internal/filter/filterlog/filterlog.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,31 @@ import (
77
"context"
88
"fmt"
99

10+
"go.opentelemetry.io/collector/featuregate"
11+
1012
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/expr"
1113
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterconfig"
1214
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filtermatcher"
15+
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterottl"
1316
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset"
1417
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottllog"
1518
)
1619

20+
var useOTTLBridge = featuregate.GlobalRegistry().MustRegister(
21+
"filter.filterlog.useOTTLBridge",
22+
featuregate.StageAlpha,
23+
featuregate.WithRegisterDescription("When enabled, filterlog will convert filterlog configuration to OTTL and use filterottl evaluation"),
24+
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18642"),
25+
)
26+
1727
// NewSkipExpr creates a BoolExpr that on evaluation returns true if a log should NOT be processed or kept.
1828
// The logic determining if a log should be processed is based on include and exclude settings.
1929
// Include properties are checked before exclude settings are checked.
2030
func NewSkipExpr(mp *filterconfig.MatchConfig) (expr.BoolExpr[ottllog.TransformContext], error) {
31+
32+
if useOTTLBridge.IsEnabled() {
33+
return filterottl.NewLogSkipExprBridge(mp)
34+
}
2135
var matchers []expr.BoolExpr[ottllog.TransformContext]
2236
inclExpr, err := newExpr(mp.Include)
2337
if err != nil {

0 commit comments

Comments
 (0)