Files
Telegram-Downloader-Bot/telegram_downloader_bot/telemetry.py
Roman Krček 8829caceee
All checks were successful
Build Docker image / test (push) Successful in 5m36s
Build Docker image / build (push) Successful in 8m19s
Add prometheus telemetry
2025-05-06 20:06:36 +02:00

33 lines
712 B
Python

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:
"""
Initialize telemetry for the bot.
"""
start_http_server(8000)