Muffin-Sentry
Muffin-Sentry — Sentry integration for the Muffin ASGI framework.
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:
- Via Muffin application config (recommended):
app = Application(
"app",
SENTRY_DSN="https://...",
SENTRY_SDK_OPTIONS={"traces_sample_rate": 0.5},
)
- 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)
Metadata
Release files for muffin-sentry 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| muffin_sentry-2.0.2.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| muffin_sentry-2.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / muffin_sentry-2.0.2.tar.gz
| Download URL | muffin_sentry-2.0.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c32898f7f4502d77551ecc24f2a115edd7240d16759908d86e0799991ba997d8
|
|
BLAKE2b-256 checksum How to use checksums |
4a28fb7096ae3e021317a79ffd8792c0f2d993f7a6576b25781e9d367acc3c3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure
|
Release files / muffin_sentry-2.0.2-py3-none-any.whl
| Download URL | muffin_sentry-2.0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b26da087cb36a5b0b52146e8a26d82b6258e6bf8a9d10ad6c413a2d91d9c2c2
|
|
BLAKE2b-256 checksum How to use checksums |
8ea5312f153ae1ca658f774f580d5f030b874d6c7fcde2c701f1640bfe799a60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure
|
Security for muffin-sentry 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.