Skip to content

Commit a4b2fc1

Browse files
committed
Update aho-corasick to 1.0.
1 parent c15c0ed commit a4b2fc1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

metrics-util/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Added a new helper type, `RecoverableRecorder`, that allows installing a recorder and then
1515
recovering it later.
1616

17+
### Changed
18+
19+
- Update `aho-corasick` to `1.0`.
20+
1721
## [0.15.0] - 2023-04-16
1822

1923
### Changed

metrics-util/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ required-features = ["handles"]
5050
metrics = { version = "^0.21", path = "../metrics" }
5151
crossbeam-epoch = { version = "0.9.2", default-features = false, optional = true, features = ["alloc", "std"] }
5252
crossbeam-utils = { version = "0.8", default-features = false, optional = true }
53-
aho-corasick = { version = "0.7", default-features = false, optional = true, features = ["std"] }
53+
aho-corasick = { version = "1", default-features = false, optional = true, features = ["std"] }
5454
indexmap = { version = "1", default-features = false, optional = true }
5555
quanta = { version = "0.11", default-features = false, optional = true }
5656
sketches-ddsketch = { version = "0.2", default-features = false, optional = true }

metrics-util/src/layers/filter.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::layers::Layer;
2-
use aho_corasick::{AhoCorasick, AhoCorasickBuilder};
2+
use aho_corasick::{AhoCorasick, AhoCorasickBuilder, AhoCorasickKind};
33
use metrics::{Counter, Gauge, Histogram, Key, KeyName, Recorder, SharedString, Unit};
44

55
/// Filters and discards metrics matching certain name patterns.
@@ -123,7 +123,7 @@ impl FilterLayer {
123123
/// searches from O(n + p) to O(n), where n is the length of the haystack.
124124
///
125125
/// 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
127127
/// compilation time or space usage.
128128
///
129129
/// Defaults to `true`.
@@ -140,9 +140,13 @@ impl<R> Layer<R> for FilterLayer {
140140
let mut automaton_builder = AhoCorasickBuilder::new();
141141
let automaton = automaton_builder
142142
.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");
146150
Filter { inner, automaton }
147151
}
148152
}

0 commit comments

Comments
 (0)