autometrics-dev / autometrics-rs

Easily add metrics to your code that actually help you spot and debug issues in production. Built on Prometheus and OpenTelemetry.
https://autometrics.dev
Apache License 2.0
797 stars 25 forks source link

Runtime configurable custom build_info details #175

Open nstinus opened 4 months ago

nstinus commented 4 months ago

Hello,

In a few projects I routinely already get access to the git describe that contains the version, sha and dirtiness of the repo. This is typically passed to clap to display a useful --version. Seems like autometrics pulls its info out of compile-time environment variables. It would be very helpful if it could be set during init instead. You could allow arbitrary keys at that stage so that many more information can be included. Not just branch and sha.

What do you think?

gagbo commented 4 months ago

Hello,

I think we could provide a few more knobs to the init or the SettingsBuilder structure to handle more customization. But there’s just one thing I didn’t understand: you say that you use git describe to create a --version command.

Are you shelling out to git describe when you call --version on your binary? That seems pretty dangerous, as it’s easy to have the compiled binary diverge from the state of the repository. And if you’re just shelling out to git describe in the build.rs phase of your script, then we should be able to access the version info at compile time anyway. So there must be something I did not understand.

With that being said, I think that the rust version of Autometrics doesn’t support yet setting the monitored code version in the metrics (I might be mistaken, I mostly worked on the Go version and I will need some time to delve again into this)

nstinus commented 3 months ago

No, I an using the git-version crate.