From 5b29894048e32cd20e7ca9e6367f96fed7ad6ecc Mon Sep 17 00:00:00 2001
From: Jack Robison <jackrobison@lbry.io>
Date: Sun, 5 Apr 2020 19:13:19 -0400
Subject: [PATCH] add reset clients counter to prometheus

---
 lbry/wallet/rpc/session.py       | 4 ++--
 lbry/wallet/server/prometheus.py | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lbry/wallet/rpc/session.py b/lbry/wallet/rpc/session.py
index e9c4c6925..53c164f4f 100644
--- a/lbry/wallet/rpc/session.py
+++ b/lbry/wallet/rpc/session.py
@@ -39,8 +39,7 @@ from lbry.wallet.tasks import TaskGroup
 from .jsonrpc import Request, JSONRPCConnection, JSONRPCv2, JSONRPC, Batch, Notification
 from .jsonrpc import RPCError, ProtocolError
 from .framing import BadMagicError, BadChecksumError, OversizedPayloadError, BitcoinFramer, NewlineFramer
-from .util import Concurrency
-from lbry.wallet.server.prometheus import NOTIFICATION_COUNT, RESPONSE_TIMES, REQUEST_ERRORS_COUNT
+from lbry.wallet.server.prometheus import NOTIFICATION_COUNT, RESPONSE_TIMES, REQUEST_ERRORS_COUNT, RESET_CONNECTIONS
 
 
 class Connector:
@@ -389,6 +388,7 @@ class RPCSession(SessionBase):
             except MemoryError:
                 self.logger.warning('received oversized message from %s:%s, dropping connection',
                                     self._address[0], self._address[1])
+                RESET_CONNECTIONS.labels(version=self.client_version).inc()
                 self._close()
                 return
 
diff --git a/lbry/wallet/server/prometheus.py b/lbry/wallet/server/prometheus.py
index 13359980a..e28976bf9 100644
--- a/lbry/wallet/server/prometheus.py
+++ b/lbry/wallet/server/prometheus.py
@@ -54,6 +54,11 @@ BLOCK_UPDATE_TIMES = Histogram("block_time", "Block update times", namespace=NAM
 REORG_COUNT = Gauge(
     "reorg_count", "Number of reorgs", namespace=NAMESPACE
 )
+RESET_CONNECTIONS = Counter(
+    "reset_clients", "Number of reset connections by client version",
+    namespace=NAMESPACE, labelnames=("version",)
+)
+
 
 class PrometheusServer:
     def __init__(self):