You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Alexey Berezhnoy 2a0e45839c update version 1 year ago
elasticapm_aiohttp fix end_transaction if excecption is different from Exception. 1 year ago
.gitignore init elasticamp-aiohttp 2 years ago
CHANGELOG.md update version 1 year ago
LICENSE.txt add license 2 years ago
README.md update README 1 year ago
setup.py update version 1 year ago

README.md

Рекомендуется использовать elasticapm последней версии т.к там появилась поддержка aiohttp https://github.com/elastic/apm-agent-python


Интеграция aiohttp приложения с elastic apm

https://www.elastic.co/guide/en/apm/agent/python/4.x/index.html

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

Установка elasticapm-aiohttp в aiohttp приложение

from aiohttp import web
from elasticapm_aiohttp.contrib.aiohttp import elastic_apm_middleware, setup_apm, close_apm


app = web.Application(middlewares=[elastic_apm_middleware])
app.on_startup.append(setup_apm(service_name='test', secret_token='secret', server_url='url'))
app.on_cleanup.append(close_apm)

Можно задать service_name, secret_token и server_url с помощью переменных окружения

# .env
ELASTIC_APM_SERVICE_NAME=test
ELASTIC_APM_SERVER_URL=url
ELASTIC_APM_SECRET_TOKEN=secret
# main.py
app.on_startup.append(setup_apm())

Полная документация по всем переменным окружения https://www.elastic.co/guide/en/apm/agent/python/current/configuration.html

Использование в асинхронном коде

from elasticapm_aiohttp import capture_span

@capture_span()
async def some_func_1():
    ...

@capture_span()
def some_func_2():
    ...