Skip to main content

Sentry Integration for Muffin framework

Project description

Muffin-SentrySentry Integration for Muffin framework

Tests Status PYPI Version Python Versions

Requirements

  • python >= 3.8

Installation

Muffin-Sentry should be installed using pip:

pip install muffin-sentry

Usage

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'

Options

Name

Default value

Desctiption

dsn

""

Sentry DSN for your application

sdk_options

{}

Additional options for Sentry SDK Client. See https://docs.sentry.io/platforms/python/configuration/options/

ignore_errors

[ResponseError, ResponseRedirect]

Exception Types to Ignore

You are able to provide the options when you are initiliazing the plugin:

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

Or setup it inside Muffin.Application config using the SENTRY_ prefix:

SENTRY_DSN = 'DSN_URL'

Muffin.Application configuration options are case insensitive

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-sentry/issues

Contributing

Development of Muffin-Sentry happens at: https://github.com/klen/muffin-sentry

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muffin-sentry-1.4.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

muffin_sentry-1.4.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file muffin-sentry-1.4.2.tar.gz.

File metadata

  • Download URL: muffin-sentry-1.4.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for muffin-sentry-1.4.2.tar.gz
Algorithm Hash digest
SHA256 48abe918c23a0d824f9157ec0d4ad9874e40a454e46bd20299d35caed797b79c
MD5 f6239e977072d919bd9219eb44e93c1d
BLAKE2b-256 5d8a402ea1f4a5ca99da7238e60fd6dc09f8ddc69a8007333faf55e97d39cbd4

See more details on using hashes here.

File details

Details for the file muffin_sentry-1.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for muffin_sentry-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e954ad03f1ce2c821eb47fdfc4449d9bebb8806adf989d544a7075ec272beeec
MD5 4059a3f063c101892ee7f993bff3c0f2
BLAKE2b-256 0ffde991a436b12afc91cda1eff52e881a33c59b1ffa3611686b96540a6e6748

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page