Skip to content

Commit

Permalink
add sentry error tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Apr 26, 2023
1 parent cddc37f commit ffcfcea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ flower==1.2.0
psutil==5.9.5
influxdb==5.3.1
beautifulsoup4==4.12.2
fakeredis==2.10.3
fakeredis==2.11.1
supervisor==4.2.5
tgbot-ping==1.0.7
redis==4.5.4
Expand All @@ -22,3 +22,4 @@ ffpb==0.4.1
youtube-search-python==1.6.6
token-bucket==0.3.0
coloredlogs==15.0.1
sentry-sdk==1.21.0
2 changes: 2 additions & 0 deletions ytdlbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@
TOKEN_PRICE = os.getenv("BUY_UNIT", 20) # one USD=20 credits

RATE_LIMIT = os.getenv("RATE_LIMIT", 10)

DSN = os.getenv("DSN")
5 changes: 5 additions & 0 deletions ytdlbot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@
import psutil
import pyrogram.errors
import requests
import sentry_sdk
from apscheduler.schedulers.background import BackgroundScheduler
from celery import Celery
from celery.worker.control import Panel
from pyrogram import Client, idle, types
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from sentry_sdk.integrations.celery import CeleryIntegration

from channel import Channel
from client_init import create_app
from config import (
ARCHIVE_ID,
BROKER,
DSN,
ENABLE_CELERY,
ENABLE_QUEUE,
ENABLE_VIP,
Expand Down Expand Up @@ -71,6 +74,8 @@

session = "ytdl-celery"
celery_client = create_app(session)
if DSN:
sentry_sdk.init(DSN, integrations=[CeleryIntegration()])


def get_messages(chat_id, message_id):
Expand Down
4 changes: 4 additions & 0 deletions ytdlbot/ytdl_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from io import BytesIO

import pyrogram.errors
import sentry_sdk
from apscheduler.schedulers.background import BackgroundScheduler
from pyrogram import Client, filters, types
from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant
Expand All @@ -29,6 +30,7 @@
from client_init import create_app
from config import (
AUTHORIZED_USER,
DSN,
ENABLE_CELERY,
ENABLE_FFMPEG,
ENABLE_VIP,
Expand Down Expand Up @@ -60,6 +62,8 @@
logging.info("Authorized users are %s", AUTHORIZED_USER)
redis = Redis()
channel = Channel()
if DSN:
sentry_sdk.init(dsn=DSN)


def private_use(func):
Expand Down

0 comments on commit ffcfcea

Please sign in to comment.