All Projects → underyx → aiohttp-sentry

underyx / aiohttp-sentry

Licence: MIT license
An aiohttp server middleware for reporting failed requests to Sentry

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to aiohttp-sentry

Sentry Javascript
Official Sentry SDKs for JavaScript. We're hiring https://grnh.se/ca81c1701us
Stars: ✭ 6,012 (+17077.14%)
Mutual labels:  sentry, raven, sentry-client
good-sentry
Sentry broadcasting for good process monitor
Stars: ✭ 15 (-57.14%)
Mutual labels:  sentry, raven, sentry-client
crow
Crow - a C++ client for Sentry
Stars: ✭ 119 (+240%)
Mutual labels:  sentry, sentry-client
raven-python-lambda
Sentry/Raven SDK Integration For AWS Lambda (python) and Serverless
Stars: ✭ 48 (+37.14%)
Mutual labels:  sentry, raven
send-test-info
Attach unit test information to exceptions sent by Raven to Sentry
Stars: ✭ 17 (-51.43%)
Mutual labels:  sentry, raven
nextcloud sentry
Sentry integration for Nextcloud
Stars: ✭ 26 (-25.71%)
Mutual labels:  sentry, sentry-client
redux-sentry
Middleware that logs all your store and actions on exception to Sentry with raven-js
Stars: ✭ 13 (-62.86%)
Mutual labels:  sentry, raven
sentry-testkit
A Sentry plugin to allow Sentry report interception and further inspection of the data being sent
Stars: ✭ 78 (+122.86%)
Mutual labels:  sentry, raven
zend-sentry
A Zend Framework 3 module that lets you log to the Sentry.io service.
Stars: ✭ 34 (-2.86%)
Mutual labels:  sentry, raven
next-utils
🥩 🍳 A set of Next.js HoC utilities to make your life easier
Stars: ✭ 30 (-14.29%)
Mutual labels:  sentry, sentry-client
Raven Aiohttp
An aiohttp transport for raven-python
Stars: ✭ 92 (+162.86%)
Mutual labels:  sentry, aiohttp
sanic-sentry
Sentry integration to sanic web server
Stars: ✭ 31 (-11.43%)
Mutual labels:  sentry, raven
Sentry Php
The official PHP SDK for Sentry (sentry.io)
Stars: ✭ 1,591 (+4445.71%)
Mutual labels:  sentry, sentry-client
Raven Python
Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
Stars: ✭ 1,677 (+4691.43%)
Mutual labels:  sentry, sentry-client
PornHub-Downloader
基于 Aiohttp 和 Pyppeteer 的 PornHub 视频下载工具,支持多任务并行下载。
Stars: ✭ 20 (-42.86%)
Mutual labels:  aiohttp
Python Blog
An async blog web app written in python3
Stars: ✭ 29 (-17.14%)
Mutual labels:  aiohttp
Pyrez
(ON REWRITE) An easy to use (a)sync wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python. 🐍
Stars: ✭ 23 (-34.29%)
Mutual labels:  aiohttp
aiokubernetes
Asynchronous Kubernetes Client
Stars: ✭ 26 (-25.71%)
Mutual labels:  aiohttp
torequests
Async wrapper for requests / aiohttp, and some crawler toolkits. Let synchronization code enjoy the performance of asynchronous programming.
Stars: ✭ 22 (-37.14%)
Mutual labels:  aiohttp
telescope
A dumb auditing service
Stars: ✭ 15 (-57.14%)
Mutual labels:  aiohttp

aiohttp-sentry

CI Status

An aiohttp server middleware for reporting failed requests to Sentry

Usage

Just add SentryMiddleware as a middleware:

from aiohttp import web
from aiohttp_sentry import SentryMiddleware
app = web.Application(middlewares=[SentryMiddleware()])

Configuration

If you want to customize error reporting, you can use the optional sentry_kwargs parameter, which is a dict of kwargs passed to the lower-level Sentry library, raven. With this, you can specify environment details, filter out specific exceptions, and so on:

from aiohttp import web
from aiohttp_sentry import SentryMiddleware
app = web.Application(
    middlewares=(
        SentryMiddleware({
            'environment': 'foo',
            'release': 'bar',
            'ignore_exceptions': 'aiohttp.HTTPClientError'
        }),
        # ...
    ),
)

If you are using the standard library's logging module, we have a convenient parameter to patch it for you, to have logger calls send events to Sentry automatically:

Warning

This modifies your logging configuration globally when you instantiate the middleware. Even if you don't end up using the middleware instance for a request, all your logs will be sent to Sentry.

import logging
from aiohttp import web
from aiohttp_sentry import SentryMiddleware

app = web.Application(
    middlewares=[SentryMiddleware(patch_logging=True, sentry_log_level=logging.WARNING)],
)

Attaching Data to Events

By default, aiohttp-sentry passes this data alongside reported exceptions:

  • HTTP scheme
  • HTTP method
  • URL
  • Query String
  • Request Headers (including cookies)
  • Requester's IP address

If you need more data in sentry, you can do that by subclassing from SentryMiddleware and overriding the get_extra_data method, which returns all the above by default. Here's what that looks like:

class DetailedSentryMiddleware(SentryMiddleware):

    async def get_extra_data(self, request):
        return {
            **await super().get_extra_data(request),
            'settings': request.app['settings'],
        }

While get_extra_data is a coroutine, which means it can make database queries, API calls, or other I/O operations, use this carefully! Make sure you understand the implications of executing expensive operations every time an error happens. If the root cause of the error is an overloaded database, you are just going to make the problem worse, while not even being able to get the extra info you wanted.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].