Add Twitter error tracking
This commit is contained in:
parent
969999fc46
commit
c022a62e98
2 changed files with 6 additions and 1 deletions
|
@ -24,6 +24,9 @@ twitter_count = Counter(
|
|||
"JARVIS twitter sync count",
|
||||
labelnames=["guild_id", "guild_name", "twitter_handle"],
|
||||
)
|
||||
twitter_error = Counter(
|
||||
"jarvis_tasks_twitter_error", "JARVIS twitter error count", labelnames=["error_code"]
|
||||
)
|
||||
|
||||
# Gauge currently not used
|
||||
reminder_gauge = Gauge(
|
||||
|
|
|
@ -13,7 +13,7 @@ from tweepy.asynchronous import AsyncStream
|
|||
from tweepy.models import Status
|
||||
|
||||
from jarvis_tasks.config import TaskConfig
|
||||
from jarvis_tasks.prometheus.stats import twitter_count, twitter_gauge
|
||||
from jarvis_tasks.prometheus.stats import twitter_count, twitter_error, twitter_gauge
|
||||
from jarvis_tasks.util import build_embed
|
||||
|
||||
config = TaskConfig.from_yaml()
|
||||
|
@ -102,6 +102,8 @@ class JARVISTwitterStream(AsyncStream):
|
|||
status_code: HTTP Status Code
|
||||
"""
|
||||
logger.error(f"Received status code {status_code} while streaming, restarting")
|
||||
errors = twitter_error.labels(error_code=status_code)
|
||||
errors.inc()
|
||||
self.disconnect()
|
||||
|
||||
async def on_status(self, status: Status) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue