-
Notifications
You must be signed in to change notification settings - Fork 34
Description
In autometrics, the repo_url and service_name are both set from cargo environment variables.
autometrics-rs/autometrics/src/settings.rs
Line 204 in 9bc24e0
| .unwrap_or_else(|| env!("CARGO_PKG_REPOSITORY").to_string()); |
autometrics-rs/autometrics/src/settings.rs
Line 215 in 9bc24e0
| .unwrap_or_else(|| env!("CARGO_PKG_NAME").to_string()), |
CARGO_PKG_REPOSITORY and CARGO_PKG_NAME are set by cargo to the current crate's values, not the top level project. This means that the values for repo_url and service_name, if not specified they will become https://github.com/autometrics-dev/autometrics-rs and autometrics respectively.
This problem does not exist for the labels from BuildInfoLabels since those are created in the expansion of the #[autometrics] macro, meaning the expanded env!() macros are located in the user's crate. A solution could be to expand these env!() macros along side the other BuildInfoLabels values.
A work around for now is to manually setup the autometrics settings using code like below:
autometrics::settings::AutometricsSettings::builder()
.repo_url(env!("CARGO_PKG_REPOSITORY"))
.service_name(env!("CARGO_PKG_NAME"))
.init();