Skip to content

Commit

Permalink
feat: add instrumentation version for instrument config. (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp authored Dec 18, 2020
1 parent 4390213 commit 47b54ee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions opentelemetry/src/api/metrics/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub struct InstrumentConfig {
pub(crate) description: Option<String>,
pub(crate) unit: Option<Unit>,
pub(crate) instrumentation_name: String,
pub(crate) instrumentation_version: Option<String>,
}

impl InstrumentConfig {
Expand All @@ -15,6 +16,20 @@ impl InstrumentConfig {
description: None,
unit: None,
instrumentation_name,
instrumentation_version: None,
}
}

/// Create a new config with instrumentation name and version
pub fn with_instrumentation(
instrumentation_name: String,
instrumentation_version: String,
) -> Self {
InstrumentConfig {
description: None,
unit: None,
instrumentation_name,
instrumentation_version: Some(instrumentation_version),
}
}

Expand All @@ -32,4 +47,9 @@ impl InstrumentConfig {
pub fn instrumentation_name(&self) -> &String {
&self.instrumentation_name
}

/// Instrumentation version returns the version of instrumentation
pub fn instrumentation_version(&self) -> Option<&String> {
self.instrumentation_version.as_ref()
}
}

0 comments on commit 47b54ee

Please sign in to comment.