pub trait LabelValue {
// Required method
fn label_value(&self) -> Value;
}Expand description
Value types that can be used as metric labels.
Implemented out of the box for strings, integers, bool, and char.
Implement this trait for custom enums to use them as labels:
enum Plan { Free, Paid }
impl LabelValue for Plan {
fn label_value(&self) -> Value {
match self {
Plan::Free => "free",
Plan::Paid => "paid",
}
.into()
}
}Required Methods§
Sourcefn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts this value into an OpenTelemetry attribute Value (string,
integer, or bool).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl LabelValue for Cow<'_, str>
impl LabelValue for Cow<'_, str>
fn label_value(&self) -> Value
Source§impl LabelValue for String
impl LabelValue for String
fn label_value(&self) -> Value
Source§impl LabelValue for bool
impl LabelValue for bool
fn label_value(&self) -> Value
Source§impl LabelValue for char
impl LabelValue for char
fn label_value(&self) -> Value
Source§impl LabelValue for i8
impl LabelValue for i8
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for i16
impl LabelValue for i16
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for i32
impl LabelValue for i32
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for i64
impl LabelValue for i64
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for isize
impl LabelValue for isize
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for str
impl LabelValue for str
fn label_value(&self) -> Value
Source§impl LabelValue for u8
impl LabelValue for u8
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for u16
impl LabelValue for u16
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for u32
impl LabelValue for u32
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for u64
impl LabelValue for u64
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.
Source§impl LabelValue for usize
impl LabelValue for usize
Source§fn label_value(&self) -> Value
fn label_value(&self) -> Value
Converts to an i64 attribute value, clamping values above i64::MAX.