From f1577271df4695a29bf5436d8709e491e680a1e8 Mon Sep 17 00:00:00 2001 From: kiriharu Date: Wed, 31 Mar 2021 09:44:08 +0300 Subject: [PATCH] don't push metrics if INFLUX_HOST not provided --- apps/tgbot/tgbot/handlers/metrics.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/tgbot/tgbot/handlers/metrics.py b/apps/tgbot/tgbot/handlers/metrics.py index 42559a1..4168b87 100644 --- a/apps/tgbot/tgbot/handlers/metrics.py +++ b/apps/tgbot/tgbot/handlers/metrics.py @@ -7,7 +7,9 @@ from ..config import (INFLUX_DB, INFLUX_HOST, INFLUX_PASSWORD, INFLUX_PORT, async def push_metric(measurement, tags: Dict, fields: Dict): - try: + if INFLUX_HOST is None: + pass + else: point = { 'measurement': measurement, 'tags': tags, @@ -22,9 +24,6 @@ async def push_metric(measurement, tags: Dict, fields: Dict): mode='async' ) as client: await client.write(point) - except Exception as e: - print(e) - pass async def push_api_request_status(status_code: int, endpoint: str):