Skip to content

Commit

Permalink
[internal/filter] Add bridge from filterlog to filterottl (#22789)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TylerHelmuth committed Jun 21, 2023
1 parent 3ed369c commit f6763a0
Show file tree
Hide file tree
Showing 4 changed files with 1,345 additions and 39 deletions.
14 changes: 14 additions & 0 deletions internal/filter/filterlog/filterlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@ import (
"context"
"fmt"

"go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/expr"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterconfig"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filtermatcher"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottllog"
)

var useOTTLBridge = featuregate.GlobalRegistry().MustRegister(
"filter.filterlog.useOTTLBridge",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("When enabled, filterlog will convert filterlog configuration to OTTL and use filterottl evaluation"),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18642"),
)

// NewSkipExpr creates a BoolExpr that on evaluation returns true if a log should NOT be processed or kept.
// The logic determining if a log should be processed is based on include and exclude settings.
// Include properties are checked before exclude settings are checked.
func NewSkipExpr(mp *filterconfig.MatchConfig) (expr.BoolExpr[ottllog.TransformContext], error) {

if useOTTLBridge.IsEnabled() {
return filterottl.NewLogSkipExprBridge(mp)
}
var matchers []expr.BoolExpr[ottllog.TransformContext]
inclExpr, err := newExpr(mp.Include)
if err != nil {
Expand Down
Loading

0 comments on commit f6763a0

Please sign in to comment.