Aviary

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(); // unsubscribe
  • traceId comes from the registered context accessor (@dudousxd/nestjs-context wires it). Official publishers call subscribers synchronously in the caller's async context, so this is the request's traceId.
  • durationMs is copied from the payload when the payload has a numeric one, for example workflows' step-completed.
  • source: 'nestjs' tells these events apart from emit() envelopes, which have no source.
  • An exception thrown by your listener never reaches the official publisher.
  • It throws a TypeError on an unknown lib, an unknown type, or an empty types array. 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.

PackageConstantChannels
@nestjs/resilience 0.0.3NESTJS_RESILIENCE_CHANNELSretry, timeout, circuit-open, circuit-half-open, circuit-closed, circuit-rejected, bulkhead-rejected, rate-limited, fallback
@nestjs/workflows 0.0.5NESTJS_WORKFLOWS_CHANNELS19 workflow-*, step-*, child-started, signal-*, journal-large, custom-status, schedule-skipped
@nestjs/authentication 0.1.5NESTJS_AUTHENTICATION_CHANNELS13: 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.3NESTJS_AUTHORIZATION_CHANNELSdenied
@nestjs/mail 0.0.2NESTJS_MAIL_CHANNELSsent, failed

These channels are not added to the aviary:* registry (registeredChannels / onChannelRegistered). Their lists are fixed, so subscribe to them explicitly.

On this page