First-party channels
Record the official NestJS packages' nestjs:* events next to Aviary's, with the same envelope and traceId.
The official NestJS packages publish their own events on node:diagnostics_channel with the convention nestjs:<lib>:<type>. Each one is a raw payload, with no envelope and no traceId. See docs.nestjs.com for each package's events.
nestjs:* is the first-party convention. Aviary never publishes on nestjs:*. aviary:<lib>:<event> is only for what the official packages don't emit.
subscribeOfficial
Aviary's addition is a subscriber that wraps each official payload in the Aviary envelope. That way a consumer, such as an OTel exporter, can record both kinds the same way. Telescope's DiagnosticWatcher only subscribes aviary:* channels; Telescope records nestjs:* through @dudousxd/nestjs-telescope-official.
import { subscribeOfficial } from '@dudousxd/nestjs-diagnostics';
const off = subscribeOfficial('resilience', ['retry', 'circuit-open'], (event, channel) => {
// channel: 'nestjs:resilience:retry'
// event: { v, ts, lib: 'resilience', event: 'retry', traceId, payload, source: 'nestjs' }
});
subscribeOfficial('authentication', 'all', record);
off(); // unsubscribetraceIdcomes from the registered context accessor (@dudousxd/nestjs-contextwires it). Official publishers call subscribers synchronously in the caller's async context, so this is the request's traceId.durationMsis copied from the payload when the payload has a numeric one, for example workflows'step-completed.source: 'nestjs'tells these events apart fromemit()envelopes, which have nosource.- An exception thrown by your listener never reaches the official publisher.
- It throws a
TypeErroron an unknown lib, an unknown type, or an emptytypesarray. Use'all'for every channel. - Duplicate types are ignored. Calling the returned unsubscribe twice is safe.
Pinned channel lists
All five lists live in one file and are exported per lib. Each was read from the published tarball of the version in OFFICIAL_PACKAGE_VERSIONS. A test re-reads the installed packages and fails if a channel is added, renamed or removed.
| Package | Constant | Channels |
|---|---|---|
@nestjs/resilience 0.0.3 | NESTJS_RESILIENCE_CHANNELS | retry, timeout, circuit-open, circuit-half-open, circuit-closed, circuit-rejected, bulkhead-rejected, rate-limited, fallback |
@nestjs/workflows 0.0.5 | NESTJS_WORKFLOWS_CHANNELS | 19 workflow-*, step-*, child-started, signal-*, journal-large, custom-status, schedule-skipped |
@nestjs/authentication 0.1.5 | NESTJS_AUTHENTICATION_CHANNELS | 13: sign-in, sign-out, mfa-*, recovery-codes-generated, refresh-token-reused, password-reset*, email-verified, magic-link-refused, session-touch-failed |
@nestjs/authorization 0.1.3 | NESTJS_AUTHORIZATION_CHANNELS | denied |
@nestjs/mail 0.0.2 | NESTJS_MAIL_CHANNELS | sent, failed |
These channels are not added to the aviary:* registry (registeredChannels / onChannelRegistered). Their lists are fixed, so subscribe to them explicitly.