pub struct MetricId {
pub namespace: String,
pub name: String,
pub labels: Vec<(String, String)>,
}
Expand description
A unique, structured identifier for a metric.
A MetricId
is composed of a namespace, a name, and a set of key-value labels,
allowing for powerful filtering and querying of telemetry data.
Fields§
§namespace: String
The broad category of the metric (e.g., “renderer”, “memory”).
name: String
The specific name of the metric (e.g., “frame_time_ms”, “triangles_rendered”).
labels: Vec<(String, String)>
Optional, sorted key-value pairs for dimensional filtering.
Implementations§
Source§impl MetricId
impl MetricId
Sourcepub fn new(namespace: impl Into<String>, name: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>, name: impl Into<String>) -> Self
Creates a new MetricId
with a namespace and a name.
Sourcepub fn with_label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a dimensional label to the metric ID, returning a new MetricId
.
Labels are kept sorted by key for consistent hashing and display.
Sourcepub fn to_string_formatted(&self) -> String
pub fn to_string_formatted(&self) -> String
Returns a formatted string representation of the ID (e.g., “namespace:name[k=v,…]”).
Trait Implementations§
impl Eq for MetricId
impl StructuralPartialEq for MetricId
Auto Trait Implementations§
impl Freeze for MetricId
impl RefUnwindSafe for MetricId
impl Send for MetricId
impl Sync for MetricId
impl Unpin for MetricId
impl UnwindSafe for MetricId
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
Mutably borrows from an owned value. Read more