Skip to content

Commit 529125c

Browse files
committed
feat(builtin): add label filter
1 parent cb9ba8c commit 529125c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

config_all_options.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ Steps:
155155
HasText: true
156156
# Only process messages that have this tail code.
157157
TailCode: N999AP
158+
# Only process messages that have one of these labels
159+
Labels:
160+
- 87
161+
- 85
162+
- 81
158163
# Only process messages that have this flight number.
159164
FlightNumber: N999AP
160165
# Only process messages that have ASS Status.

filter_builtin.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"reflect"
77
"regexp"
8+
"slices"
89
"strings"
910

1011
"github.com/adrg/strutil"
@@ -57,6 +58,8 @@ type BuiltinFilter struct {
5758
HasText *bool `json:",omitempty" default:"false"`
5859
// Only process messages that have this tail code.
5960
TailCode string `json:",omitempty" default:"N999AP"`
61+
// Only process messages that have one of these labels
62+
Labels []string `json:",omitempty" default:"[87,85,81]"`
6063
// Only process messages that have this flight number.
6164
FlightNumber string `json:",omitempty" default:"N999AP"`
6265
// Only process messages that have ASS Status.
@@ -297,6 +300,15 @@ var (
297300
valueBelow := GetAPMessageCommonFieldAsInt(m, field) < f.LLMProcessedNumberBelow
298301
return !valueBelow, reason, nil
299302
},
303+
"Labels": func(f BuiltinFilter, m APMessage) (filter bool, reason string, err error) {
304+
field := "Label"
305+
label := GetAPMessageCommonFieldAsString(m, field)
306+
var match bool
307+
if slices.Contains(f.Labels, label) {
308+
match = true
309+
}
310+
return !match, reason, nil
311+
},
300312
}
301313
)
302314

0 commit comments

Comments
 (0)