Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add instrumentation version for instrument config. #392

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions opentelemetry/src/api/metrics/config.rs
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()
}
}