1
1
use crate :: layers:: Layer ;
2
- use aho_corasick:: { AhoCorasick , AhoCorasickBuilder } ;
2
+ use aho_corasick:: { AhoCorasick , AhoCorasickBuilder , AhoCorasickKind } ;
3
3
use metrics:: { Counter , Gauge , Histogram , Key , KeyName , Recorder , SharedString , Unit } ;
4
4
5
5
/// Filters and discards metrics matching certain name patterns.
@@ -123,7 +123,7 @@ impl FilterLayer {
123
123
/// searches from O(n + p) to O(n), where n is the length of the haystack.
124
124
///
125
125
/// In general, it's a good idea to enable this if you're searching a small number of fairly
126
- /// short patterns (~1000) , or if you want the fastest possible search without regard to
126
+ /// short patterns, or if you want the fastest possible search without regard to
127
127
/// compilation time or space usage.
128
128
///
129
129
/// Defaults to `true`.
@@ -140,9 +140,13 @@ impl<R> Layer<R> for FilterLayer {
140
140
let mut automaton_builder = AhoCorasickBuilder :: new ( ) ;
141
141
let automaton = automaton_builder
142
142
. ascii_case_insensitive ( self . case_insensitive )
143
- . dfa ( self . use_dfa )
144
- . auto_configure ( & self . patterns )
145
- . build ( & self . patterns ) ;
143
+ . kind ( self . use_dfa . then ( || AhoCorasickKind :: DFA ) )
144
+ . build ( & self . patterns )
145
+ // Documentation for `AhoCorasickBuilder::build` states that the error here will be
146
+ // related to exceeding some internal limits, but that those limits should generally be
147
+ // large enough for most use cases.. so I'm making the executive decision to consider
148
+ // that "good enough" and treat this as an exceptional error if it does occur.
149
+ . expect ( "should not fail to build filter automaton" ) ;
146
150
Filter { inner, automaton }
147
151
}
148
152
}
0 commit comments