Python
Adding version information

Adding version information to metrics in Python

Autometrics makes it easy to spot versions and commits that introduce errors or latency.

It produces a build_info metric and uses labels to expose various metadata related to your app to Prometheus.

build_info{branch="main",commit="4cfd2f3b26224fa82daf4ba68fe36e188f3153ff",version="1.0.0",service_name="api",repo_url="https://github.com/autometrics-dev/autometrics-rs",repo_provider="github",autometrics_version="1.0.0"} 1

Labels are exposed and can be set as environment variables at compile or run time:

LabelEnvironment VariablesDefaultDescription
versionAUTOMETRICS_VERSION ""The version of your app
commitAUTOMETRICS_COMMIT ""The Git SHA-1 commit hash of your app
branchAUTOMETRICS_BRANCH ""The Git branch of your app
autometrics.versionNone1.0.0The version of the Autometrics spec your app is targeting. You cannot modify this value, it is hardcoded.
service.nameAUTOMETRICS_SERVICE_NAME, OTEL_SERVICE_NAME ""Name of the service
repository.urlAUTOMETRICS_REPOSITORY_URL ""Repository url where the source code of your app is available
repository.providerAUTOMETRICS_REPOSITORY_PROVIDER ""Repository provider for `repository.url`, e.g `github` or `gitlab`
⚠️

As of writing, build_info will not work correctly when using the default tracker (AUTOMETRICS_TRACKER=OPEN_TELEMETRY). This will be fixed once the following PR is merged on the opentelemetry-python project: open-telemetry/opentelemetry-python#3306 (opens in a new tab)

autometrics-py will track support for build_info via #38