Add prometheus telemetry
All checks were successful
Build Docker image / test (push) Successful in 5m36s
Build Docker image / build (push) Successful in 8m19s

This commit is contained in:
Roman Krček
2025-05-06 20:06:36 +02:00
parent 8cc1c55026
commit 8829caceee
6 changed files with 320 additions and 276 deletions

View File

@@ -1,10 +1,32 @@
import sentry_sdk
from prometheus_client import Histogram, start_http_server
DOWNLOAD_DURATION = Histogram(
'tt_download_time',
'Time taken to download a single tiktok video',
['service'],
buckets=[0.1, 0.5, 1, 2, 5, 10, 30, 60, 120]
)
FILE_SIZE_BYTES = Histogram(
'downloaded_file_size_bytes',
'Size of the downloaded file in bytes',
['service'],
buckets=[
1e6, # 1 MB
5e6, # 5 MB
10e6, # 10 MB
25e6, # 25 MB
50e6, # 50 MB
100e6, # 100 MB
200e6, # 200 MB
500e6, # 500 MB
1e9 # 1 GB
]
)
def init_telemetry() -> None:
sentry_sdk.init(
dsn="https://12d7a075d483fc133cde0ed82e72ac45@o4508071875313664.ingest.de.sentry.io/4508075566694480", # noqa: E501
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
enable_tracing=True
)
"""
Initialize telemetry for the bot.
"""
start_http_server(8000)