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.0.tar.gz (71.2 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.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiogram3_metrics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd0d5b4d9e77a3e943b2c179651d63fd3cbe8a429af28ffb3b88c0f561d0f724
MD5 b743a7ef7f4fcccd71edeca247d37fbe
BLAKE2b-256 6adc7517a6e2a0b00f38337e5e74bf2d96bfb04bb8f55468fc1011187afaa751

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aiogram3_metrics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c905ae4ba09cd483f8ed3b85c1d11f6bf31374a8cb6fa19483415d7e714746e0
MD5 7db39aa221544030a658152ff523a282
BLAKE2b-256 5d33ca4d21a4561f05b2160d1c57d52a2f44154f5ee3ff63c0513a0f03166c81

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