InvergeDocs
PythonAPI reference

Telescope integrations

Telescope for Python web frameworks and task queues.

from nexus.telescope import …

Telescope for Python web frameworks and task queues.

  • TelescopeWSGIMiddleware — any WSGI app (Flask, Pyramid, Bottle, Falcon…)
  • TelescopeASGIMiddleware — any ASGI app (FastAPI, Starlette, Quart, Litestar…)
  • DjangoTelescopeMiddleware — Django (plus ORM queries and model signals)
  • instrument_flask — names Flask routes and captures their exceptions
  • instrument_celery — Celery tasks as jobs that join the dispatching trace
SymbolKindSummary
TelescopeWSGIMiddlewareclassapp.wsgi_app = TelescopeWSGIMiddleware(app.wsgi_app, telescope).
TelescopeASGIMiddlewareclassapp.add_middleware(TelescopeASGIMiddleware) (FastAPI/Starlette) or app = TelescopeASGIMiddleware(app).
DjangoTelescopeMiddlewareclassAdd "nexus.telescope.integrations.DjangoTelescopeMiddleware" FIRST in MIDDLEWARE.
instrument_flask()functioninstrument_flask(app): wraps app.wsgi_app and adds route names, the parsed body, the user (flask-login) and exception capture.
instrument_celery()functionCelery tasks as Telescope jobs.

TelescopeWSGIMiddleware

class

app.wsgi_app = TelescopeWSGIMiddleware(app.wsgi_app, telescope).

View source

TelescopeWSGIMiddleware

constructor
TelescopeWSGIMiddleware(app, telescope=None)

Parameters

Prop

Type

View source

TelescopeASGIMiddleware

class

app.add_middleware(TelescopeASGIMiddleware) (FastAPI/Starlette) or app = TelescopeASGIMiddleware(app).

View source

TelescopeASGIMiddleware

constructor
TelescopeASGIMiddleware(app, telescope=None)

Parameters

Prop

Type

View source

DjangoTelescopeMiddleware

class

Add "nexus.telescope.integrations.DjangoTelescopeMiddleware" FIRST in MIDDLEWARE. Records the request, every ORM query (with N+1 detection), model saves/deletes, exceptions and logs. Configure with NEXUS = {...} in settings (TELESCOPE sub-dict for Telescope options).

View source

DjangoTelescopeMiddleware

constructor
DjangoTelescopeMiddleware(get_response)

Parameters

Prop

Type

View source

process_exception()

method
def process_exception(request, exception) -> None

Parameters

Prop

Type

View source

Functions

instrument_flask()

function
def instrument_flask(app, telescope=None) -> Any

instrument_flask(app): wraps app.wsgi_app and adds route names, the parsed body, the user (flask-login) and exception capture.

Parameters

Prop

Type

Returns Any

View source

instrument_celery()

function
def instrument_celery(telescope=None) -> None

Celery tasks as Telescope jobs. Call once, e.g. in your celery.py.

Publishing a task records a job entry in the current journey and puts a traceparent in the message headers; the worker's run joins that trace.

Parameters

Prop

Type

View source

On this page