diff --git a/CHANGELOG.md b/CHANGELOG.md index 28595eb..3358228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,9 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 The [Autometrics specification v1.0.0](https://github.com/autometrics-dev/autometrics-shared/blob/main/specs/autometrics_v1.0.0.md) has been released. The following changes are made in order to bring the release in compliance with the spec: -- Added `repository_url` and `repository_provider` as `build_info` labels. They can be +- Added `repository.url` and `repository.provider` as `build_info` labels. They can be configured either through environment variables or automatically based on your `Cargo.toml` `package.repository` value (only GitHub, GitLab and BitBucket) (#152) +- Added `autometrics.version` as `build_info` label, specifying the autometrics spec + version that we are targeting. It is currently hardcoded to `1.0.0` (#154) ## [0.6.0](https://github.com/autometrics-dev/autometrics-rs/releases/tag/v0.5.0) - 2023-08-08 diff --git a/autometrics/src/constants.rs b/autometrics/src/constants.rs index 26f49b2..ba24d6d 100644 --- a/autometrics/src/constants.rs +++ b/autometrics/src/constants.rs @@ -1,3 +1,6 @@ +// Version of the autometrics spec we are targeting +pub const AUTOMETRICS_SPEC_TARGET: &str = "1.0.0"; + // Metrics pub const COUNTER_NAME: &str = "function.calls"; pub const HISTOGRAM_NAME: &str = "function.calls.duration"; @@ -41,3 +44,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"; diff --git a/autometrics/src/labels.rs b/autometrics/src/labels.rs index f242a9c..89d8925 100644 --- a/autometrics/src/labels.rs +++ b/autometrics/src/labels.rs @@ -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 { @@ -31,7 +32,8 @@ impl BuildInfoLabels { branch, service_name: &get_settings().service_name, repo_url, - repo_provider + repo_provider, + autometrics_version: AUTOMETRICS_SPEC_TARGET } } @@ -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) ] } diff --git a/autometrics/src/tracker/prometheus.rs b/autometrics/src/tracker/prometheus.rs index 87d9218..30b9bf2 100644 --- a/autometrics/src/tracker/prometheus.rs +++ b/autometrics/src/tracker/prometheus.rs @@ -76,6 +76,7 @@ static BUILD_INFO: Lazy = Lazy::new(|| { SERVICE_NAME_KEY_PROMETHEUS, REPO_URL_KEY_PROMETHEUS, REPO_PROVIDER_KEY_PROMETHEUS, + AUTOMETRICS_VERSION_KEY_PROMETHEUS, ], get_settings().prometheus_registry.clone() ) @@ -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, + AUTOMETRICS_SPEC_TARGET ]) .set(1); });