From d9f809864fd2e0bec124bc06106b29327bc08814 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 22 Jan 2020 19:13:58 -0500 Subject: [PATCH] include version and build info in prometheus output --- docker/set_build.py | 2 +- lbry/build_type.py | 2 +- lbry/wallet/server/prometheus.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docker/set_build.py b/docker/set_build.py index 7cb3294db..9bbe9bc72 100644 --- a/docker/set_build.py +++ b/docker/set_build.py @@ -32,7 +32,7 @@ def main(): build_type = get_build_type(os.getenv('CI_COMMIT_TAG', os.getenv('TRAVIS_TAG'))) log.debug("setting build type=%s, build commit=%s", build_type, commit_hash) with open(build_type_path, 'w') as f: - f.write(f"BUILD = \"{build_type}\"\nBUILD_COMMIT = \"{commit_hash}\"\n") + f.write(f"BUILD = \"{build_type}\"\nCOMMIT_HASH = \"{commit_hash}\"\n") if __name__ == '__main__': diff --git a/lbry/build_type.py b/lbry/build_type.py index 07a818289..d85b9593b 100644 --- a/lbry/build_type.py +++ b/lbry/build_type.py @@ -1,3 +1,3 @@ # don't touch this. CI server changes this during build/deployment BUILD = "dev" -BUILD_COMMIT = "source installation" +COMMIT_HASH = "none" diff --git a/lbry/wallet/server/prometheus.py b/lbry/wallet/server/prometheus.py index 651350f12..84a7a3529 100644 --- a/lbry/wallet/server/prometheus.py +++ b/lbry/wallet/server/prometheus.py @@ -1,9 +1,13 @@ from aiohttp import web -from prometheus_client import Counter, generate_latest as prom_generate_latest +from prometheus_client import Counter, Info, generate_latest as prom_generate_latest from lbry.wallet.server import util +from lbry import __version__ as version +from lbry.build_type import BUILD, COMMIT_HASH NAMESPACE = "wallet_server" +VERSION_INFO = Info('build_info', 'Wallet server build info (e.g. version, commit hash)', namespace=NAMESPACE) +VERSION_INFO.info({'version': version, 'build': BUILD, "commit": COMMIT_HASH}) REQUESTS_COUNT = Counter("requests_count", "Number of requests received", namespace=NAMESPACE)