add version to session count metric
This commit is contained in:
parent
28eee4da25
commit
bf4cbe1204
2 changed files with 10 additions and 6 deletions
|
@ -7,7 +7,7 @@ from lbry.wallet.server import util
|
||||||
import lbry.wallet.server.version as wallet_server_version
|
import lbry.wallet.server.version as wallet_server_version
|
||||||
|
|
||||||
NAMESPACE = "wallet_server"
|
NAMESPACE = "wallet_server"
|
||||||
|
CPU_COUNT = f"{os.cpu_count()}"
|
||||||
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_INFO.info({
|
||||||
'build': BUILD,
|
'build': BUILD,
|
||||||
|
@ -15,9 +15,10 @@ VERSION_INFO.info({
|
||||||
"docker_tag": DOCKER_TAG,
|
"docker_tag": DOCKER_TAG,
|
||||||
'version': version,
|
'version': version,
|
||||||
"min_version": util.version_string(wallet_server_version.PROTOCOL_MIN),
|
"min_version": util.version_string(wallet_server_version.PROTOCOL_MIN),
|
||||||
"cpu_count": os.cpu_count()
|
"cpu_count": CPU_COUNT
|
||||||
})
|
})
|
||||||
SESSIONS_COUNT = Gauge("session_count", "Number of connected client sessions", namespace=NAMESPACE)
|
SESSIONS_COUNT = Gauge("session_count", "Number of connected client sessions", namespace=NAMESPACE,
|
||||||
|
labelnames=("version", ))
|
||||||
REQUESTS_COUNT = Counter("requests_count", "Number of requests received", namespace=NAMESPACE,
|
REQUESTS_COUNT = Counter("requests_count", "Number of requests received", namespace=NAMESPACE,
|
||||||
labelnames=("method", "version"))
|
labelnames=("method", "version"))
|
||||||
RESPONSE_TIMES = Histogram("response_time", "Response times", namespace=NAMESPACE, labelnames=("method", "version"))
|
RESPONSE_TIMES = Histogram("response_time", "Response times", namespace=NAMESPACE, labelnames=("method", "version"))
|
||||||
|
|
|
@ -673,7 +673,7 @@ class SessionBase(RPCSession):
|
||||||
context = {'conn_id': f'{self.session_id}'}
|
context = {'conn_id': f'{self.session_id}'}
|
||||||
self.logger = util.ConnectionLogger(self.logger, context)
|
self.logger = util.ConnectionLogger(self.logger, context)
|
||||||
self.group = self.session_mgr.add_session(self)
|
self.group = self.session_mgr.add_session(self)
|
||||||
SESSIONS_COUNT.inc()
|
SESSIONS_COUNT.labels(version=self.client_version).inc()
|
||||||
peer_addr_str = self.peer_address_str()
|
peer_addr_str = self.peer_address_str()
|
||||||
self.logger.info(f'{self.kind} {peer_addr_str}, '
|
self.logger.info(f'{self.kind} {peer_addr_str}, '
|
||||||
f'{self.session_mgr.session_count():,d} total')
|
f'{self.session_mgr.session_count():,d} total')
|
||||||
|
@ -682,7 +682,7 @@ class SessionBase(RPCSession):
|
||||||
"""Handle client disconnection."""
|
"""Handle client disconnection."""
|
||||||
super().connection_lost(exc)
|
super().connection_lost(exc)
|
||||||
self.session_mgr.remove_session(self)
|
self.session_mgr.remove_session(self)
|
||||||
SESSIONS_COUNT.dec()
|
SESSIONS_COUNT.labels(version=self.client_version).dec()
|
||||||
msg = ''
|
msg = ''
|
||||||
if not self._can_send.is_set():
|
if not self._can_send.is_set():
|
||||||
msg += ' whilst paused'
|
msg += ' whilst paused'
|
||||||
|
@ -1428,7 +1428,10 @@ class LBRYElectrumX(SessionBase):
|
||||||
self.close_after_send = True
|
self.close_after_send = True
|
||||||
raise RPCError(BAD_REQUEST,
|
raise RPCError(BAD_REQUEST,
|
||||||
f'unsupported client: {client_name}')
|
f'unsupported client: {client_name}')
|
||||||
self.client_version = client_name[:17]
|
if self.client_version != client_name[:17]:
|
||||||
|
SESSIONS_COUNT.labels(version=self.client_version).dec()
|
||||||
|
self.client_version = client_name[:17]
|
||||||
|
SESSIONS_COUNT.labels(version=self.client_version).inc()
|
||||||
CLIENT_VERSIONS.labels(version=self.client_version).inc()
|
CLIENT_VERSIONS.labels(version=self.client_version).inc()
|
||||||
|
|
||||||
# Find the highest common protocol version. Disconnect if
|
# Find the highest common protocol version. Disconnect if
|
||||||
|
|
Loading…
Add table
Reference in a new issue