Skip to main content

Prometheus metrics middleware for aiogram 3.x bots

Project description

aiogram3-metrics

Prometheus метрики для aiogram 3.x ботов

Русский | English

Быстрый старт

Установка

pip install aiogram3-metrics

Использование

from aiogram_metrics import MetricsMiddleware, InstrumentedAiohttpSession, start_metrics_server

# /metrics HTTP endpoint
start_metrics_server(port=9101)

# Инструментация сессии (latency и счётчик API вызовов)
session = InstrumentedAiohttpSession(bot_name="mybot")
bot = Bot(token=TOKEN, session=session)

# Middleware (счётчик апдейтов, latency хендлеров, ошибки)
dp.update.outer_middleware(MetricsMiddleware(bot_name="mybot"))

Метрики

MetricsMiddleware

Метрика Тип Labels
tg_updates_total Counter bot, update_type
tg_handler_duration_seconds Histogram bot, update_type
tg_long_polling_lag_seconds Histogram bot
tg_errors_total Counter bot, update_type, error_type

InstrumentedAiohttpSession

Метрика Тип Labels
tg_api_call_duration_seconds Histogram bot, method
tg_api_calls_total Counter bot, method, status

Тестирование

pytest tests/ -v

Phasalo
Делаем красиво!

2026

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiogram3_metrics-0.1.1.tar.gz (71.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram3_metrics-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file aiogram3_metrics-0.1.1.tar.gz.

File metadata

  • Download URL: aiogram3_metrics-0.1.1.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiogram3_metrics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68ff7fd911aafecfa69654ef7eda8e27faa238c397efaa75c5a6892c90e328a0
MD5 225ad521ac5e915b0dde09897c2cc3fc
BLAKE2b-256 8dcea71f2a6c752c499edc2c7f74153c6241d5e71b523d9c6d18254e1f443121

See more details on using hashes here.

File details

Details for the file aiogram3_metrics-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aiogram3_metrics-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aiogram3_metrics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99a76b868e3068deedb458b3ac1a1ff62447eae91f8af36de259365d6b627476
MD5 3d0739dcba35cee7dcb9fb63ef00ae61
BLAKE2b-256 92ebf6b5895cfc225d6e9525659ca483995b97c4f8d33f0a1317a35cdd962eb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page