add min_version and method name to metrics
This commit is contained in:
parent
fb568768c5
commit
0732ab6ad5
3 changed files with 16 additions and 6 deletions
|
@ -1,14 +1,20 @@
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from prometheus_client import Counter, Info, 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 import __version__ as version
|
||||||
from lbry.build_info import BUILD, COMMIT_HASH
|
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"
|
NAMESPACE = "wallet_server"
|
||||||
|
|
||||||
VERSION_INFO = Info('build', 'Wallet server build info (e.g. version, commit hash)', namespace=NAMESPACE)
|
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})
|
VERSION_INFO.info({
|
||||||
REQUESTS_COUNT = Counter("requests_count", "Number of requests received", namespace=NAMESPACE)
|
'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:
|
class PrometheusServer:
|
||||||
|
|
|
@ -28,6 +28,7 @@ from lbry.wallet.server.db import reader
|
||||||
from lbry.wallet.server.websocket import AdminWebSocket
|
from lbry.wallet.server.websocket import AdminWebSocket
|
||||||
from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics
|
from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics
|
||||||
from lbry.wallet.server.prometheus import REQUESTS_COUNT
|
from lbry.wallet.server.prometheus import REQUESTS_COUNT
|
||||||
|
import lbry.wallet.server.version as VERSION
|
||||||
|
|
||||||
from lbry.wallet.rpc import (
|
from lbry.wallet.rpc import (
|
||||||
RPCSession, JSONRPCAutoDetect, JSONRPCConnection,
|
RPCSession, JSONRPCAutoDetect, JSONRPCConnection,
|
||||||
|
@ -708,7 +709,7 @@ class SessionBase(RPCSession):
|
||||||
"""Handle an incoming request. ElectrumX doesn't receive
|
"""Handle an incoming request. ElectrumX doesn't receive
|
||||||
notifications from client sessions.
|
notifications from client sessions.
|
||||||
"""
|
"""
|
||||||
REQUESTS_COUNT.inc()
|
REQUESTS_COUNT.labels(method=request.method).inc()
|
||||||
if isinstance(request, Request):
|
if isinstance(request, Request):
|
||||||
handler = self.request_handlers.get(request.method)
|
handler = self.request_handlers.get(request.method)
|
||||||
else:
|
else:
|
||||||
|
@ -778,8 +779,8 @@ class LBRYSessionManager(SessionManager):
|
||||||
class LBRYElectrumX(SessionBase):
|
class LBRYElectrumX(SessionBase):
|
||||||
"""A TCP server that handles incoming Electrum connections."""
|
"""A TCP server that handles incoming Electrum connections."""
|
||||||
|
|
||||||
PROTOCOL_MIN = (0, 54, 0)
|
PROTOCOL_MIN = VERSION.PROTOCOL_MIN
|
||||||
PROTOCOL_MAX = (0, 99, 0)
|
PROTOCOL_MAX = VERSION.PROTOCOL_MAX
|
||||||
max_errors = math.inf # don't disconnect people for errors! let them happen...
|
max_errors = math.inf # don't disconnect people for errors! let them happen...
|
||||||
session_mgr: LBRYSessionManager
|
session_mgr: LBRYSessionManager
|
||||||
version = lbry.__version__
|
version = lbry.__version__
|
||||||
|
|
3
lbry/wallet/server/version.py
Normal file
3
lbry/wallet/server/version.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# need this to avoid circular import
|
||||||
|
PROTOCOL_MIN = (0, 54, 0)
|
||||||
|
PROTOCOL_MAX = (0, 99, 0)
|
Loading…
Reference in a new issue