variable OBSERVED_CHANNEL_NAME

Name of the diagnostics_channel that observed publishes to on Node and Deno. Messages are { error: Failure.Any }. This is what a tracing adapter subscribes to — e.g. OpenTelemetry, in its entirety:

import * as Failure from './failure.ts';
import diagnostics_channel from 'node:diagnostics_channel';

// Defined, not invoked: the adapter an application imports once at boot.
function installOtelAdapter(getActiveSpan: () => { recordException(e: Error): void; setAttributes(a: object): void } | undefined) {
  diagnostics_channel.subscribe(Failure.OBSERVED_CHANNEL_NAME, (message) => {
    const { error } = message as { error: Failure.Any };
    const span = getActiveSpan(); // resolves via AsyncLocalStorage — the right span, free
    span?.recordException(error);
    span?.setAttributes(Failure.attributes(error));
  });
}

Type

"qunitx.failure.observed"

Usage

import { OBSERVED_CHANNEL_NAME } from "lib/result/failure.ts";