Python

Python SDK

Tindra uses the official Sentry Python SDK. No Tindra-specific package required. Works with Django, Flask, FastAPI, and plain Python.

Installation

pip install sentry-sdk

Setup

import sentry_sdk

sentry_sdk.init(
    dsn="https://your-key@your-hostname.tindra.sh/1",
    environment="production",
    release="1.4.2",
    traces_sample_rate=0.1,
)

Framework integrations

The SDK includes integrations for common Python frameworks. Pass them in integrations=[].

Django

pip install sentry-sdk[django]
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
    dsn="...",
    integrations=[DjangoIntegration()],
    traces_sample_rate=0.1,
    send_default_pii=True,
)

Flask

pip install sentry-sdk[flask]
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration

sentry_sdk.init(
    dsn="...",
    integrations=[FlaskIntegration()],
    traces_sample_rate=0.1,
)

FastAPI

pip install sentry-sdk[fastapi]
import sentry_sdk
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.starlette import StarletteIntegration

sentry_sdk.init(
    dsn="...",
    integrations=[StarletteIntegration(), FastApiIntegration()],
    traces_sample_rate=0.1,
)

Manual error capturing

try:
    process_order(order)
except Exception as e:
    sentry_sdk.capture_exception(e)
    raise

Capture a message

sentry_sdk.capture_message("User exceeded quota", level="warning")

User context

Use a stable application ID to follow the same user across errors, logs, and traces. Email is optional; keep the identity consistent between related applications.

sentry_sdk.set_user({"id": str(user.id)})

Clear on logout or when this context no longer belongs to the user:

sentry_sdk.set_user(None)

Set context inside the current request or job scope so concurrent work cannot inherit another user. See the Python SDK user-context API.

Custom spans

with sentry_sdk.start_span(op="db.query", description="Fetch user orders"):
    orders = db.execute("SELECT * FROM orders WHERE user_id = %s", (user_id,))

Profiling

Continuous profiling, from SDK 2.24.1. The profiler runs whenever a span is active:

sentry_sdk.init(
    dsn="https://your-key@your-hostname.tindra.sh/1",
    traces_sample_rate=0.1,
    profile_session_sample_rate=1.0,
    profile_lifecycle="trace",
)

Transaction profiling, from SDK 1.18.0, if you are on an older SDK:

sentry_sdk.init(
    dsn="https://your-key@your-hostname.tindra.sh/1",
    traces_sample_rate=0.1,
    profiles_sample_rate=1.0,
)

Tindra accepts both. See Profiling.

Testing

sentry_sdk.capture_exception(Exception("Hello Tindra"))

Check your dashboard. The event should appear within a few seconds.

Verify project setup

After configuring the SDK, open Check setup for your project in Settings > Projects. Start a fresh check and capture an exception with the displayed tindra_setup tag, then wait for confirmed storage. The Project Setup guide covers generated browser/Node.js snippets, other SDKs, missing data, and optional transaction, profile, and source-map checks.