跳转到主要内容

Muffin框架的Sentry集成

项目描述

松饼-SentrySentry 集成于 Muffin 框架

Tests Status PYPI Version Python Versions

需求

  • python >= 3.8

安装

松饼-Sentry 应使用pip安装

pip install muffin-sentry

用法

from muffin import Application
import muffin_sentry

# Create Muffin Application
app = Application('example')

# Initialize the plugin
# As alternative: jinja2 = Jinja2(app, **options)
sentry = muffin_sentry.Plugin()
sentry.setup(app, dsn="DSN_URL")

# Setup custom request processors (coroutines are not supported)
@sentry.processor
def user_scope(event, hint, request):
    if request.user:
        event['user'] = request.user.email
    return event

# Use it inside your handlers

# The exception will be send to Sentry
@app.route('/unhandled')
async def catch_exception(request):
    raise Exception('unhandled')

# Capture a message by manual
@app.route('/capture_message')
async def message(request):
    sentry.capture_message('a message from app')
    return 'OK'

# Capture an exception by manual
@app.route('/capture_exception')
async def exception(request):
    sentry.capture_exception(Exception())
    return 'OK'

# Update Sentry Scope
@app.route('/update_user')
async def user(request):
    scope = sentry.current_scope.get()
    scope.set_user({'id': 1, 'email': 'example@example.com'})
    sentry.capture_exception(Exception())
    return 'OK'

选项

名称

默认值

描述

dsn

""

您的应用程序的Sentry DSN

sdk_options

{}

Sentry SDK客户端的附加选项。请参阅 https://docs.sentry.io/platforms/python/configuration/options/

ignore_errors

[ResponseError, ResponseRedirect]

要忽略的异常类型

您可以在初始化插件时提供这些选项

sentry.setup(app, dsn='DSN_URL')

或者,在 Muffin.Application 配置中使用 SENTRY_ 前缀进行设置

SENTRY_DSN = 'DSN_URL'

Muffin.Application 配置选项不区分大小写

错误追踪器

如果您有任何建议、错误报告或烦恼,请向https://github.com/klen/muffin-sentry/issues 的问题跟踪器报告

贡献

Muffin-Sentry的开发发生在这里: https://github.com/klen/muffin-sentry

贡献者

  • klen (Kirill Klenov)

许可证

MIT许可证下许可。

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

muffin_sentry-1.10.0.tar.gz (4.4 kB 查看哈希值)

上传时间 源代码

构建分发

muffin_sentry-1.10.0-py3-none-any.whl (4.7 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面