pub enum MetricId {
Builtin(BuiltinMetric),
Dynamic(Cow<'static, str>),
}Expand description
A metric identifier accepted by every metric accessor via impl Into<MetricId>:
a typed BuiltinMetric (the common, discoverable, typo-proof case) or a
dynamic scheduler-runtime / payload string (the open keyspace). One call shape
for both — phase_metric(BuiltinMetric::X) and phase_metric("runtime_key").
Variants§
Builtin(BuiltinMetric)
A compile-time-known built-in metric (carries its registry kind via
BuiltinMetric::def).
Dynamic(Cow<'static, str>)
A scheduler-runtime / payload-supplied key not in the built-in registry.
Implementations§
Source§impl MetricId
impl MetricId
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
The wire-name key — into super::METRICS and the ext-metrics maps. For
a Builtin this is the inner BuiltinMetric::wire_name; for a Dynamic
it is the raw key string.
Sourcepub fn def(&self) -> Option<&'static MetricDef>
pub fn def(&self) -> Option<&'static MetricDef>
The registry definition if this id names a REGISTERED metric — Some for
every Builtin; None for a genuine scheduler-runtime key. Via the From
impls a registered name canonicalizes to Builtin, so a Dynamic reached
through the public impl Into<MetricId> path never holds a registered name
and resolves to None here; the Dynamic registry lookup is a defensive
fallback for a directly-constructed MetricId::Dynamic. The GUARDRAIL: a
None here means no declared kind, so the caller must not aggregate the
value as a guessed kind (resolve-by-name or fold conservatively).
Trait Implementations§
Source§impl From<&BuiltinMetric> for MetricId
impl From<&BuiltinMetric> for MetricId
Source§fn from(b: &BuiltinMetric) -> Self
fn from(b: &BuiltinMetric) -> Self
Borrowed-BuiltinMetric convenience — sweeping BuiltinMetric::ALL
yields &BuiltinMetric; it is Copy, so this is a trivial copy-then-wrap.
Source§impl From<BuiltinMetric> for MetricId
impl From<BuiltinMetric> for MetricId
Source§fn from(b: BuiltinMetric) -> Self
fn from(b: BuiltinMetric) -> Self
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more