pub struct RemapperRule { /* private fields */ }Expand description
A metric remapping rule.
Rules define the basic matching behavior (metric name, and optionally tags) as well as how to remap the new copy of the metric. This can include copying tags as-is from the source metric, copying specific tags over with a new name, and adding an additional fixed set of tags to the new metric.
Implementations§
Source§impl RemapperRule
impl RemapperRule
Sourcepub fn by_name(existing_name: &'static str, new_name: &'static str) -> Self
pub fn by_name(existing_name: &'static str, new_name: &'static str) -> Self
Creates a new RemapperRule that matches a source metric by name only.
Creates a new RemapperRule that matches a source metric by name and tags.
Sourcepub fn with_required_tag_keys<I>(self, required_tag_keys: I) -> Selfwhere
I: IntoIterator<Item = &'static str>,
pub fn with_required_tag_keys<I>(self, required_tag_keys: I) -> Selfwhere
I: IntoIterator<Item = &'static str>,
Adds a set of tag names that must be present on the source metric, with any value, for this rule to match.
This is useful when the same metric name is emitted both with and without a given tag (for example, an aggregate series alongside per-dimension series), and only the tagged series should be remapped.
This method is additive, so it can be called multiple times to add more required tag keys.
Adds a set of tags that make this rule reject a source metric that carries any of them.
Tags are matched exactly, in the same key:value (or bare) form as the tags given to
by_name_and_tags. This is useful when a metric is emitted by components for
different purposes and only some of them should be remapped.
Unlike with_all_original_tags_except, which controls which tags are
copied onto the remapped metric, this decides whether the metric is remapped at all.
A metric this rule rejects is still offered to the rules that follow it, so excluding a metric from a set of rules requires rejecting it on every rule that could match it.
This method is additive, so it can be called multiple times to add more rejected tags.
Adds a set of tags to remap from the source metric by changing their name.
Remapped tags must be given in the form of (source_tag, destination_tag). If a tag by the name source_tag is
found in the source metric, it’s copied to the remapped metric with a name of destination_tag.
This method is additive, so it can be called multiple times to add more remapped tags. Tag remapping is order-dependent, so if a tag is configured to be remapped, or copied, multiple times, then the first match will take precedence.
Adds a set of tags to remap from the source metric without changing their name.
Remapped tags must be given in the form of source_tag. If a tag by the name source_tag is found in the
source metric, it’s copied to the remapped metric with the same name.
This method is additive, so it can be called multiple times to add more original tags. Tag remapping is order-dependent, so if a tag is configured to be copied, or remapped, multiple times, then the first match will take precedence.
Adds a fixed set of tags to add to the remapped metric.
Additional tags are given in the form of tag, which can be any valid tag value: bare or key/value.
This method is additive, so it can be called multiple times to add more additional tags.
Copies all source tags except tags whose names are in excluded_tags.
This is useful when a metric carries a dynamic set of labels alongside component-specific tags.
Explicit copies and renames configured with with_original_tags or with_remapped_tags take precedence:
their source names are not copied again, even if also listed in excluded_tags. Exclusions apply only
to this catch-all copy, not to explicit mappings. Output order is explicit mappings in rule order,
remaining source tags in source order, then with_additional_tags.
To keep output tag names unique, source tags that share a name with a renamed or additional tag are not copied, and only the first value of a repeated source tag name is copied.
Calling this method again replaces the previous exclusion list.
Sourcepub fn with_continued_matching(self) -> Self
pub fn with_continued_matching(self) -> Self
Allows later rules to also match the same source metric.
Sourcepub fn with_summed_gauges(self) -> Self
pub fn with_summed_gauges(self) -> Self
Sums gauges that remap to the same name and tags, instead of keeping the latest one.
Remapping can drop the tags that told two source series apart, such as a component ID, so that they share one remapped identity. For a gauge that’s a total across them, such as a queue size, this reports their sum rather than whichever one was seen last.
Sourcepub fn with_help_text(self, help_text: &'static str) -> Self
pub fn with_help_text(self, help_text: &'static str) -> Self
Sets the Prometheus # HELP text that should be emitted alongside the remapped metric.
Some downstream collectors (notably the Datadog Agent’s OpenMetrics check) require a specific help text on overlapped metric names. Setting this here keeps the help text next to the rule that produces the name.
Sourcepub const fn should_continue_matching(&self) -> bool
pub const fn should_continue_matching(&self) -> bool
Returns true if matching should continue after this rule matches.
Sourcepub const fn sums_gauges(&self) -> bool
pub const fn sums_gauges(&self) -> bool
Returns true if gauges that remap to the same name and tags are summed.
Sourcepub const fn remapped_name(&self) -> &'static str
pub const fn remapped_name(&self) -> &'static str
Returns the remapped metric name produced by this rule.
Sourcepub const fn help_text(&self) -> Option<&'static str>
pub const fn help_text(&self) -> Option<&'static str>
Returns the help text associated with this rule, if any.
Sourcepub fn try_match_no_context(&self, context: &Context) -> Option<RemappedMetric>
pub fn try_match_no_context(&self, context: &Context) -> Option<RemappedMetric>
Attempts to match the given context against this rule.
If the rule matches, returns a RemappedMetric containing the new metric name and tags.
Trait Implementations§
Source§impl Clone for RemapperRule
impl Clone for RemapperRule
Source§fn clone(&self) -> RemapperRule
fn clone(&self) -> RemapperRule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RemapperRule
impl RefUnwindSafe for RemapperRule
impl Send for RemapperRule
impl Sync for RemapperRule
impl Unpin for RemapperRule
impl UnsafeUnpin for RemapperRule
impl UnwindSafe for RemapperRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more