From f7065c6f0c76081d700e6e686b10e1a7a0f33cc4 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 31 Mar 2020 10:14:35 -0400 Subject: [PATCH] add reorg count metric to prometheus --- lbry/wallet/server/block_processor.py | 3 ++- lbry/wallet/server/prometheus.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lbry/wallet/server/block_processor.py b/lbry/wallet/server/block_processor.py index bdb3d014d..d6cdd7b74 100644 --- a/lbry/wallet/server/block_processor.py +++ b/lbry/wallet/server/block_processor.py @@ -10,7 +10,7 @@ from lbry.wallet.server.daemon import DaemonError from lbry.wallet.server.hash import hash_to_hex_str, HASHX_LEN from lbry.wallet.server.util import chunks, class_logger from lbry.wallet.server.leveldb import FlushData -from lbry.wallet.server.prometheus import BLOCK_COUNT, BLOCK_UPDATE_TIMES +from lbry.wallet.server.prometheus import BLOCK_COUNT, BLOCK_UPDATE_TIMES, REORG_COUNT class Prefetcher: @@ -255,6 +255,7 @@ class BlockProcessor: last -= len(raw_blocks) self.db.sql.delete_claims_above_height(self.height) await self.prefetcher.reset_height(self.height) + REORG_COUNT.inc() async def reorg_hashes(self, count): """Return a pair (start, last, hashes) of blocks to back up during a diff --git a/lbry/wallet/server/prometheus.py b/lbry/wallet/server/prometheus.py index a2f82f21e..13359980a 100644 --- a/lbry/wallet/server/prometheus.py +++ b/lbry/wallet/server/prometheus.py @@ -51,7 +51,9 @@ BLOCK_COUNT = Gauge( "block_count", "Number of processed blocks", namespace=NAMESPACE ) BLOCK_UPDATE_TIMES = Histogram("block_time", "Block update times", namespace=NAMESPACE) - +REORG_COUNT = Gauge( + "reorg_count", "Number of reorgs", namespace=NAMESPACE +) class PrometheusServer: def __init__(self):