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

allow the metric names to be changed with compile-time env vars #6

Merged
merged 3 commits into from
Dec 19, 2022

Conversation

dylanwh
Copy link
Contributor

@dylanwh dylanwh commented Dec 18, 2022

To match local conventions I needed to adjust the metric names and I'm not able to modify the scrape config. Thus, I made this patch which allows these AXUM_HTTP_* constants to be changed via envs.

It is common for applications metrics to have an application-specific prefix. Metrics can be renamed at scrape time of course, but in some environments an application is expected to merely expose metrics on a given port and no other configuration is allowed.

This commit allows the metric names to be changed at compile time by setting the following environment variables:

  • AXUM_HTTP_REQUESTS_TOTAL
  • AXUM_HTTP_REQUESTS_DURATION_SECONDS
  • AXUM_HTTP_REQUESTS_PENDING

In the absence of these environment variables, the metric names are unchanged.

This commit also documents the usage of these envs and suggests setting them in .cargo/config.toml

It is common for applications metrics to have an application-specific prefix.  Metrics
can be renamed at scrape time of course, but in some environments an application is
expected to merely expose metrics on a given port and no other configuration is allowed.

This commit allows the metric names to be changed at compile time by setting the
following environment variables:
- `AXUM_HTTP_REQUESTS_TOTAL`
- `AXUM_HTTP_REQUESTS_DURATION_SECONDS`
- `AXUM_HTTP_REQUESTS_PENDING`

In the absence of these environment variables, the metric names are unchanged.

This commit also documents the usage of these envs and suggests setting them in
.cargo/config.toml
@Ptrskay3
Copy link
Owner

Thanks @dylanwh!
Do you want to add this to the changelog as well?

@dylanwh
Copy link
Contributor Author

dylanwh commented Dec 19, 2022

Thanks @dylanwh! Do you want to add this to the changelog as well?

Done in 104bbf6

@dylanwh
Copy link
Contributor Author

dylanwh commented Dec 19, 2022

I also updated the docs for the constants, so that someone reading the docs will know they can change them.

@Ptrskay3
Copy link
Owner

Great! I'm planning to release 0.3 this weekend along with other changes - you can use the master branch until then.

@Ptrskay3 Ptrskay3 merged commit b2e2c77 into Ptrskay3:master Dec 19, 2022
@Ptrskay3
Copy link
Owner

Ptrskay3 commented Jan 4, 2023

Just released 0.3, and includes this change.

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

Successfully merging this pull request may close these issues.

2 participants