In autometrics, the repo_url and service_name are both set from cargo environment variables.
|
.unwrap_or_else(|| env!("CARGO_PKG_REPOSITORY").to_string()); |
|
.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();
In autometrics, the
repo_urlandservice_nameare both set from cargo environment variables.autometrics-rs/autometrics/src/settings.rs
Line 204 in 9bc24e0
autometrics-rs/autometrics/src/settings.rs
Line 215 in 9bc24e0
CARGO_PKG_REPOSITORYandCARGO_PKG_NAMEare set by cargo to the current crate's values, not the top level project. This means that the values forrepo_urlandservice_name, if not specified they will becomehttps://github.com/autometrics-dev/autometrics-rsandautometricsrespectively.This problem does not exist for the labels from
BuildInfoLabelssince those are created in the expansion of the#[autometrics]macro, meaning the expandedenv!()macros are located in the user's crate. A solution could be to expand theseenv!()macros along side the otherBuildInfoLabelsvalues.A work around for now is to manually setup the autometrics settings using code like below: