InvergeDocs
Telescope

Telescope for Python

Django, Flask, FastAPI / Starlette, Celery and any WSGI or ASGI app — with requests, httpx, SQLAlchemy, redis-py and logging instrumented.

Install & init

pip install inverge-nexus
import nexus.telescope as telescope

telescope.init(api_key=os.environ["NEXUS_API_KEY"], service="orders-api")

init() also instruments requests and httpx (sync and async, adding a traceparent), SQLAlchemy, redis-py and the logging module. Pass instrument=False to skip that, or an existing NexusClient as client=.

Add your framework

settings.py
NEXUS = {"API_KEY": env("NEXUS_API_KEY"), "TELESCOPE": {"SERVICE": "orders-api"}}

MIDDLEWARE = [
    "nexus.telescope.integrations.DjangoTelescopeMiddleware",   # first
    # …
]

ORM queries and model saves are recorded too.

Your own work

tel = telescope.get()

with tel.span("price lookup"):          # nests correctly across await
    quote = pricing.quote(order)

@tel.traced()
def rebuild_index(): ...

with tel.command("reports:daily"):
    run_report()

payload = {"order": 7, **tel.inject("send_invoice", "emails")}   # producer
with tel.job("send_invoice", carrier=payload):                    # worker
    send_invoice(payload)

tel.query("select …", [7], duration_ms=1.2, connection="clickhouse")
tel.user(user.id, email=user.email)
tel.tag("vip")

Context lives on contextvars — correct per thread and per asyncio task.

Options

telescope.init(..., **options):

OptionDefault
serviceNEXUS_SERVICE_NAME
releaseNEXUS_RELEASE, else the client's release
sample_rateNEXUS_TELESCOPE_SAMPLE_RATE, else the console's
ignore_paths/health*, /healthz, /favicon.ico, /static/*
ignore_types, redact_keys—
capture_bodies, body_size_limitTrue, 64 KB
max_entries2000
flush_interval2.0 s
enabledTrue (also NEXUS_TELESCOPE_ENABLED=false)

Delivery runs on a fork-safe background thread; tel.flush() waits for in-flight journeys (call it at the end of scripts).

On this page