From baffe1b79e8886f4b842900a0343c9f37d440d6d Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 1 Jun 2019 21:18:06 +0300 Subject: [PATCH] Revert "Add event/update counter to metrics" This reverts commit 145eb8f611d00ec83fd3ddcc59677770a9d37fd5. --- mautrix_telegram/abstract_user.py | 11 +++-------- mautrix_telegram/matrix.py | 8 ++------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/mautrix_telegram/abstract_user.py b/mautrix_telegram/abstract_user.py index 3b789a16..5094769c 100644 --- a/mautrix_telegram/abstract_user.py +++ b/mautrix_telegram/abstract_user.py @@ -52,16 +52,13 @@ UpdateMessage = Union[UpdateShortChatMessage, UpdateShortMessage, UpdateNewChann UpdateMessageContent = Union[UpdateShortMessage, UpdateShortChatMessage, Message, MessageService] try: - from prometheus_client import Histogram, Counter + from prometheus_client import Histogram - UPDATE_COUNT = Counter("telegram_update_count", "Number of Telegram updates processed", - ["update_type"]) UPDATE_TIME = Histogram("telegram_update", "Time spent processing Telegram updates", ["update_type"]) except ImportError: Histogram = None UPDATE_TIME = None - UPDATE_COUNT = None class AbstractUser(ABC): session_container = None # type: AlchemySessionContainer @@ -169,10 +166,8 @@ class AbstractUser(ABC): await self._update(update) except Exception: self.log.exception("Failed to handle Telegram update") - if UPDATE_TIME and UPDATE_COUNT: - update_type = type(update).__name__ - UPDATE_TIME.labels(update_type=update_type).observe(time.time() - start_time) - UPDATE_COUNT.labels(update_type=update_type).inc() + if UPDATE_TIME: + UPDATE_TIME.labels(update_type=type(update).__name__).observe(time.time() - start_time) async def get_dialogs(self, limit: int = None) -> List[Union[Chat, Channel]]: if self.is_bot: diff --git a/mautrix_telegram/matrix.py b/mautrix_telegram/matrix.py index e1255f10..1830416d 100644 --- a/mautrix_telegram/matrix.py +++ b/mautrix_telegram/matrix.py @@ -29,16 +29,13 @@ if TYPE_CHECKING: from .context import Context try: - from prometheus_client import Histogram, Counter + from prometheus_client import Histogram - EVENT_COUNT = Counter("matrix_event_count", "Number of Matrix events processed", - ["event_type"]) EVENT_TIME = Histogram("matrix_event", "Time spent processing Matrix events", ["event_type"]) except ImportError: Histogram = None EVENT_TIME = None - EVENT_COUNT = None class MatrixHandler: @@ -446,6 +443,5 @@ class MatrixHandler: await self.handle_typing(room_id, content.get("user_ids", [])) else: return - if EVENT_TIME and EVENT_COUNT: + if EVENT_TIME: EVENT_TIME.labels(event_type=evt_type).observe(time.time() - start_time) - EVENT_COUNT.labels(event_type=evt_type).inc()