Muffin框架的Sentry集成
项目描述
松饼-Sentry – Sentry 集成于 Muffin 框架
需求
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的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1cc575f96856d7d673b49b68d4e1399ef7bb171c16e0d9602c627f6c5f07d728 |
|
MD5 | f481b626695b66b18d8daa3037a04edf |
|
BLAKE2b-256 | cab6df4b5a197cbbafe1f5dc4b0bccd5376cce0227b62619b4db28f8fcbad6c3 |
关闭
muffin_sentry-1.10.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f1631495a1de03bfdccfddc9017e3470958f4d0f274ebdfcfc80a9d9315fd2b3 |
|
MD5 | 001a51969f4de3faf55466e9fd0a88d7 |
|
BLAKE2b-256 | 091af0198992ee2930455f434d2ba986582db11b6214cd71139efd63533b9f04 |