Skip to main content

Muffin-SentrySentry integration for the Muffin ASGI framework.

Tests Status PyPI Version Python Versions License

Requirements

  • Python >= 3.10

  • Muffin >= 1.0

  • sentry-sdk >= 1.40

Installation

Install using pip:

pip install muffin-sentry

Usage

from muffin import Application
import muffin_sentry

app = Application("example", SENTRY_DSN="https://<public>@sentry.io/<project_id>")

# Initialize the plugin manually (optional if config is provided)
sentry = muffin_sentry.Plugin()
sentry.setup(app)

# Add custom processor (must be sync)
@sentry.processor
def enrich_event(event, hint, request):
    if user := getattr(request, "user", None):
        event["user"] = {"id": str(user.id)}
    return event

# Raise unhandled exception
@app.route("/fail")
async def fail(request):
    raise RuntimeError("Boom")

# Manually capture a message
@app.route("/capture")
async def capture(request):
    sentry.capture_message("Manual log")
    return "OK"

# Update scope manually
@app.route("/scope")
async def tag_scope(request):
    sentry.scope.set_tag("section", "test")
    sentry.capture_exception(Exception("With scope tag"))
    return "OK"

Configuration Options

You can configure the plugin in two ways:

  1. Via Muffin application config (recommended):

app = Application(
    "app",
    SENTRY_DSN="https://...",
    SENTRY_SDK_OPTIONS={"traces_sample_rate": 0.5},
)
  1. Or by calling `.setup()` manually:

sentry.setup(app, dsn="https://...", sdk_options={"traces_sample_rate": 0.5})

Available options:

Name

Default value

Description

dsn

""

Sentry DSN for your project

sdk_options

{}

Dict of options for sentry-sdk (e.g., traces_sample_rate)

ignore_errors

[ResponseError, ResponseRedirect]

Exception classes to ignore

Notes

  • You can access the current Sentry scope using plugin.scope.

  • Event processors must be synchronous functions.

  • Sentry sessions and transactions are handled automatically inside the plugin middleware.

Bug Tracker

Found a bug or have a feature request? Please open an issue at: https://github.com/klen/muffin-sentry/issues

Contributing

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

Pull requests and suggestions are welcome!

License

Licensed under the MIT license.

Credits

  • Created by klen (Kirill Klenov)

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-2.0.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muffin_sentry-2.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file muffin_sentry-2.0.0.tar.gz.

File metadata

  • Download URL: muffin_sentry-2.0.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for muffin_sentry-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6b033dc52187c0fb091b961562cb9b800ed94dbe2b86f0fa067915f5630f688f
MD5 366304729ef85f953c9a4bf214238c27
BLAKE2b-256 22ee9951d77f9cb15919c42f46d716316693e69492514aa32774810bdda96f2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: muffin_sentry-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for muffin_sentry-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a319d3d2a7d57821f3cd5289e22c1a645223abf24e6791ec8eee9a97594d3c4
MD5 7575cafc2d6a7b6932c773de4672550e
BLAKE2b-256 cc9769f6307f3cec5e523283055b1341ce99f040082c075168d0d3a4513d017b

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.2

2 files

This release

2.0.0 This release

2 files

1.11.0

2 files

1.10.0

2 files

1.9.0

2 files

1.8.1

2 files

1.8.0

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page