# Muffin-Sentry
**Muffin-Sentry** — [Sentry](https://sentry.io/) integration for the [Muffin](https://github.com/klen/muffin) ASGI framework.

[](https://pypi.org/project/muffin-sentry/)
[](https://pypi.org/project/muffin-sentry/)
[](https://opensource.org/licenses/MIT)
---
## Requirements
- Python >= 3.10
- Muffin >= 1.0
- sentry-sdk >= 1.40
## Installation
Install using pip:
```bash
pip install muffin-sentry
```
## Usage
```python
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)**:
```python
app = Application(
"app",
SENTRY_DSN="https://...",
SENTRY_SDK_OPTIONS={"traces_sample_rate": 0.5},
)
```
2. **Or by calling `.setup()` manually**:
```python
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](https://opensource.org/licenses/MIT).
## Credits
- Created by [klen](https://github.com/klen) (Kirill Klenov)
Raw data
{
"_id": null,
"home_page": "https://github.com/klen/muffin-sentry",
"name": "muffin-sentry",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "sentry, asyncio, trio, asgi, muffin",
"author": "Kirill Klenov",
"author_email": "horneds@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/4a/28/fb7096ae3e021317a79ffd8792c0f2d993f7a6576b25781e9d367acc3c3d/muffin_sentry-2.0.2.tar.gz",
"platform": null,
"description": "# Muffin-Sentry\n\n**Muffin-Sentry** \u2014 [Sentry](https://sentry.io/) integration for the [Muffin](https://github.com/klen/muffin) ASGI framework.\n\n\n[](https://pypi.org/project/muffin-sentry/)\n[](https://pypi.org/project/muffin-sentry/)\n[](https://opensource.org/licenses/MIT)\n\n---\n\n## Requirements\n\n- Python >= 3.10\n- Muffin >= 1.0\n- sentry-sdk >= 1.40\n\n## Installation\n\nInstall using pip:\n\n```bash\npip install muffin-sentry\n```\n\n## Usage\n\n```python\nfrom muffin import Application\nimport muffin_sentry\n\napp = Application(\"example\", SENTRY_DSN=\"https://<public>@sentry.io/<project_id>\")\n\n# Initialize the plugin manually (optional if config is provided)\nsentry = muffin_sentry.Plugin()\nsentry.setup(app)\n\n# Add custom processor (must be sync)\n@sentry.processor\ndef enrich_event(event, hint, request):\n if user := getattr(request, \"user\", None):\n event[\"user\"] = {\"id\": str(user.id)}\n return event\n\n# Raise unhandled exception\n@app.route(\"/fail\")\nasync def fail(request):\n raise RuntimeError(\"Boom\")\n\n# Manually capture a message\n@app.route(\"/capture\")\nasync def capture(request):\n sentry.capture_message(\"Manual log\")\n return \"OK\"\n\n# Update scope manually\n@app.route(\"/scope\")\nasync def tag_scope(request):\n sentry.scope.set_tag(\"section\", \"test\")\n sentry.capture_exception(Exception(\"With scope tag\"))\n return \"OK\"\n```\n\n## Configuration Options\n\nYou can configure the plugin in two ways:\n\n1. **Via Muffin application config (recommended)**:\n\n```python\napp = Application(\n \"app\",\n SENTRY_DSN=\"https://...\",\n SENTRY_SDK_OPTIONS={\"traces_sample_rate\": 0.5},\n)\n```\n\n2. **Or by calling `.setup()` manually**:\n\n```python\nsentry.setup(app, dsn=\"https://...\", sdk_options={\"traces_sample_rate\": 0.5})\n```\n\nAvailable options:\n\n| Name | Default value | Description |\n| --------------- | ----------------------------------- | --------------------------------------------------------- |\n| `dsn` | `\"\"` | Sentry DSN for your project |\n| `sdk_options` | `{}` | Dict of options for sentry-sdk (e.g., traces_sample_rate) |\n| `ignore_errors` | `[ResponseError, ResponseRedirect]` | Exception classes to ignore |\n\n## Notes\n\n- You can access the current Sentry scope using `plugin.scope`.\n- Event processors must be **synchronous** functions.\n- Sentry sessions and transactions are handled automatically inside the plugin middleware.\n\n## Bug Tracker\n\nFound a bug or have a feature request?\nPlease open an issue at: https://github.com/klen/muffin-sentry/issues\n\n## Contributing\n\nDevelopment happens at: https://github.com/klen/muffin-sentry\nPull requests and suggestions are welcome!\n\n## License\n\nLicensed under the [MIT license](https://opensource.org/licenses/MIT).\n\n## Credits\n\n- Created by [klen](https://github.com/klen) (Kirill Klenov)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Sentry Integration for Muffin framework",
"version": "2.0.2",
"project_urls": {
"Homepage": "https://github.com/klen/muffin-sentry",
"Repository": "https://github.com/klen/muffin-sentry"
},
"split_keywords": [
"sentry",
" asyncio",
" trio",
" asgi",
" muffin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ea5312f153ae1ca658f774f580d5f030b874d6c7fcde2c701f1640bfe799a60",
"md5": "461f8c9c2efba4b4c3241ef8c945a725",
"sha256": "0b26da087cb36a5b0b52146e8a26d82b6258e6bf8a9d10ad6c413a2d91d9c2c2"
},
"downloads": -1,
"filename": "muffin_sentry-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "461f8c9c2efba4b4c3241ef8c945a725",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 4499,
"upload_time": "2025-07-17T13:44:58",
"upload_time_iso_8601": "2025-07-17T13:44:58.262267Z",
"url": "https://files.pythonhosted.org/packages/8e/a5/312f153ae1ca658f774f580d5f030b874d6c7fcde2c701f1640bfe799a60/muffin_sentry-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4a28fb7096ae3e021317a79ffd8792c0f2d993f7a6576b25781e9d367acc3c3d",
"md5": "d9728bfc790325e9f5cb2629742fc85e",
"sha256": "c32898f7f4502d77551ecc24f2a115edd7240d16759908d86e0799991ba997d8"
},
"downloads": -1,
"filename": "muffin_sentry-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "d9728bfc790325e9f5cb2629742fc85e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 4049,
"upload_time": "2025-07-17T13:45:00",
"upload_time_iso_8601": "2025-07-17T13:45:00.325510Z",
"url": "https://files.pythonhosted.org/packages/4a/28/fb7096ae3e021317a79ffd8792c0f2d993f7a6576b25781e9d367acc3c3d/muffin_sentry-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-17 13:45:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "klen",
"github_project": "muffin-sentry",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "muffin-sentry"
}