Skip to content

Commit

Permalink
add autometrics.version to build_info
Browse files Browse the repository at this point in the history
  • Loading branch information
mellowagain committed Nov 13, 2023
1 parent b887363 commit 2962a4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions autometrics/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ pub const REPO_URL_KEY: &str = "repository.url";
pub const REPO_URL_KEY_PROMETHEUS: &str = "repository_url";
pub const REPO_PROVIDER_KEY: &str = "repository.provider";
pub const REPO_PROVIDER_KEY_PROMETHEUS: &str = "repository_provider";
pub const AUTOMETRICS_VERSION_KEY: &str = "autometrics.version";
pub const AUTOMETRICS_VERSION_KEY_PROMETHEUS: &str = "autometrics_version";
7 changes: 5 additions & 2 deletions autometrics/src/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct BuildInfoLabels {
pub(crate) service_name: &'static str,
pub(crate) repo_url: &'static str,
pub(crate) repo_provider: &'static str,
pub(crate) autometrics_version: &'static str,
}

impl BuildInfoLabels {
Expand All @@ -31,7 +32,8 @@ impl BuildInfoLabels {
branch,
service_name: &get_settings().service_name,
repo_url,
repo_provider
repo_provider,
autometrics_version: "1.0.0"
}
}

Expand All @@ -42,7 +44,8 @@ impl BuildInfoLabels {
(BRANCH_KEY, self.branch),
(SERVICE_NAME_KEY, self.service_name),
(REPO_URL_KEY, self.repo_url),
(REPO_PROVIDER_KEY, self.repo_provider)
(REPO_PROVIDER_KEY, self.repo_provider),
(AUTOMETRICS_VERSION_KEY, self.autometrics_version)
]
}

Expand Down
4 changes: 3 additions & 1 deletion autometrics/src/tracker/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static BUILD_INFO: Lazy<IntGaugeVec> = Lazy::new(|| {
SERVICE_NAME_KEY_PROMETHEUS,
REPO_URL_KEY_PROMETHEUS,
REPO_PROVIDER_KEY_PROMETHEUS,
AUTOMETRICS_VERSION_KEY_PROMETHEUS,
],
get_settings().prometheus_registry.clone()
)
Expand Down Expand Up @@ -146,7 +147,8 @@ impl TrackMetrics for PrometheusTracker {
build_info_labels.branch,
build_info_labels.service_name,
build_info_labels.repo_url,
build_info_labels.repo_provider
build_info_labels.repo_provider,
"1.0.0" // autometrics_version
])
.set(1);
});
Expand Down

0 comments on commit 2962a4d

Please sign in to comment.