Signals
Reference for defineSignal, which declares a typed event that an adapter publishes to DSUI's event log for people and plugins to read.
On this page
A signal is a typed event about a service, such as a failed query or a finished DAG run. Your adapter publishes signals from jobs and actions. DSUI stores them in an event log that people, scripts, and plugins can read.
Define a signal#
A signal has a kebab-case id, a type, and a Zod schema for its payload. The type is info, success, warning, or error.
import { defineSignal, z } from "@northgraindata/dsui-adapter-sdk";
export const queryFailed = defineSignal({
id: "query-failed",
type: "error",
schema: z.object({
operation: z.string(),
durationMs: z.number().int().nonnegative(),
errorCode: z.string().optional(),
}),
});List the signal in signals of defineAdapter. DSUI rejects an emission of a signal that the adapter didn’t declare.
Emit a signal#
Call emit from a job or an action:
ctx.emit(queryFailed, { operation: "select", durationMs: 42 }, {
idempotencyKey: runId,
});The payload must match the schema. An idempotencyKey makes the emission safe to repeat. DSUI records one event for a key, ignores a repeat with the same data, and reports an error when the key is reused with different data.
Where signals go#
DSUI adds the signal to its event log with these values:
signalId:<adapter id>.<signal id>, such aspostgresql.query-failedtype: the type that you declaredsourceTypeandsourceId:adapterand the ID of the service that emitted itpayloadandoccurredAt: your data and the time
Anyone who can inspect the installation can read the log. See HTTP API. A plugin can start a job when a signal arrives, by listing the signalId in the job’s onSignals. See Plugin SDK jobs.
Choose what to put in a payload#
Put in the facts that someone needs to decide what to do, such as the operation, the duration, and an error code. Leave out credentials, query text, and personal data, because the event log is readable by everyone who can inspect the installation.