Sentry integration plugin for Flaxon framework
Project description
Flaxon Sentry Plugin
Sentry error tracking and performance monitoring for Flaxon framework.
Installation
pip install flaxon-sentry
Quick Start
python
from flaxon import Flaxon
from flaxon_sentry import SentryPlugin
app = Flaxon("my-app")
# Load Sentry plugin
app.plugins.load_plugin(SentryPlugin(
dsn="https://your-sentry-dsn",
environment="production",
release="1.0.0",
))
@app.get("/")
async def home():
return {"message": "Hello with Sentry!"}
Features
Error capture — Automatically captures exceptions and sends to Sentry
Request context — Adds request data to Sentry events (method, path, user, etc.)
Performance tracking — Transaction timing for routes
User tracking — Associates errors with users
Custom tags — Add custom tags to events
Ignore patterns — Configure which errors to ignore
Configuration
Environment Variables
bash
export SENTRY_DSN=https://your-sentry-dsn
export SENTRY_ENVIRONMENT=production
export SENTRY_RELEASE=1.0.0
export SENTRY_SAMPLE_RATE=1.0
export SENTRY_TRACES_SAMPLE_RATE=0.1
With Flaxon Config
python
app = Flaxon("my-app", config={
"SENTRY_DSN": "https://your-sentry-dsn",
"ENV": "production",
})
plugin = SentryPlugin.from_config(app.config)
app.plugins.load_plugin(plugin)
Advanced Usage
User Context
python
def get_user_from_request(request):
return {
"id": request.user.id,
"email": request.user.email,
"username": request.user.username,
}
plugin = SentryPlugin(dsn="...")
plugin.set_user_getter(get_user_from_request)
app.plugins.load_plugin(plugin)
Manual Exception Capture
python
@app.post("/users")
async def create_user(data: CreateUser):
try:
# Some operation
pass
except Exception as e:
app.state.sentry_plugin.capture_exception(e, request)
return {"error": "Failed to create user"}
Adding Breadcrumbs
python
@app.get("/process")
async def process(request):
app.state.sentry_plugin.add_breadcrumb(
"Starting process",
category="process",
level="info",
data={"user_id": 123}
)
# Process...
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flaxon_sentry-0.1.1.tar.gz
(9.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flaxon_sentry-0.1.1.tar.gz.
File metadata
- Download URL: flaxon_sentry-0.1.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06f378fc82beb7710d2cef3f6e98170ce1cd95c3a19b48eebb7d05df8a5ea89a
|
|
| MD5 |
27c302d7e88cfeadd1726012a056f100
|
|
| BLAKE2b-256 |
58e590a4ed878f20f1a11d449604d0a3a0812a6861b681021e838b0eb5c047c3
|
File details
Details for the file flaxon_sentry-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flaxon_sentry-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cda4406f98a29151e8847acd58d8ac5998ffd8538bc9b55c8c6c6c0212c24346
|
|
| MD5 |
9aeab961ce4b4871f36f6690ce5ea325
|
|
| BLAKE2b-256 |
ca8027844509069cbd9e68962e8fc8fa972a370930658c8652068dc981b6c8ab
|