Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz committed May 16, 2021
1 parent 2875e9e commit fe5fa9a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions metrics-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ atomic-shim = { version = "0.1", optional = true }
aho-corasick = { version = "0.7", optional = true }
dashmap = { version = "4", optional = true }
indexmap = { version = "1.6", optional = true }
nibble_vec = { version = "0.1", optional = true }
parking_lot = { version = "0.11", optional = true }
quanta = { version = "0.7", optional = true }
sketches-ddsketch = { version = "0.1", optional = true }
Expand Down Expand Up @@ -87,4 +86,4 @@ default = ["std", "layer-filter", "layer-absolute", "layer-router"]
std = ["atomic-shim", "crossbeam-epoch", "crossbeam-utils", "dashmap", "indexmap", "parking_lot", "quanta", "sketches-ddsketch"]
layer-filter = ["aho-corasick"]
layer-absolute = ["aho-corasick", "parking_lot"]
layer-router = ["radix_trie", "nibble_vec"]
layer-router = ["radix_trie"]
3 changes: 2 additions & 1 deletion metrics-util/src/layers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ pub use fanout::{Fanout, FanoutBuilder};
mod absolute;
#[cfg(feature = "layer-absolute")]
pub use absolute::{Absolute, AbsoluteLayer};

#[cfg(feature = "layer-router")]
mod router;
#[cfg(feature = "layer-router")]
pub use router::{Router, RouterBuilder};

/// Decorates an object by wrapping it within another type.
Expand Down
9 changes: 2 additions & 7 deletions metrics-util/src/layers/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,15 @@ impl Router {
search_routes: &Trie<String, usize>,
) -> &dyn Recorder {
// The global mask is essentially a Bloom filter of overridden route types. If it doesn't
// match our metric, we know for a fact there's no route. Use the default recorder.
// match our metric, we know for a fact there's no route and must use the default recorder.
if !self.global_mask.matches(kind) {
self.default.as_ref()
} else {
// TODO: it'd be neat to search incrementally, like part #1 of key nameparts, then part
// #2, etc... but there's no way to do that with the exposed API. we'd need to be able
// to feed a it a slice of u8 slices or something.

// SAFETY: We derive the `idx` value that is inserted into our route maps by using the
// length of `targets` itself before adding a new target. Ergo, the index is provably
// populated if the `idx` has been stored.
let needle = key.name().to_string();
search_routes
.get_ancestor(needle.as_str())
.get_ancestor(key.name())
.map(|st| unsafe { self.targets.get_unchecked(*st.value().unwrap()).as_ref() })
.unwrap_or(self.default.as_ref())
}
Expand Down

0 comments on commit fe5fa9a

Please sign in to comment.