Pure Python, no C extensions. Tested on 3.10, 3.11, 3.12, 3.13. FastAPI, Flask, Django middlewares included. structlog and stdlib-logging transports.
pip install coderadar
# or: poetry add coderadar
# or: uv add coderadar
import os
import coderadar
coderadar.init(
dsn = os.environ["CODERADAR_DSN"],
project = "veritize",
environment = os.environ.get("ENV", "dev"),
release = os.environ.get("RELEASE_SHA"),
sample_rate = 1.0,
traces_sample_rate = 0.2,
debug = False,
before_send = lambda ev: ev,
)
from fastapi import FastAPI
from coderadar.fastapi import CodeRadarMiddleware
app = FastAPI()
app.add_middleware(CodeRadarMiddleware)
# captures unhandled exceptions, attaches request context,
# propagates W3C tracecontext on outbound httpx calls.
from flask import Flask
from coderadar.flask import init_app
app = Flask(__name__)
init_app(app)
# settings.py
MIDDLEWARE = [
"coderadar.django.CodeRadarMiddleware",
# ...rest of your middleware
]
from coderadar import capture_exception, set_user, set_tag, push_scope
set_tag("job", "drift_scan")
try:
run_drift_scan()
except Exception as e:
capture_exception(e)
raise
# Scoped context (thread / task local)
with push_scope() as scope:
scope.set_tag("step", "embed")
do_embedding()
import structlog
from coderadar.structlog import processor
structlog.configure(processors=[
processor(min_level="error"),
structlog.processors.JSONRenderer(),
])
from coderadar.celery import celery_init
celery_init(app) # captures task failures with task_id + args context
before_send strips fields named authorization, cookie, password, token, api_key, secret.httpx internally for outbound shipping; install separately if not present.coderadar.flush(timeout=2.0) blocks for up to 2s while the buffer drains.