diff --git a/lbry/wallet/server/prometheus.py b/lbry/wallet/server/prometheus.py index 8872b2ae7..59bb3964c 100644 --- a/lbry/wallet/server/prometheus.py +++ b/lbry/wallet/server/prometheus.py @@ -1,14 +1,20 @@ from aiohttp import web 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_info import BUILD, COMMIT_HASH +from lbry.wallet.server import util +import lbry.wallet.server.version as wallet_server_version NAMESPACE = "wallet_server" VERSION_INFO = Info('build', '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) +VERSION_INFO.info({ + 'build': BUILD, + "commit": COMMIT_HASH, + 'version': version, + "min_version": util.version_string(wallet_server_version.PROTOCOL_MIN), +}) +REQUESTS_COUNT = Counter("requests_count", "Number of requests received", namespace=NAMESPACE, labelnames=("method",)) class PrometheusServer: diff --git a/lbry/wallet/server/session.py b/lbry/wallet/server/session.py index f373da2f1..826ed38cc 100644 --- a/lbry/wallet/server/session.py +++ b/lbry/wallet/server/session.py @@ -28,6 +28,7 @@ from lbry.wallet.server.db import reader from lbry.wallet.server.websocket import AdminWebSocket from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics from lbry.wallet.server.prometheus import REQUESTS_COUNT +import lbry.wallet.server.version as VERSION from lbry.wallet.rpc import ( RPCSession, JSONRPCAutoDetect, JSONRPCConnection, @@ -708,7 +709,7 @@ class SessionBase(RPCSession): """Handle an incoming request. ElectrumX doesn't receive notifications from client sessions. """ - REQUESTS_COUNT.inc() + REQUESTS_COUNT.labels(method=request.method).inc() if isinstance(request, Request): handler = self.request_handlers.get(request.method) else: @@ -778,8 +779,8 @@ class LBRYSessionManager(SessionManager): class LBRYElectrumX(SessionBase): """A TCP server that handles incoming Electrum connections.""" - PROTOCOL_MIN = (0, 54, 0) - PROTOCOL_MAX = (0, 99, 0) + PROTOCOL_MIN = VERSION.PROTOCOL_MIN + PROTOCOL_MAX = VERSION.PROTOCOL_MAX max_errors = math.inf # don't disconnect people for errors! let them happen... session_mgr: LBRYSessionManager version = lbry.__version__ diff --git a/lbry/wallet/server/version.py b/lbry/wallet/server/version.py new file mode 100644 index 000000000..7d640996d --- /dev/null +++ b/lbry/wallet/server/version.py @@ -0,0 +1,3 @@ +# need this to avoid circular import +PROTOCOL_MIN = (0, 54, 0) +PROTOCOL_MAX = (0, 99, 0)