Skip to main content

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


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

Uploaded Source

Built Distribution

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

flaxon_sentry-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file flaxon_sentry-0.1.0.tar.gz.

File metadata

  • Download URL: flaxon_sentry-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for flaxon_sentry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb1e3d268711144308323fb5775ee6adc2dfb69668f2cc18f26cd34925feae41
MD5 16cd9632fd2080baff16401574562973
BLAKE2b-256 edf6e87a20fce978629b7b9c1dfd8bdeb1b7f3a19f636211ca56ceb8d623a494

See more details on using hashes here.

File details

Details for the file flaxon_sentry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flaxon_sentry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for flaxon_sentry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c5b566fbd16dd5f622847c43ce18ba905c69fb2501a967889307c55c9bfdc3b
MD5 e356b15519d49485a2292ce86bb365a4
BLAKE2b-256 baf0b4b9ada0be622a0005c397cdb01fcdb29682ea306f3526c8f1bd920ee470

See more details on using hashes here.

Supported by

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