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

[autometrics 1.0 compliance] add autometrics.version to build_info #154

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions autometrics/src/constants.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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";
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: AUTOMETRICS_SPEC_TARGET
}
}

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,
AUTOMETRICS_SPEC_TARGET
])
.set(1);
});
Expand Down