Skip to content

Commit 47b54ee

Browse files
authored
feat: add instrumentation version for instrument config. (#392)
1 parent 4390213 commit 47b54ee

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

opentelemetry/src/api/metrics/config.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct InstrumentConfig {
66
pub(crate) description: Option<String>,
77
pub(crate) unit: Option<Unit>,
88
pub(crate) instrumentation_name: String,
9+
pub(crate) instrumentation_version: Option<String>,
910
}
1011

1112
impl InstrumentConfig {
@@ -15,6 +16,20 @@ impl InstrumentConfig {
1516
description: None,
1617
unit: None,
1718
instrumentation_name,
19+
instrumentation_version: None,
20+
}
21+
}
22+
23+
/// Create a new config with instrumentation name and version
24+
pub fn with_instrumentation(
25+
instrumentation_name: String,
26+
instrumentation_version: String,
27+
) -> Self {
28+
InstrumentConfig {
29+
description: None,
30+
unit: None,
31+
instrumentation_name,
32+
instrumentation_version: Some(instrumentation_version),
1833
}
1934
}
2035

@@ -32,4 +47,9 @@ impl InstrumentConfig {
3247
pub fn instrumentation_name(&self) -> &String {
3348
&self.instrumentation_name
3449
}
50+
51+
/// Instrumentation version returns the version of instrumentation
52+
pub fn instrumentation_version(&self) -> Option<&String> {
53+
self.instrumentation_version.as_ref()
54+
}
3555
}

0 commit comments

Comments
 (0)