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

Issue with default repo_url and service_name values #178

Open
DusterTheFirst opened this issue Jul 4, 2024 · 0 comments
Open

Issue with default repo_url and service_name values #178

DusterTheFirst opened this issue Jul 4, 2024 · 0 comments

Comments

@DusterTheFirst
Copy link

DusterTheFirst commented Jul 4, 2024

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant