为raven-python提供的asyncio传输
项目描述
.. raw:: html
<p align="center">
.. image:: https://sentry-brand.storage.googleapis.com/sentry-logo-black.png
:target: https://sentry.io
:align: center
:width: 116
:alt: Sentry网站
.. raw:: html
</p>
===========================================================
Raven-Aiohttp - Sentry Python SDK的Asyncio传输
===========================================================
.. image:: https://img.shields.io/pypi/v/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- 版本
.. image:: https://travis-ci.org/getsentry/raven-aiohttp.svg?branch=master
:target: https://travis-ci.org/getsentry/raven-aiohttp
.. image:: https://img.shields.io/pypi/l/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- BSD许可
.. image:: https://img.shields.io/pypi/pyversions/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- Python版本
为`Sentry Python SDK`_提供的传输,支持Python 3的asyncio接口。
有关Sentry和python SDK的更多信息,请参阅我们的`Python文档`_有关框架集成
和其他好东西。
要求
============
- `raven-python>=5.4.0`
- `python>=3.4.2`
- `aiohttp>=2.0`
用法
=====
`raven-aiohttp` 为 `raven.Client` 提供了两个基于 asyncio 的传输方式:`AioHttpTransport` 和 `QueuedAioHttpTransport`。
AioHttpTransport
----------------
所有发送到 Sentry 服务器的消息将通过“一次性发送”产生
每个新消息都会创建它自己的 `asyncio.Task`,数量不受限制
.. code-block:: python
import asyncio
from raven import Client
from raven_aiohttp import AioHttpTransport
client = Client(transport=AioHttpTransport)
try
1 / 0
except ZeroDivisionError
client.captureException()
# 优雅关闭,等待所有待处理消息发送完成
loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())
QueuedAioHttpTransport
----------------------
所有发送到 Sentry 服务器的消息将通过队列系统产生
当传输创建时,它将启动有限数量的 `asyncio.Task`
它们从内部 `asyncio.Queue` 逐个发送消息
.. code-block:: python
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()
# 优雅关闭,等待内部队列为空
loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())
资源
=========
* `Sentry`_
* `Python 文档`_
* `问题跟踪器`_
* `IRC 频道`_ (irc.freenode.net, #sentry)
.. _Sentry: https://getsentry.com/
.. _Sentry Python SDK: https://github.com/getsentry/raven-python
.. _Python 文档: https://docs.getsentry.com/hosted/clients/python/
.. _问题跟踪器: https://github.com/getsentry/raven-aiohttp/issues
.. _IRC 频道: irc://irc.freenode.net/sentry
<p align="center">
.. image:: https://sentry-brand.storage.googleapis.com/sentry-logo-black.png
:target: https://sentry.io
:align: center
:width: 116
:alt: Sentry网站
.. raw:: html
</p>
===========================================================
Raven-Aiohttp - Sentry Python SDK的Asyncio传输
===========================================================
.. image:: https://img.shields.io/pypi/v/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- 版本
.. image:: https://travis-ci.org/getsentry/raven-aiohttp.svg?branch=master
:target: https://travis-ci.org/getsentry/raven-aiohttp
.. image:: https://img.shields.io/pypi/l/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- BSD许可
.. image:: https://img.shields.io/pypi/pyversions/raven-aiohttp.svg
:target: https://pypi.python.org/pypi/raven-aiohttp
:alt: PyPi页面链接 -- Python版本
为`Sentry Python SDK`_提供的传输,支持Python 3的asyncio接口。
有关Sentry和python SDK的更多信息,请参阅我们的`Python文档`_有关框架集成
和其他好东西。
要求
============
- `raven-python>=5.4.0`
- `python>=3.4.2`
- `aiohttp>=2.0`
用法
=====
`raven-aiohttp` 为 `raven.Client` 提供了两个基于 asyncio 的传输方式:`AioHttpTransport` 和 `QueuedAioHttpTransport`。
AioHttpTransport
----------------
所有发送到 Sentry 服务器的消息将通过“一次性发送”产生
每个新消息都会创建它自己的 `asyncio.Task`,数量不受限制
.. code-block:: python
import asyncio
from raven import Client
from raven_aiohttp import AioHttpTransport
client = Client(transport=AioHttpTransport)
try
1 / 0
except ZeroDivisionError
client.captureException()
# 优雅关闭,等待所有待处理消息发送完成
loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())
QueuedAioHttpTransport
----------------------
所有发送到 Sentry 服务器的消息将通过队列系统产生
当传输创建时,它将启动有限数量的 `asyncio.Task`
它们从内部 `asyncio.Queue` 逐个发送消息
.. code-block:: python
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()
# 优雅关闭,等待内部队列为空
loop = asyncio.get_event_loop()
loop.run_until_complete(client.remote.get_transport().close())
资源
=========
* `Sentry`_
* `Python 文档`_
* `问题跟踪器`_
* `IRC 频道`_ (irc.freenode.net, #sentry)
.. _Sentry: https://getsentry.com/
.. _Sentry Python SDK: https://github.com/getsentry/raven-python
.. _Python 文档: https://docs.getsentry.com/hosted/clients/python/
.. _问题跟踪器: https://github.com/getsentry/raven-aiohttp/issues
.. _IRC 频道: irc://irc.freenode.net/sentry