When we get bug reports about zebrad, it would be helpful to have exact version and platform information.
We could use vergen's:
git describe)See https://docs.rs/vergen/3.2.0/vergen/index.html
We'd also want to set:
vergen::ConstantsFlags::REBUILD_ON_HEAD_CHANGE, so that every build gets the latest commit hashWhen building in Google Cloud, we can use:
Ideally, we should have the git version (SHORT_SHA or VERGEN_SHA_SHORT) appear in:
We'd also like:
git_commitgit describe, contains the git tag name and number of following commitsgit_commit: contains the package version from Cargo.toml, if git is not available at build time, plus the git commit from vergen or google cloudTo appear in:
zebra-network user-agent stringWe'd also like:
git_commitTo appear in:
zebrad version commandzebrad version in the help message (when you run zebrad without any arguments) - optionalpanic_sectionadd_issue_metadataI had a look at vergen's other build time info, and I don't think we want it:
FROM_CARGO_PACKAGE is redundant with ZebraCmd::version()I don't think we'll want the other Google Cloud variables either.
https://github.com/ZcashFoundation/zebra/pull/1410#issuecomment-737533655
Knowing the exact commit SHA seems like it would be helpful for debugging builds from git, but would we still want it for tagged releases, where the semver string's git tag is enough to canonically identify the exact version? Working with semver strings seems a lot more user-friendly than working with commit hashes.
If this information is going to be in a lot of our log lines I'd want to try to keep it as minimal as possible. Ideally just the SHA, and not the commit date, because that can easily be determined via the sha. Also, I want to make sure we label it in the output so its clear that the sha is a git commit sha.
I've worked with a codebase that logged a ton of extra context that was occasionally relevant like pid and thread ids, and various identifiers for pieces of the system where none of the numbers were labeled and you just had to know that the 1st one was PID and the 3rd one was an RSDID (or did I get that backwards?) and it is hell to keep everything straight, along with the fact that it significantly increased the verbosity of our logs.
I think the standard format is something like:
For example:
git-abcdef
git-abcdef-extra (with uncommitted changes)
I've seen users make all sorts of changes, and then build in release mode. Fixing those bugs was terribly confusing, because we didn't know what code we were actually working with.
Sounds good, how do you feel about replacing the git sha with a tag if we're on a tagged release? I'm not sure if vergen can handle that but if so that might be a nice QoL feature.
Sounds good, how do you feel about replacing the git sha with a tag if we're on a tagged release? I'm not sure if vergen can handle that but if so that might be a nice QoL feature.
Tags can be moved around (_can_ be, we _shouldn't_ move them around, but it can happen) so I would make the short 7 char commit sha always be included, and the semver of zebrad (which _should_ match a tag on the commit when released).
I think we should close this for now to stay focused and revisit it if we ever get a confusing bug report.
Reopening this issue because:
zebrad help message, so I could add the exact commit to my Zebra bug reportsI've simplified the issue, and added the target triple, because it would actually be useful in bug reports from users.