Skip to main content

insider-python

The Python SDK for Insider.

Beam Beacons from your Python service to your Insider server with a one-line setup. No runtime overhead on your request path. Never raises into your code, no matter what.

Install

pip install insider-python

Your app already provides Django — do not rely on insider-python[django] to install the framework (older releases wrongly pulled django>=4.2 and upgraded host pins). DjangoIntegration imports Django at runtime.

Quick start

Plain Python

import insider

insider.init(
    dsn="https://<beacon_token>@theinsiderinc.com/<project_uuid>",
    environment="production",
    release="1.2.3",
)

try:
    risky()
except Exception as exc:
    insider.capture_exception(exc)

Out-of-band events (background jobs, explicit calls) use standalone beacons: capture_exception, capture_log, capture_perf.

Django

Initialize in wsgi.py or asgi.py before get_wsgi_application() / get_asgi_application():

WSGI (Gunicorn)

import os
import insider
from insider.integrations.django import DjangoIntegration
from insider.integrations.logging import LoggingIntegration

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

insider.init(
    dsn=os.environ.get("INSIDER_DSN"),
    environment="production",
    release="1.2.3",
    enable_logs=True,
    integrations=[DjangoIntegration(), LoggingIntegration()],
)

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

ASGI (Daphne / Uvicorn — plain Django)

import os
import insider
from insider.integrations.django import DjangoIntegration
from insider.integrations.logging import LoggingIntegration

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

insider.init(
    dsn=os.environ.get("INSIDER_DSN"),
    environment="production",
    release="1.2.3",
    enable_logs=True,
    integrations=[DjangoIntegration(), LoggingIntegration()],
)

from django.core.asgi import get_asgi_application
application = get_asgi_application()

ASGI + Channels (ProtocolTypeRouter)

Wrap only the HTTP branch; disable handler auto-perf to avoid double capture:

import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

import django

django.setup()

import insider
from insider.integrations.django import DjangoIntegration
from insider.integrations.django.asgi import wrap_asgi_application
from insider.integrations.logging import LoggingIntegration

insider.init(
    dsn=os.environ.get("INSIDER_DSN"),
    environment="production",
    enable_logs=True,
    integrations=[DjangoIntegration(auto_perf=False), LoggingIntegration()],
)

from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application

application = ProtocolTypeRouter({
    "http": wrap_asgi_application(get_asgi_application()),
    "websocket": URLRouter(websocket_urlpatterns),
})

FastAPI

Same idea: pass FastAPIIntegration() to init before the process starts serving. No middleware.

import os
import insider
from insider.integrations.fastapi import FastAPIIntegration
from insider.integrations.logging import LoggingIntegration

insider.init(
    dsn=os.environ.get("INSIDER_DSN"),
    environment="production",
    release="1.2.3",
    enable_logs=True,
    integrations=[FastAPIIntegration(), LoggingIntegration()],
)

from fastapi import FastAPI

app = FastAPI()

Every HTTP request emits one flat footprint (timing, request context, stdlib logs when enable_logs=True, and the unhandled exception when the request fails). WebSocket and lifespan traffic is ignored.

Turn auto-capture off until you want it:

integrations=[FastAPIIntegration(auto_perf=False)]

pip install insider-python is enough. Do not rely on an extra to install FastAPI — the host app already pins it. FastAPIIntegration imports FastAPI at runtime.

Set INSIDER_DEBUG=true to print which hooks installed at startup.

LoggingIntegration stays attached when Django later applies settings.LOGGING via dictConfig — you do not re-init or re-attach handlers after get_wsgi_application().

That's the whole setup. Every HTTP request emits one kind=request beacon containing:

  • timing (duration, method, path, status)
  • request context (headers, path, query string)
  • stdlib logs during that request (when enable_logs=True)
  • unhandled exception + stack trace (when the request fails)

No middleware, no INSTALLED_APPS, and no EXCEPTION_HANDLER wiring.

Disable auto capture on high-traffic apps until sampling lands:

integrations=[DjangoIntegration(auto_perf=False)]

Logging

During an HTTP request, stdlib logging lines are buffered into the request envelope — not beamed as separate rows:

import logging

logger = logging.getLogger(__name__)
logger.info("checkout completed")  # → payload.logs[] on the request beacon

Requires enable_logs=True, LoggingIntegration(), and a configured logger level (see your app's LOGGING settings).

LoggingIntegration accepts two optional thresholds:

from insider.integrations.logging import LoggingIntegration

LoggingIntegration(
    logs_level=logging.INFO,        # minimum level beamed as standalone log beacon
    breadcrumb_level=logging.DEBUG, # minimum level recorded as a breadcrumb
)

breadcrumb_level defaults to DEBUG; logs_level defaults to INFO. Breadcrumbs are attached to capture_exception payloads automatically.

Outside an HTTP request, stdlib logs still beam as standalone kind=log beacons. For explicit structured events, use capture_log():

insider.capture_log(
    "User checkout completed",
    level="info",
    source="checkout.service",
    tags={"feature": "checkout"},
)

Manual perf timings (Celery, custom spans):

insider.capture_perf(
    op="celery.tasks.send_email",
    duration_ms=842,
)

Footprint kinds

Kind When
request One per HTTP request (DjangoIntegration)
error Manual capture_exception() outside request cycle
log Manual capture_log() or stdlib logs outside request cycle
perf Manual capture_perf() for non-HTTP timings

Configuration

If no DSN is found anywhere, the SDK enters disabled mode: every public call is a no-op.

Option Default Notes
dsn env INSIDER_DSN If absent, SDK is disabled
environment "production" Top-level Footprint field
release None Top-level Footprint field
enable_logs False Buffer stdlib logs into request envelopes
send_default_pii False Required to capture request/response bodies
ignore_paths [] Skip footprints for these path prefixes
ignore_builtin_paths True When False, capture /static/, /media/, /favicon.ico
scrub_defaults False Opt in to built-in sensitive-key deny-list
scrub_keys [] Extra key names to redact in bodies
scrub None Advanced dict — see Privacy section below
header_policy "allowlist" "all" captures all; "none" captures no headers
in_app_include [] Module prefixes marked in_app=True in stack frames
before_send None Callable (payload) -> payload | None; return None to drop
transport_queue_size 1000 Drop beacons when queue is full
transport_flush_timeout 2.0 Seconds; used by flush()
debug False Print SDK warnings to stderr

Privacy

Production apps typically add path ignores and keep bodies off:

insider.init(
    dsn=os.environ["INSIDER_DSN"],
    ignore_paths=["/health/", "/metrics/"],
    send_default_pii=False,
)

When capturing bodies (send_default_pii=True), enable scrubbing:

insider.init(
    dsn=os.environ["INSIDER_DSN"],
    send_default_pii=True,
    scrub_defaults=True,
    scrub_keys=["pin", "account_number"],
)

For full control over what gets scrubbed, use the scrub dict — it overrides all shorthand scrub params:

insider.init(
    dsn=os.environ["INSIDER_DSN"],
    send_default_pii=True,
    scrub={
        "defaults": True,               # enable built-in deny-list
        "body_keys": ["pin", "dob"],     # additional body key redactions
        "header_names": ["x-internal"],  # additional header redactions
    },
)

Matched body keys are replaced with the literal string "[Filtered]".

With enable_logs=True (LoggingIntegration), stdlib log lines are attached as system_logs. Scrubbing applies to dict keys in structured log entries, not to free-form log message text — avoid logging secrets in logger.info("password=%s", ...) even when scrub is enabled.

See security-compliance.md for advanced options (scrub={...}, header_policy, before_send).

Integrators deploying in Docker: see sdk-integration-notes.md for release / GIT_SHA setup.

Promise

The SDK never raises into your code.

License

MIT

Metadata

Release files for insider-python 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insider-python 0.2.0
File Size Uploaded Provenance Actions
insider_python-0.2.0.tar.gz 54.8 kB Without provenance Details for insider_python-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for insider-python 0.2.0
File Interpreter ABI Platform Actions
insider_python-0.2.0-py3-none-any.whl Python 3 none any Details for insider_python-0.2.0-py3-none-any.whl

Total release size: 106.3 kB

Release files / insider_python-0.2.0.tar.gz

Download URL insider_python-0.2.0.tar.gz
Size 54.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6189e1e2d8b347c9f3b9fd6c4cffc5ca2818e286bfae11ff3c53b4cd3ef5aa92
BLAKE2b-256 checksum
How to use checksums
d7ebb1af9745b8fe34848451ea44534bf6c5a215b12ff645e2154b173dc9bc32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / insider_python-0.2.0-py3-none-any.whl

Download URL insider_python-0.2.0-py3-none-any.whl
Size 51.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77e378f37d2e46805a465a2a85511214a12cf38df9f35a73907962e747c2add1
BLAKE2b-256 checksum
How to use checksums
8c6f6423324f6be48b1519f4fadb8286ae68d0d42bc4566322bd9fda673ef31b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for insider-python 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page