Introduce inferred-context for filterprocessor#39688
Introduce inferred-context for filterprocessor#39688jaronoff97 wants to merge 12 commits intoopen-telemetry:mainfrom
Conversation
|
Looks OK to my untrained eye, asking for codeowner review. |
There was a problem hiding this comment.
Thanks for working on it, @jaronoff97, it's great to have standardized settings across processors :)
These are early comments; I'm still going through the PR.
processor/filterprocessor/config.go
Outdated
| // Validate checks if the processor configuration is valid | ||
| func (cfg *Config) Validate() error { | ||
| // TODO: The old format should be deprecated and removed. | ||
| if cfg.TraceConditions != nil && (cfg.Traces.SpanConditions != nil || cfg.Traces.SpanEventConditions != nil) { |
There was a problem hiding this comment.
Can we please add some tests for those mixed-style conditions?
| flp.telemetry = fpt | ||
|
|
||
| if len(cfg.LogConditions) > 0 { | ||
| pc, collectionErr := common.NewLogParserCollection(set.TelemetrySettings, common.WithLogParser(filterottl.StandardLogFuncs())) |
There was a problem hiding this comment.
We're missing passing the default error_mode options (common.With*ErrorMode) for the parser collections (other signals too). In addition to that, can we please also port the existing error mode unit tests from the transform processor?
There was a problem hiding this comment.
do you want me to port these tests for the config or these tests for the processors, or both?
There was a problem hiding this comment.
I meant the second set of tests that are specific for error mode.
| return Scope | ||
| } | ||
|
|
||
| func (s scopeConditions) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { |
There was a problem hiding this comment.
It seems we've no coverage for the scope context (all signals). Can we please add some tests for that?
processor/filterprocessor/config.go
Outdated
| if cfg.TraceConditions != nil && (cfg.Traces.SpanConditions != nil || cfg.Traces.SpanEventConditions != nil) { | ||
| return errors.New("cannot use inferred context trace conditions and old format at the same time") | ||
| } | ||
| if cfg.MetricConditions != nil && (cfg.Metrics.MetricConditions != nil || cfg.Metrics.DataPointConditions != nil) { |
There was a problem hiding this comment.
I'm trying to wrap my head around on how this processor config should work, but based on the existing settings and validations (docs is missing), it should use either the include and exclude settings, OR the OTTL conditions, but not both.
That said, I think we're missing a validation here, so it does not allow the include and exclude keys when <sinal>_conditions are configured.
| if errors != nil { | ||
| return nil, errors | ||
| } | ||
| } |
There was a problem hiding this comment.
We should early return here as skipExpr won't be evaluated when the signal condition is set.
| ) | ||
|
|
||
| type filterLogProcessor struct { | ||
| consumers []common.LogsConsumer |
There was a problem hiding this comment.
It would be great if we could add some tests for all signals processors using their context inferrer settings (like we do for the transformprocessor (example), so we can ensure that filtering all possible inferred contexts works.
There was a problem hiding this comment.
I'm still think we need to add tests for the high level processor code (all signals). I might be wrong, but I don't think the current implementation is working as expected with the new context inferred style.
At the moment, we're skipping processing the data for all signals when the skipExpr is nil, leading configurations with only context inferred conditions to be no-op.
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
@edmocosta i still want to work at this, ive been very busy the past week 😢 |
|
still going through rn to add tests! |
|
@edmocosta i think this should be ready for another review. One thing i'd like your take on – I think we could probably condense the individual |
| switch { | ||
| case tt.filterEverything && !tt.wantErr: | ||
| assert.Equal(t, processorhelper.ErrSkipProcessingData, consumeErr) | ||
| case tt.wantErr: |
There was a problem hiding this comment.
Do we need this condition and the above && !tt.wantErr? It seems we're early returning it when tt.wantErr == true at line 96. If we want to assert both operations ParseContextConditions and ConsumeLogs errors, we probably should be more specific on the expected error string.
| errorMode ottl.ErrorMode | ||
| conditions []common.ContextConditions | ||
| want func(td plog.Logs) | ||
| wantErr bool |
There was a problem hiding this comment.
It seems we're not using this wantErr field on the tests scenarios. if so, we could just drop it and keep only the wantErrorWith.
| // Apply each consumer sequentially | ||
| for _, consumer := range consumers { | ||
| if err := consumer.ConsumeLogs(context.Background(), finalLogs); err != nil { | ||
| if errors.Is(err, processorhelper.ErrSkipProcessingData) { |
There was a problem hiding this comment.
I didn't fully understand this block, shouldn't it be something like the following if the idea is to ignore ErrSkipProcessingData errors? am I missing something?
if err := consumer.ConsumeLogs(context.Background(), finalLogs); err != nil {
if !errors.Is(err, processorhelper.ErrSkipProcessingData) {
consumeErr = err
break
}
}If that's the case, we can also drop the if condition at line 236 and assert.NoError(t, consumeErr) it directly.
| ) | ||
|
|
||
| type filterLogProcessor struct { | ||
| consumers []common.LogsConsumer |
There was a problem hiding this comment.
I'm still think we need to add tests for the high level processor code (all signals). I might be wrong, but I don't think the current implementation is working as expected with the new context inferred style.
At the moment, we're skipping processing the data for all signals when the skipExpr is nil, leading configurations with only context inferred conditions to be no-op.
That's interesting, but I'm not completely sure if that would work, we need to run some tests to double check that. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
This commit continues the work from PR open-telemetry#39688 by @jaronoff97 - Carried over the original implementation - Fixed error_mode ignore test cases - Fixed issues with resource filtering Co-authored-by: jaronoff97 <jacobaronoff45@gmail.com>
Description
This PR adds the ability to do context inference for conditions for the filter processor. New config fields are introduced for the supported telemetry types and an isolated code path is introduced for ease of review and separation of concerns
Link to tracking issue
Fixes #37904
Testing
Unit, ran locally
Documentation
TODO