Skip to main content

Python SDK for Insider — ship Beacons to your Insider server.

Project description

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

For the Django integration:

pip install "insider-python[django]"

Quick start

Plain Python

import insider

insider.init(
    dsn="https://<beacon_token>@insider.example.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),
})

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

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).

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 bodies
debug False Print SDK warnings to stderr

Promise

The SDK never raises into your code.

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

insider_python-0.1.8.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

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

insider_python-0.1.8-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file insider_python-0.1.8.tar.gz.

File metadata

  • Download URL: insider_python-0.1.8.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for insider_python-0.1.8.tar.gz
Algorithm Hash digest
SHA256 90243fb4e9ff779e4c8630b55220c561ab7b51d607826213b0896ba8a4c0a457
MD5 ff64abd6533c17c6620909fb7932d746
BLAKE2b-256 f84f54e18a959442de8b42e2516952d6060c19e70afca5d32889c66012cb7762

See more details on using hashes here.

File details

Details for the file insider_python-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: insider_python-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for insider_python-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5e811794e00ba3d71a6e37f3647c65989187419fff5040069b09d6987f702da5
MD5 33335dbfcf270b1b2fad8cd9e02bf6f2
BLAKE2b-256 12116b76cfe63581d4d8d559661d04af2a1b7b1a350e0616edbfdc129643c899

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