Telescope
Nexus Telescope — request journeys for Python.
import nexus.telescope as telescopeNexus 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 inMIDDLEWARE - 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.
| Symbol | Kind | Summary |
|---|---|---|
Telescope | class | The public Telescope API (one per process — see init). |
init() | function | Create (once) the process-wide Telescope. |
get() | function | The Telescope created by init, if any. |
Telescope
classThe public Telescope API (one per process — see init).
Telescope
constructorTelescope(recorder)Parameters
Prop
Type
job()
methoddef job(name, **kw)with telescope.job("send_invoice", carrier=payload): — joins the trace in carrier.
Parameters
Prop
Type
command()
methoddef command(name, **content)Parameters
Prop
Type
schedule()
methoddef schedule(name, expression=None)Parameters
Prop
Type
inject()
methoddef 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]
span()
methoddef span(name, **content)with telescope.span("pricing"): — entries inside nest under it.
Parameters
Prop
Type
traced()
methoddef 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]]
record()
methoddef record(kind, content, **opts) -> Optional[str]Parameters
Prop
Type
Returns Optional[str]
query()
methoddef query(sql, bindings=None, duration_ms=None, connection=None) -> NoneParameters
Prop
Type
event()
methoddef event(name, payload=None) -> NoneParameters
Prop
Type
cache()
methoddef cache(action, key, value=None) -> NoneParameters
Prop
Type
log()
methoddef log(level, message, **context) -> NoneParameters
Prop
Type
exception()
methoddef exception(exc, handled=True, **context) -> NoneParameters
Prop
Type
user()
methoddef user(id, **fields) -> NoneThe signed-in user: tags the journey Auth:<id> and links it to Nexus Sessions.
Parameters
Prop
Type
tag()
methoddef tag(*tags) -> NoneParameters
Prop
Type
traceparent()
methoddef traceparent() -> Optional[str]Returns Optional[str]
flush()
methoddef flush(timeout=None) -> NoneParameters
Prop
Type
Functions
init()
functiondef init(client=None, *, api_key=None, base_url=None, instrument=True, **options) -> TelescopeCreate (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
get()
functiondef get() -> Optional[Telescope]The Telescope created by init, if any.
Returns Optional[Telescope]
