pub struct FilterLayer { /* private fields */ }
Expand description

A layer for filtering and discarding metrics matching certain name patterns.

Uses an Aho-Corasick automaton to efficiently match a metric key against multiple patterns at once. Patterns are matched across the entire key i.e. they are matched as substrings.

If a metric key matches any of the configured patterns, it will be skipped entirely. This applies equally to metric registration and metric emission.

A number of options are exposed that control the underlying automaton, such as compilation to a DFA, or case sensitivity.

Implementations

Creates a FilterLayer from an existing set of patterns.

Adds a pattern to match.

Sets the case sensitivity used for pattern matching.

Defaults to false i.e. searches are case sensitive.

Sets whether or not to internally use a deterministic finite automaton.

The main benefit to a DFA is that it can execute searches more quickly than a NFA (perhaps 2-4 times as fast). The main drawback is that the DFA uses more space and can take much longer to build.

Enabling this option does not change the time complexity for constructing the underlying Aho-Corasick automaton (which is O(p) where p is the total number of patterns being compiled). Enabling this option does however reduce the time complexity of non-overlapping searches from O(n + p) to O(n), where n is the length of the haystack.

In general, it’s a good idea to enable this if you’re searching a small number of fairly short patterns (~1000), or if you want the fastest possible search without regard to compilation time or space usage.

Defaults to true.

Trait Implementations

Returns the “default value” for a type. Read more

The output type after wrapping.

Wraps inner based on this layer.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.