Giter Site home page Giter Site logo

raven-aiohttp's Introduction

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

raven-aiohttp's People

Contributors

dcramer avatar mitsuhiko avatar titouanc avatar mattrobenolt avatar hellysmile avatar ashwoods avatar mastak avatar min3953 avatar matrixise avatar hotsyk avatar

Watchers

James Cloos avatar Nicolas Delaby avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.