InvergeDocs
PythonAPI reference

Telescope

Nexus Telescope — request journeys for Python.

import nexus.telescope as telescope

Nexus Telescope — request journeys for Python.

import nexus.telescope as telescope

telescope.init(api_key="nxs_live_xxx", service="orders-api")

Then add the integration for your framework:

  • Django: "nexus.telescope.integrations.DjangoTelescopeMiddleware" first in MIDDLEWARE
  • FastAPI / Starlette: app.add_middleware(TelescopeASGIMiddleware)
  • Flask: instrument_flask(app)
  • Any WSGI / ASGI app: TelescopeWSGIMiddleware / TelescopeASGIMiddleware
  • Celery: instrument_celery()

init() also instruments requests, httpx (sync + async, with a W3C traceparent so downstream services join the trace), SQLAlchemy, redis-py and the logging module. Everything is best-effort and never raises into your app. Exceptions and log lines are also forwarded by Nexus to Errors and Logs.

SymbolKindSummary
TelescopeclassThe public Telescope API (one per process — see init).
init()functionCreate (once) the process-wide Telescope.
get()functionThe Telescope created by init, if any.

Telescope

class

The public Telescope API (one per process — see init).

View source

Telescope

constructor
Telescope(recorder)

Parameters

Prop

Type

View source

job()

method
def job(name, **kw)

with telescope.job("send_invoice", carrier=payload): — joins the trace in carrier.

Parameters

Prop

Type

View source

command()

method
def command(name, **content)

Parameters

Prop

Type

View source

schedule()

method
def schedule(name, expression=None)

Parameters

Prop

Type

View source

inject()

method
def inject(job_name=None, queue=None) -> Dict[str, str]

Fields to merge into a job payload so its run joins this trace; records the dispatch.

Parameters

Prop

Type

Returns Dict[str, str]

View source

span()

method
def span(name, **content)

with telescope.span("pricing"): — entries inside nest under it.

Parameters

Prop

Type

View source

traced()

method
def traced(name=None) -> Callable[[Callable[..., T]], Callable[..., T]]

Decorator form of span (sync and async functions).

Parameters

Prop

Type

Returns Callable[[Callable[..., T]], Callable[..., T]]

View source

record()

method
def record(kind, content, **opts) -> Optional[str]

Parameters

Prop

Type

Returns Optional[str]

View source

query()

method
def query(sql, bindings=None, duration_ms=None, connection=None) -> None

Parameters

Prop

Type

View source

event()

method
def event(name, payload=None) -> None

Parameters

Prop

Type

View source

cache()

method
def cache(action, key, value=None) -> None

Parameters

Prop

Type

View source

log()

method
def log(level, message, **context) -> None

Parameters

Prop

Type

View source

exception()

method
def exception(exc, handled=True, **context) -> None

Parameters

Prop

Type

View source

user()

method
def user(id, **fields) -> None

The signed-in user: tags the journey Auth:<id> and links it to Nexus Sessions.

Parameters

Prop

Type

View source

tag()

method
def tag(*tags) -> None

Parameters

Prop

Type

View source

traceparent()

method
def traceparent() -> Optional[str]

Returns Optional[str]

View source

flush()

method
def flush(timeout=None) -> None

Parameters

Prop

Type

View source

Functions

init()

function
def init(client=None, *, api_key=None, base_url=None, instrument=True, **options) -> Telescope

Create (once) the process-wide Telescope. Options: service, release, sample_rate, ignore_paths, ignore_types, redact_keys, capture_bodies, body_size_limit, max_entries, enabled.

Parameters

Prop

Type

Returns Telescope

View source

get()

function
def get() -> Optional[Telescope]

The Telescope created by init, if any.

Returns Optional[Telescope]

View source

On this page