use crate::metrics::Unit;
use crate::sdk::InstrumentationLibrary;
use std::borrow::Cow;
#[derive(Clone, Debug, PartialEq, Hash)]
pub struct InstrumentConfig {
pub(crate) description: Option<String>,
pub(crate) unit: Option<Unit>,
pub(crate) instrumentation_library: InstrumentationLibrary,
}
impl InstrumentConfig {
pub fn with_instrumentation_name(instrumentation_name: &'static str) -> Self {
InstrumentConfig {
description: None,
unit: None,
instrumentation_library: InstrumentationLibrary::new(instrumentation_name, None),
}
}
pub fn with_instrumentation<T: Into<Cow<'static, str>>>(
instrumentation_name: T,
instrumentation_version: Option<T>,
) -> Self {
InstrumentConfig {
description: None,
unit: None,
instrumentation_library: InstrumentationLibrary::new(
instrumentation_name,
instrumentation_version,
),
}
}
pub fn description(&self) -> Option<&String> {
self.description.as_ref()
}
pub fn unit(&self) -> Option<&Unit> {
self.unit.as_ref()
}
pub fn instrumentation_name(&self) -> Cow<'static, str> {
self.instrumentation_library.name.clone()
}
pub fn instrumentation_version(&self) -> Option<Cow<'static, str>> {
self.instrumentation_library.version.clone()
}
}