An aiohttp transport for raven-python
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Transport queue (#18) Oct 13, 2017
.gitignore meta: add more files to gitignore (build, venv) Mar 20, 2018
.travis.yml Release 0.6.0 Oct 16, 2017
CHANGES Fix out of date change Oct 22, 2017
LICENSE meta: Bump year Mar 20, 2018
MANIFEST.in Transport queue (#18) Oct 13, 2017
Makefile Transport queue (#18) Oct 13, 2017
README.rst Update README.rst Oct 25, 2017
raven_aiohttp.py 0.7.0 Mar 20, 2018
setup.cfg Transport queue (#18) Oct 13, 2017
setup.py Fix supported Python versions. (#19) Oct 14, 2017
tox.ini Transport queue (#18) Oct 13, 2017

README.rst

Sentry website

Raven-Aiohttp - Asyncio Transport for the Sentry Python SDK

PyPi page link -- version https://travis-ci.org/getsentry/raven-aiohttp.svg?branch=master PyPi page link -- BSD licence PyPi page link -- Python versions

A transport for the Sentry Python SDK which supports Python 3's asyncio interface. For more information about Sentry and the python SDK, see our Python Documentation for framework integrations and other goodies.

Requirements

  • raven-python>=5.4.0
  • python>=3.4.2
  • aiohttp>=2.0

Usage

raven-aiohttp ships two asyncio based transports for raven.Client: AioHttpTransport and QueuedAioHttpTransport.

AioHttpTransport

All messages to the sentry server will be produced by "Fire And Forget"

Each new message spawns it owns asyncio.Task, amount of them is not limited

import asyncio

from raven import Client
from raven_aiohttp import AioHttpTransport

client = Client(transport=AioHttpTransport)

try:
    1 / 0
except ZeroDivisionError:
    client.captureException()

# graceful shutdown waits until all pending messages are send

loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())

QueuedAioHttpTransport

All messages to the sentry server will be produced by queue system

When transport is created it spawns limited amount of asyncio.Task which sends messages one by one from internal asyncio.Queue

import asyncio
from functools import partial

from raven import Client
from raven_aiohttp import QueuedAioHttpTransport

client = Client(transport=partial(QueuedAioHttpTransport, workers=5, qsize=1000))

try:
    1 / 0
except ZeroDivisionError:
    client.captureException()

# graceful shutdown waits until internal queue is empty

loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())

Resources