Aviary
Packages

@dudousxd/nestjs-telescope (core)

The core module — request + exception watchers, the recorder, ALS correlation, the zero-config SQLite store, the headless API, the gate, and the pruner.

pnpm add @dudousxd/nestjs-telescope

Core is everything you need to start capturing: it wires request and exception watchers automatically, turns on a zero-config SQLite store and pruner, and exposes the headless API. Import the module and you're recording — no adapter required.

import { TelescopeModule } from '@dudousxd/nestjs-telescope';

@Module({
  imports: [
    TelescopeModule.forRoot({
      prune: { after: '24h' },
      // Required in production (else every console request answers 403):
      // authorize: (ctx) => ctx.switchToHttp().getRequest().user?.isAdmin === true,
    }),
  ],
})
export class AppModule {}

Hit GET /telescope/api/entries (or /telescope/api/entries/:id for a request and everything it caused).

Built-in watchers

ExportCaptures
request watcherEvery HTTP request (wired automatically) — opens the batch.
exception watcherEvery thrown exception (wired automatically).
HttpClientWatcherOutbound fetch calls, correlated to the request/job. Optionally also axios / @nestjs/axios. Sanitizes credentials and secret query params; no peer dependency.
import { TelescopeModule, HttpClientWatcher } from '@dudousxd/nestjs-telescope';

TelescopeModule.forRoot({ watchers: [new HttpClientWatcher({ slowMs: 1000 })] });

HttpClientWatcher + axios / @nestjs/axios

fetch is patched out of the box, but NestJS apps mostly call out through @nestjs/axios's HttpService — and in Node, axios uses the http adapter, not fetch, so those calls are invisible to the fetch patch. Pass an axios source to capture them too, via axios's public interceptor API (no monkey-patching). Both paths share the same content shape, tags, and family-hash, so axios and fetch entries are indistinguishable in the dashboard.

@nestjs/axios — resolve HttpService lazily. HttpService isn't constructed until the container is up, so use the custom-source instrument hook to grab axiosRef at register time from ctx.moduleRef:

import { TelescopeModule, HttpClientWatcher } from '@dudousxd/nestjs-telescope';
import { HttpService } from '@nestjs/axios';

TelescopeModule.forRoot({
  watchers: [
    new HttpClientWatcher({
      slowMs: 1000,
      axios: {
        instrument(attach, ctx) {
          const http = ctx.moduleRef.get(HttpService, { strict: false });
          attach(http.axiosRef); // wire interceptors onto the real instance
        },
      },
    }),
  ],
});

Plain axios instance — hand it over directly:

import axios from 'axios';
import { TelescopeModule, HttpClientWatcher } from '@dudousxd/nestjs-telescope';

const client = axios.create({ baseURL: 'https://api.example.com' });

TelescopeModule.forRoot({ watchers: [new HttpClientWatcher({ axios: client })] });

On a non-2xx response the entry records error.response.status; on a transport failure (no response) it records statusCode: null (tagged failed). Either way the rejection is re-thrown, so your error handling is untouched. Instrumentation is idempotent per axios instance, so sharing one instance across watchers never double-records.

Double-capture edge case: if you explicitly configure axios with the fetch adapter (Node's default is the http adapter), a single call could record on both the axios and fetch paths. Keep the http adapter, or pass only one source.

Headless API

Method & pathReturns
GET /telescope/api/entriesEntries, newest first, as a cursor list { data, meta: { nextCursor, prevCursor, hasNext, hasPrev }, partial? }. Filters filter[type], filter[tag], filter[batchId], filter[familyHash], filter[traceId], plus search; pages with after=<meta.nextCursor> and first (default 50, max 500).
GET /telescope/api/entries/:idOne entry plus its correlated batch.
GET /telescope/api/pulse?window=1hPer-type counts, slowest entries, top exceptions, N+1 occurrences, the slowest background work (slowWork: queue jobs and durable steps by p95, with the slowJobs card). cards=slowest,nPlusOne,… computes only those cards (the others come back empty, and the reads they need are skipped); buckets=60 adds timeseries (the same report as /timeseries) from the read that counts the window.
GET /telescope/api/queues?window=1hPer-queue throughput, runtime/wait-time percentiles, failure rate.
GET /telescope/api/timeseries?window=1h&buckets=60Bucketed throughput — the sparkline data.
GET /telescope/api/tags?search=sloTag counts, most used first, as a cursor list (filter[tag][startsWith]=user:, search, after / first).
GET /telescope/api/traces?window=1h&size=50&after=The window's traces, most recently active first, a page at a time: { data, scanned, truncated, nextCursor, hasNext }; pass nextCursor as after for the next page.
GET /telescope/api/healthTelescope's own self-overhead (capture cost, buffer, flush, drops).

Key options

OptionDescription
enabledMaster switch. Compute inline (e.g. NODE_ENV !== 'production').
storageStorageProvider (or factory). Defaults to the embedded SQLite store.
watchersBuilt-in + custom watchers; each individually configurable.
authorizeWho may use the console (API, live feed, and its tools on the dev MCP endpoint): a function, an @Injectable() class, a lazy import, { policy, ability } or a gate name. Omitted: open outside production, 403 in production — see Protecting the routes.
decoratorsClass decorators for the mounted console controllers, run before authorize (e.g. [UseGuards(AuthenticationGuard)]).
routesfalse mounts no controller, so you serve the routes from your own subclasses of the exported controllers.
mutationstrue turns on queue actions, prune, replay and profiling-arm (off: 403).
importsExtra imports for whatever your decorators need.
redactDeep-redact configured headers / query / body paths (default sensitive keys always run).
pruneRetention window driving the scheduled pruner (e.g. { after: '24h' }). Supports perType for per-type cutoffs (e.g. { after: '5m', perType: { exception: '7d' } }).
archiveExport a type's entries to a sink before the pruner deletes them — see Archiving before prune.
pulseHealth-snapshot tuning. slowRouteMs (default 1000) is the p99 a route must reach to count as a slow-request hotspot — matches the slow tag threshold, so a quiet host shows no false hotspots.
traceContext / traceLinkOpenTelemetry trace stamping + deep-link template — see -otel.
queueManagersLive queue managers — see queue managers.
devToolsServe telescope's telescope_* tools on the Aviary dev MCP endpoint (/mcp/aviary), gated by authorize. On while the routes are mounted. See MCP tools. (5.0 removed mcp, mcpAuthorize and mcpDecorators with the old <path>/api/mcp endpoint.)
overloadProtectionPause capture under event-loop pressure. true (default, 200ms p99), false, or { maxEventLoopLagMs }. See Performance.

Helpers for package authors

Core also exports the pieces its own modules use, for a package that mounts routes or reports AI usage:

ExportWhat it does
dynamicController(base, path, decorators?)Subclasses base, mounts it at path, and applies decorators to the subclass only, so one registration's decorators never leak into another.
applyControllerDecorators(controller, decorators?)Marks controller open to @nestjs/authorization's global guard (as Can.Anyone() would), then applies decorators in order. Call it on a class built for one registration.
UseConsoleAuthorize({ authorize, pages? })Class decorator applying the console's access guard and denial responses to a controller you mount yourself. ConsoleAuthorizeGuard.for(...) returns just the guard.
resolveConsoleAuthorize(authorize, moduleRef)Resolves any authorize form into one (context) => Promise<ConsoleDecision> that never throws.
authorizeByToken({ token })An authorize that allows Authorization: Bearer <token> (constant-time compare).
publishAgentObservation(observation)Feeds an AI-usage or agent-run observation to the same metrics as the aviary:agent:* channels (Prometheus and OTLP). -official's telescopeAiUsage() uses it. Publish each event from one source only, or it counts twice.

See Capture & correlation for the recorder pipeline and the Entry / Watcher / StorageProvider SPIs.

On this page