An open API service indexing awesome lists of open source software.

https://github.com/alexdemure/gadfastsentry

A production-ready sentry configuration module for Python.
https://github.com/alexdemure/gadfastsentry

fastapi-sentry python-sentry sentry

Last synced: 25 days ago
JSON representation

A production-ready sentry configuration module for Python.

Awesome Lists containing this project

README

        



logo


A production-ready sentry configuration module for Python.

---

### Installation

```
pip install gadfastsentry
```

### Usage

```python
import logging

import sentry_sdk
from fastapi import FastAPI
from fastapi import Request
from gadfastsentry import Sentry

Sentry(dsn="***", env="production")

app = FastAPI()

@app.middleware("http")
async def inject_trace(request: Request, call_next):
sentry_sdk.set_extra("trace_id", "12345")
return await call_next(request)

@app.get("/sentry-debug")
async def trigger_error():
try:
division_by_zero = 1 / 0
except Exception as e:
logging.error(str(e), exc_info=True)
```