@usearazzo/runner 1.0.1-alpha.34 → 1.0.1-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +6 -1
- package/dist/arazzo-runner.browser.js +687 -317
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +52 -7
- package/src/errors/ExecutionError.cjs +2 -0
- package/src/errors/ExecutionError.mjs +2 -0
- package/src/executor/OpenAPIOperationExecutor.cjs +58 -47
- package/src/executor/OpenAPIOperationExecutor.mjs +58 -47
- package/src/executor/WorkflowExecutor.cjs +302 -160
- package/src/executor/WorkflowExecutor.mjs +302 -160
- package/src/index.cjs +14 -0
- package/src/index.mjs +2 -0
- package/src/observability/EventChannel.cjs +30 -20
- package/src/observability/EventChannel.mjs +30 -23
- package/src/observability/Redactor.cjs +7 -5
- package/src/observability/Redactor.mjs +7 -5
- package/src/observability/combineObservers.cjs +18 -0
- package/src/observability/combineObservers.mjs +12 -0
- package/src/observability/instrument.cjs +159 -0
- package/src/observability/instrument.mjs +144 -0
- package/src/observability/logging/LoggingObserver.cjs +177 -0
- package/src/observability/logging/LoggingObserver.mjs +172 -0
- package/src/observability/logging/index.cjs +13 -0
- package/src/observability/logging/index.mjs +1 -0
- package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.cjs +321 -0
- package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.mjs +313 -0
- package/src/observability/opentelemetry/index.cjs +13 -0
- package/src/observability/opentelemetry/index.mjs +1 -0
- package/src/observability/stream/EventStream.cjs +112 -0
- package/src/observability/stream/EventStream.mjs +107 -0
- package/src/observability/stream/index.cjs +13 -0
- package/src/observability/stream/index.mjs +1 -0
- package/src/registry/DocumentRegistry.cjs +14 -9
- package/src/registry/DocumentRegistry.mjs +14 -9
- package/src/version.cjs +9 -0
- package/src/version.mjs +3 -0
- package/types/observability/logging/LoggingObserver.d.ts +82 -0
- package/types/observability/logging/index.d.ts +2 -0
- package/types/observability/opentelemetry/ArazzoRunnerInstrumentation.d.ts +84 -0
- package/types/observability/opentelemetry/index.d.ts +2 -0
- package/types/observability/stream/EventStream.d.ts +68 -0
- package/types/observability/stream/index.d.ts +2 -0
- package/types/runner.d.ts +131 -34
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Redactor, type ArazzoRunnerEvent, type ArazzoRunnerObserver } from '@usearazzo/runner';
|
|
2
|
+
/**
|
|
3
|
+
* The level a log record is written at. Every common logger has these four.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
7
|
+
/**
|
|
8
|
+
* One log record, made from one event.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface LogRecord {
|
|
12
|
+
readonly level: LogLevel;
|
|
13
|
+
/**
|
|
14
|
+
* A one-line, human-readable summary of the event, e.g.
|
|
15
|
+
* `step placeOrder failed after 2 attempts`.
|
|
16
|
+
*/
|
|
17
|
+
readonly message: string;
|
|
18
|
+
/**
|
|
19
|
+
* The event, masked, as structured fields: its `type`, `runId`, `stepId`,
|
|
20
|
+
* `location` and the rest. The selected action of `action:selected` is
|
|
21
|
+
* given by its `name` and `type`, not as the document's element. The
|
|
22
|
+
* `error` of a settled event that threw is the native `Error`, for the
|
|
23
|
+
* logger to serialize as it is configured to: loggers serialize errors only
|
|
24
|
+
* under their own keys (pino's `err`, winston's top level), so give yours
|
|
25
|
+
* one for `error`, e.g. pino's `serializers: { error: pino.stdSerializers.err }`.
|
|
26
|
+
*/
|
|
27
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Writes one log record to the logger of your choice. Loggers disagree on
|
|
31
|
+
* argument order, so this is where a record is handed over the way yours
|
|
32
|
+
* expects: `logger[level](fields, message)` for pino or bunyan,
|
|
33
|
+
* `logger.log(level, message, fields)` for winston,
|
|
34
|
+
* `console[level](message, fields)` for the console.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export type LogFunction = (record: LogRecord) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Options for {@link loggingObserver}.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface LoggingObserverOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Masks each event before it is logged. A `new Redactor()` with the default
|
|
45
|
+
* field patterns when omitted; there is no way to log unmasked events
|
|
46
|
+
* through this adapter. A settled event's `error` is the exception: it is
|
|
47
|
+
* logged as `execute` rejects with it.
|
|
48
|
+
*/
|
|
49
|
+
readonly redactor?: Redactor;
|
|
50
|
+
/**
|
|
51
|
+
* The level for an event type, replacing the default for every event of
|
|
52
|
+
* that type: `{ 'criterion:evaluated': 'info' }`.
|
|
53
|
+
*/
|
|
54
|
+
readonly levels?: Readonly<Partial<Record<ArazzoRunnerEvent['type'], LogLevel>>>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* An observer that writes every event as a log record through `log`, masked
|
|
58
|
+
* by a `Redactor` first.
|
|
59
|
+
*
|
|
60
|
+
* Events carry no level, so this adapter gives them one: `info` for workflows
|
|
61
|
+
* and steps starting and settling, `warn` for a failed step, `error` for a
|
|
62
|
+
* failed workflow or a step or workflow that threw, and `debug` for
|
|
63
|
+
* attempts, criteria, actions, retries,
|
|
64
|
+
* dependencies, document loads, normalization and requests. A workflow that
|
|
65
|
+
* transferred to another is `info`: the workflow it transferred to reports its
|
|
66
|
+
* own outcome. `levels` overrides it per event type.
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* import pino from 'pino';
|
|
70
|
+
* import { ArazzoRunner } from '@usearazzo/runner';
|
|
71
|
+
* import { loggingObserver } from '@usearazzo/runner/observability/logging';
|
|
72
|
+
*
|
|
73
|
+
* // the error of a step or workflow that threw, serialized as pino does `err`
|
|
74
|
+
* const logger = pino({ serializers: { error: pino.stdSerializers.err } });
|
|
75
|
+
* const runner = await ArazzoRunner.load(uri, {
|
|
76
|
+
* observer: loggingObserver(({ level, message, fields }) => logger[level](fields, message)),
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
declare const loggingObserver: (log: LogFunction, options?: LoggingObserverOptions) => ArazzoRunnerObserver;
|
|
82
|
+
export default loggingObserver;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration of {@link ArazzoRunnerInstrumentation}, OpenTelemetry's
|
|
4
|
+
* `InstrumentationConfig`.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ArazzoRunnerInstrumentationConfig {
|
|
8
|
+
/** Whether it is enabled once constructed. `true` when omitted. */
|
|
9
|
+
readonly enabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Traces every runner in the process with OpenTelemetry, as an OpenTelemetry
|
|
13
|
+
* instrumentation: list it with the others, and no runner needs wiring.
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
17
|
+
* import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
18
|
+
* import { ArazzoRunnerInstrumentation } from '@usearazzo/runner/observability/opentelemetry';
|
|
19
|
+
*
|
|
20
|
+
* new NodeSDK({
|
|
21
|
+
* instrumentations: [getNodeAutoInstrumentations(), new ArazzoRunnerInstrumentation()],
|
|
22
|
+
* }).start();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* In the browser, with the fetch instrumentation for the request spans:
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* import { BatchSpanProcessor, WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
|
29
|
+
* import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
30
|
+
* import { ZoneContextManager } from '@opentelemetry/context-zone';
|
|
31
|
+
* import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
32
|
+
* import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
|
|
33
|
+
* import { ArazzoRunnerInstrumentation } from '@usearazzo/runner/observability/opentelemetry';
|
|
34
|
+
*
|
|
35
|
+
* const provider = new WebTracerProvider({
|
|
36
|
+
* spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter())],
|
|
37
|
+
* });
|
|
38
|
+
* provider.register({ contextManager: new ZoneContextManager() });
|
|
39
|
+
* registerInstrumentations({
|
|
40
|
+
* // propagateTraceHeaderCorsUrls: the cross-origin APIs that get a traceparent
|
|
41
|
+
* instrumentations: [
|
|
42
|
+
* new FetchInstrumentation({ propagateTraceHeaderCorsUrls: [/api\.example\.com/] }),
|
|
43
|
+
* new ArazzoRunnerInstrumentation(),
|
|
44
|
+
* ],
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* Each workflow invocation and each step is an `INTERNAL` span, the step's
|
|
49
|
+
* under its workflow's, a sub-workflow's and a retry reference's under the
|
|
50
|
+
* step that calls them, and a `dependsOn` workflow's or a transfer target's
|
|
51
|
+
* under the workflow that runs them. Attempts, criteria,
|
|
52
|
+
* selected actions, retry waits, retry references and the operations a step
|
|
53
|
+
* calls are events of the step's span, each named by the runner event it
|
|
54
|
+
* comes from (`step:attempt`, `criterion:evaluated`, `action:selected`, …). A step runs in its span's context, so
|
|
55
|
+
* the HTTP instrumentation of the client it sends with (undici for Node's
|
|
56
|
+
* `fetch`, `@opentelemetry/instrumentation-fetch` in the browser) nests its
|
|
57
|
+
* request spans under the step and propagates the trace into the API.
|
|
58
|
+
*
|
|
59
|
+
* In the browser, the workflow and step spans keep their tree with any
|
|
60
|
+
* context manager, but request spans nest under the step only where the
|
|
61
|
+
* context survives an `await`: zone.js loses it across a native one, so
|
|
62
|
+
* transpile `async`/`await` as OpenTelemetry's web instrumentation asks.
|
|
63
|
+
*
|
|
64
|
+
* Spans carry the identifiers and outcomes of the run, not its data: no
|
|
65
|
+
* inputs, outputs, criterion values or requests. A step or workflow that
|
|
66
|
+
* throws records the error, whose message can quote what the run saw.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
declare class ArazzoRunnerInstrumentation {
|
|
70
|
+
#private;
|
|
71
|
+
readonly instrumentationName = "@usearazzo/runner";
|
|
72
|
+
readonly instrumentationVersion: string;
|
|
73
|
+
constructor(config?: ArazzoRunnerInstrumentationConfig);
|
|
74
|
+
/** Starts tracing every runner in the process. */
|
|
75
|
+
enable(): void;
|
|
76
|
+
/** Stops tracing; runs in progress stop at their next workflow or step. */
|
|
77
|
+
disable(): void;
|
|
78
|
+
setTracerProvider(tracerProvider: TracerProvider): void;
|
|
79
|
+
/** Records no metrics. */
|
|
80
|
+
setMeterProvider(): void;
|
|
81
|
+
setConfig(config: ArazzoRunnerInstrumentationConfig): void;
|
|
82
|
+
getConfig(): ArazzoRunnerInstrumentationConfig;
|
|
83
|
+
}
|
|
84
|
+
export default ArazzoRunnerInstrumentation;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Redactor, type ArazzoRunnerEvent, type ArazzoRunnerObserver } from '@usearazzo/runner';
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link eventStream}.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface EventStreamOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Masks each event before it is queued. A `new Redactor()` with the default
|
|
9
|
+
* field patterns when omitted; there is no way to stream unmasked events
|
|
10
|
+
* through this adapter. A settled event's `error` is the exception: it is
|
|
11
|
+
* queued as `execute` rejects with it.
|
|
12
|
+
*/
|
|
13
|
+
readonly redactor?: Redactor;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A run's events as a stream: wire `observer` into the runner, read the
|
|
17
|
+
* events with `for await`, or pipe `stream`, and end it with `close` or
|
|
18
|
+
* `error` once the run settles.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface EventStream extends AsyncIterable<ArazzoRunnerEvent> {
|
|
22
|
+
/**
|
|
23
|
+
* Queues each event, masked. It never waits for the consumer, so a slow
|
|
24
|
+
* consumer cannot hold the run back: events wait in an unbounded queue.
|
|
25
|
+
*/
|
|
26
|
+
readonly observer: ArazzoRunnerObserver;
|
|
27
|
+
/**
|
|
28
|
+
* The events as a WHATWG `ReadableStream`, for piping. It has one consumer:
|
|
29
|
+
* read it or iterate this object, not both. For two consumers, give each
|
|
30
|
+
* an `eventStream()` of its own behind `combineObservers`: a `tee()`d
|
|
31
|
+
* branch loses its unread events when the stream fails.
|
|
32
|
+
*/
|
|
33
|
+
readonly stream: ReadableStream<ArazzoRunnerEvent>;
|
|
34
|
+
/**
|
|
35
|
+
* Ends the stream once the queued events are read. Call it when `execute`
|
|
36
|
+
* resolves; events after it are dropped.
|
|
37
|
+
*/
|
|
38
|
+
close(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Fails the stream once the queued events are read: reading it then rejects
|
|
41
|
+
* with `reason`. Call it when `execute` rejects; events after it are
|
|
42
|
+
* dropped.
|
|
43
|
+
*/
|
|
44
|
+
error(reason: unknown): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Turns a run's events into a stream. The caller ends it: a runner can run
|
|
48
|
+
* many times into one stream, and an `execute` that fails before its
|
|
49
|
+
* workflow starts (an unknown workflow, a document that does not load)
|
|
50
|
+
* emits no workflow event to end it on:
|
|
51
|
+
*
|
|
52
|
+
* ```js
|
|
53
|
+
* import { ArazzoRunner } from '@usearazzo/runner';
|
|
54
|
+
* import { eventStream } from '@usearazzo/runner/observability/stream';
|
|
55
|
+
*
|
|
56
|
+
* const events = eventStream();
|
|
57
|
+
* const runner = await ArazzoRunner.load(uri, { observer: events.observer });
|
|
58
|
+
* runner.execute('authenticateAndOrderPet', options).then(events.close, events.error);
|
|
59
|
+
*
|
|
60
|
+
* for await (const event of events) render(event);
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* A consumer that stops reading early (a `break` out of `for await`, or a
|
|
64
|
+
* cancelled stream) stops the queuing: the run goes on unobserved.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
declare const eventStream: (options?: EventStreamOptions) => EventStream;
|
|
68
|
+
export default eventStream;
|
package/types/runner.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export declare class ActionResolver {
|
|
|
84
84
|
* @public
|
|
85
85
|
*/
|
|
86
86
|
export declare interface ActionSelectedEvent extends WorkflowExecutionStepEventBase {
|
|
87
|
-
readonly type: 'action
|
|
87
|
+
readonly type: 'action:selected';
|
|
88
88
|
/**
|
|
89
89
|
* Where the selected action is written; absent when no action was
|
|
90
90
|
* selected.
|
|
@@ -263,7 +263,7 @@ export declare class ArazzoRunnerError extends ApiDOMStructuredError {
|
|
|
263
263
|
*
|
|
264
264
|
* Events carry no level or severity, like Node's `diagnostics_channel`
|
|
265
265
|
* messages: how to log an event is the logging consumer's decision. The
|
|
266
|
-
* `document
|
|
266
|
+
* `document:*`, `workflow:normalize:*` and `openapi:operation:*` events describe the
|
|
267
267
|
* machinery under a run, the detail a debug log would show.
|
|
268
268
|
* @public
|
|
269
269
|
*/
|
|
@@ -593,6 +593,16 @@ export declare class ClientError extends ArazzoRunnerError {
|
|
|
593
593
|
readonly uri?: string;
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
+
/**
|
|
597
|
+
* One observer that hands each event to every observer given, in order, so
|
|
598
|
+
* several consumers (a log, a trace, a stream) can watch the same run.
|
|
599
|
+
*
|
|
600
|
+
* Delivery stays synchronous. An observer that throws aborts the run with its
|
|
601
|
+
* error, as any observer does, and the observers after it miss that event.
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
export declare const combineObservers: <E extends ArazzoRunnerEvent = ArazzoRunnerEvent>(...observers: readonly ArazzoRunnerObserver<E>[]) => ArazzoRunnerObserver<E>;
|
|
605
|
+
|
|
596
606
|
/**
|
|
597
607
|
* A read-only source of the runtime expression context for a step.
|
|
598
608
|
*
|
|
@@ -687,7 +697,7 @@ export declare type CriterionErrorReason = (typeof CriterionError)[Exclude<keyof
|
|
|
687
697
|
* @public
|
|
688
698
|
*/
|
|
689
699
|
export declare interface CriterionEvaluatedEvent extends WorkflowExecutionStepEventBase {
|
|
690
|
-
readonly type: 'criterion
|
|
700
|
+
readonly type: 'criterion:evaluated';
|
|
691
701
|
/**
|
|
692
702
|
* Where the criterion is written.
|
|
693
703
|
*/
|
|
@@ -739,7 +749,7 @@ export declare interface CriterionEvaluationRecord {
|
|
|
739
749
|
*
|
|
740
750
|
* A whole body (`$response.body`, `$request.body`) is recorded as the
|
|
741
751
|
* placeholder `[body]`, so the trace never holds a body; the body and its
|
|
742
|
-
* size are in the attempt's `openapi
|
|
752
|
+
* size are in the attempt's `openapi:operation:request:settled` event.
|
|
743
753
|
*/
|
|
744
754
|
readonly values: Readonly<Record<string, unknown>>;
|
|
745
755
|
/**
|
|
@@ -878,7 +888,7 @@ export declare type CriterionPredicate = (criterion: CriterionElement, action: S
|
|
|
878
888
|
* @public
|
|
879
889
|
*/
|
|
880
890
|
export declare interface DependencySettledEvent extends WorkflowExecutionEventBase {
|
|
881
|
-
readonly type: 'dependency
|
|
891
|
+
readonly type: 'dependency:settled';
|
|
882
892
|
readonly dependency: WorkflowExecutionDependency;
|
|
883
893
|
/**
|
|
884
894
|
* Whether the prerequisite had already completed earlier in this run and was
|
|
@@ -895,7 +905,7 @@ export declare interface DependencySettledEvent extends WorkflowExecutionEventBa
|
|
|
895
905
|
* @public
|
|
896
906
|
*/
|
|
897
907
|
export declare interface DependencyStartEvent extends WorkflowExecutionEventBase {
|
|
898
|
-
readonly type: 'dependency
|
|
908
|
+
readonly type: 'dependency:start';
|
|
899
909
|
/**
|
|
900
910
|
* Where the `dependsOn` entry is written.
|
|
901
911
|
*/
|
|
@@ -915,7 +925,7 @@ export declare class DocumentLoadError extends ArazzoRunnerError {
|
|
|
915
925
|
* @public
|
|
916
926
|
*/
|
|
917
927
|
export declare interface DocumentLoadSettledEvent extends ArazzoRunnerEventBase {
|
|
918
|
-
readonly type: 'document
|
|
928
|
+
readonly type: 'document:load:settled';
|
|
919
929
|
readonly uri: string;
|
|
920
930
|
}
|
|
921
931
|
|
|
@@ -928,7 +938,7 @@ export declare interface DocumentLoadSettledEvent extends ArazzoRunnerEventBase
|
|
|
928
938
|
* @public
|
|
929
939
|
*/
|
|
930
940
|
export declare interface DocumentLoadStartEvent extends ArazzoRunnerEventBase {
|
|
931
|
-
readonly type: 'document
|
|
941
|
+
readonly type: 'document:load:start';
|
|
932
942
|
/**
|
|
933
943
|
* The canonical URI of the document.
|
|
934
944
|
*/
|
|
@@ -1118,6 +1128,8 @@ export declare class ExecutionError extends ArazzoRunnerError {
|
|
|
1118
1128
|
static readonly GotoTargetMissing: "goto-target-missing";
|
|
1119
1129
|
/** A `goto` action's `stepId` names no step in the workflow. */
|
|
1120
1130
|
static readonly GotoTargetNotFound: "goto-target-not-found";
|
|
1131
|
+
/** A process-wide instrumentation wrap (see `instrument`) settled without running its workflow or step. */
|
|
1132
|
+
static readonly InstrumentationWrap: "instrumentation-wrap";
|
|
1121
1133
|
/** An `operationId` or `operationPath` is not a valid operation reference. */
|
|
1122
1134
|
static readonly InvalidOperationReference: "invalid-operation-reference";
|
|
1123
1135
|
/** A `workflowId` is not a valid `$sourceDescriptions.{name}.{workflowId}` expression. */
|
|
@@ -1219,6 +1231,79 @@ export declare type HTTPClient = (request: OpenAPIOperationRequest) => Promise<R
|
|
|
1219
1231
|
*/
|
|
1220
1232
|
export declare const httpClientFetch: HTTPClient;
|
|
1221
1233
|
|
|
1234
|
+
/**
|
|
1235
|
+
* Applies `hooks` to every runner in the process, until the returned
|
|
1236
|
+
* function removes them: the seam process-wide tooling, such as the
|
|
1237
|
+
* OpenTelemetry instrumentation, is built on. A run already in progress
|
|
1238
|
+
* picks hooks up at its next event or operation, and drops removed ones the
|
|
1239
|
+
* same way: a removed hook misses the settled events of what it saw start.
|
|
1240
|
+
* Hooks apply in the order they were added, the first wrap outermost.
|
|
1241
|
+
* @public
|
|
1242
|
+
*/
|
|
1243
|
+
export declare const instrument: (hooks: InstrumentationHooks) => (() => void);
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Hooks that apply to every runner in the process, on top of the observer
|
|
1247
|
+
* each was given.
|
|
1248
|
+
* @public
|
|
1249
|
+
*/
|
|
1250
|
+
export declare interface InstrumentationHooks {
|
|
1251
|
+
/**
|
|
1252
|
+
* Receives every event of every building block, after the block's own
|
|
1253
|
+
* observer, under the same rules: synchronously, never awaited, and a throw
|
|
1254
|
+
* aborts what emitted it. Events carry what the run saw, credentials
|
|
1255
|
+
* included.
|
|
1256
|
+
*/
|
|
1257
|
+
readonly observer?: ArazzoRunnerObserver;
|
|
1258
|
+
/** Runs around each workflow invocation and each step. */
|
|
1259
|
+
readonly wrap?: InstrumentationWrap;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Runs around each workflow invocation and each step, so what `run` does
|
|
1264
|
+
* happens inside it: in the active context of a span it opened, for one. It
|
|
1265
|
+
* must call `run`, and should settle once `run` settles; a second call runs
|
|
1266
|
+
* nothing again. What it resolves or rejects with does not change the run:
|
|
1267
|
+
* the run's own outcome stands, once the run settled, and the operation's
|
|
1268
|
+
* settled event says what it was.
|
|
1269
|
+
* @public
|
|
1270
|
+
*/
|
|
1271
|
+
export declare type InstrumentationWrap = (operation: InstrumentedOperation, run: () => Promise<void>) => Promise<void>;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* What an {@link InstrumentationWrap} runs around.
|
|
1275
|
+
* @public
|
|
1276
|
+
*/
|
|
1277
|
+
export declare type InstrumentedOperation = InstrumentedWorkflow | InstrumentedStep;
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* A step an {@link InstrumentationWrap} runs around: its `step:start`, its
|
|
1281
|
+
* attempts and requests, and its `step:settled`.
|
|
1282
|
+
* @public
|
|
1283
|
+
*/
|
|
1284
|
+
export declare interface InstrumentedStep {
|
|
1285
|
+
readonly kind: 'step';
|
|
1286
|
+
readonly runId: string;
|
|
1287
|
+
readonly workflowId: string;
|
|
1288
|
+
readonly path: readonly string[];
|
|
1289
|
+
readonly stepId: string;
|
|
1290
|
+
readonly location: DocumentLocation;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* A workflow invocation an {@link InstrumentationWrap} runs around: its
|
|
1295
|
+
* `workflow:start`, its steps and its `workflow:settled`.
|
|
1296
|
+
* @public
|
|
1297
|
+
*/
|
|
1298
|
+
export declare interface InstrumentedWorkflow {
|
|
1299
|
+
readonly kind: 'workflow';
|
|
1300
|
+
readonly runId: string;
|
|
1301
|
+
readonly workflowId: string;
|
|
1302
|
+
readonly path: readonly string[];
|
|
1303
|
+
readonly via: WorkflowCallVia;
|
|
1304
|
+
readonly location: DocumentLocation;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1222
1307
|
/** @public */
|
|
1223
1308
|
export declare class InvalidEntryDocumentError extends ArazzoRunnerError {
|
|
1224
1309
|
readonly uri?: string;
|
|
@@ -1440,7 +1525,7 @@ export declare type OpenAPIDocumentRegistryProviderOptions = DocumentRegistryPro
|
|
|
1440
1525
|
* @public
|
|
1441
1526
|
*/
|
|
1442
1527
|
export declare interface OpenAPIOperationAssembledEvent extends OpenAPIOperationEventBase {
|
|
1443
|
-
readonly type: 'openapi
|
|
1528
|
+
readonly type: 'openapi:operation:assembled';
|
|
1444
1529
|
}
|
|
1445
1530
|
|
|
1446
1531
|
/**
|
|
@@ -1671,7 +1756,7 @@ export declare interface OpenAPIOperationExecutorOptions {
|
|
|
1671
1756
|
*/
|
|
1672
1757
|
readonly now?: () => number;
|
|
1673
1758
|
/**
|
|
1674
|
-
* Whether the `openapi
|
|
1759
|
+
* Whether the `openapi:operation:request:*` events carry the request and
|
|
1675
1760
|
* response bodies. Off by default.
|
|
1676
1761
|
*/
|
|
1677
1762
|
readonly captureBodies?: boolean;
|
|
@@ -1824,7 +1909,7 @@ export declare interface OpenAPIOperationNormalizerOptions {
|
|
|
1824
1909
|
* @public
|
|
1825
1910
|
*/
|
|
1826
1911
|
export declare interface OpenAPIOperationNormalizeSettledEvent extends OpenAPIOperationEventBase {
|
|
1827
|
-
readonly type: 'openapi
|
|
1912
|
+
readonly type: 'openapi:operation:normalize:settled';
|
|
1828
1913
|
}
|
|
1829
1914
|
|
|
1830
1915
|
/**
|
|
@@ -1833,7 +1918,7 @@ export declare interface OpenAPIOperationNormalizeSettledEvent extends OpenAPIOp
|
|
|
1833
1918
|
* @public
|
|
1834
1919
|
*/
|
|
1835
1920
|
export declare interface OpenAPIOperationNormalizeStartEvent extends OpenAPIOperationEventBase {
|
|
1836
|
-
readonly type: 'openapi
|
|
1921
|
+
readonly type: 'openapi:operation:normalize:start';
|
|
1837
1922
|
}
|
|
1838
1923
|
|
|
1839
1924
|
/**
|
|
@@ -1937,7 +2022,7 @@ export declare interface OpenAPIOperationRequestInfo {
|
|
|
1937
2022
|
* @public
|
|
1938
2023
|
*/
|
|
1939
2024
|
export declare interface OpenAPIOperationRequestSettledEvent extends OpenAPIOperationEventBase {
|
|
1940
|
-
readonly type: 'openapi
|
|
2025
|
+
readonly type: 'openapi:operation:request:settled';
|
|
1941
2026
|
readonly response: {
|
|
1942
2027
|
readonly status: number;
|
|
1943
2028
|
readonly headers: Readonly<Record<string, string>>;
|
|
@@ -1961,7 +2046,7 @@ export declare interface OpenAPIOperationRequestSettledEvent extends OpenAPIOper
|
|
|
1961
2046
|
* @public
|
|
1962
2047
|
*/
|
|
1963
2048
|
export declare interface OpenAPIOperationRequestStartEvent extends OpenAPIOperationEventBase {
|
|
1964
|
-
readonly type: 'openapi
|
|
2049
|
+
readonly type: 'openapi:operation:request:start';
|
|
1965
2050
|
readonly request: {
|
|
1966
2051
|
readonly method: string;
|
|
1967
2052
|
readonly url: string;
|
|
@@ -2150,7 +2235,8 @@ export declare class OutputResolver extends ArazzoValueResolver {
|
|
|
2150
2235
|
* - a request or response body that is JSON or a URL-encoded form, field by
|
|
2151
2236
|
* field, and any other body, or any object that is not plain data, whole.
|
|
2152
2237
|
*
|
|
2153
|
-
* A
|
|
2238
|
+
* A settled event's `error` is carried as it is, the error `execute` rejects
|
|
2239
|
+
* with. A credential under a name no pattern matches is carried as it is. The
|
|
2154
2240
|
* masked value is `REDACTED`.
|
|
2155
2241
|
* @public
|
|
2156
2242
|
*/
|
|
@@ -2435,7 +2521,7 @@ export declare interface RetryReferenceRecord {
|
|
|
2435
2521
|
* @public
|
|
2436
2522
|
*/
|
|
2437
2523
|
export declare interface RetryReferenceSettledEvent extends WorkflowExecutionStepEventBase {
|
|
2438
|
-
readonly type: 'retry
|
|
2524
|
+
readonly type: 'retry:reference:settled';
|
|
2439
2525
|
readonly attempt: number;
|
|
2440
2526
|
readonly kind: RetryReferenceRecord['kind'];
|
|
2441
2527
|
readonly id: RetryReferenceRecord['id'];
|
|
@@ -2447,7 +2533,7 @@ export declare interface RetryReferenceSettledEvent extends WorkflowExecutionSte
|
|
|
2447
2533
|
* @public
|
|
2448
2534
|
*/
|
|
2449
2535
|
export declare interface RetryReferenceStartEvent extends WorkflowExecutionStepEventBase {
|
|
2450
|
-
readonly type: 'retry
|
|
2536
|
+
readonly type: 'retry:reference:start';
|
|
2451
2537
|
/**
|
|
2452
2538
|
* Where the `retry` action that names the reference is written.
|
|
2453
2539
|
*/
|
|
@@ -2463,7 +2549,7 @@ export declare interface RetryReferenceStartEvent extends WorkflowExecutionStepE
|
|
|
2463
2549
|
* @public
|
|
2464
2550
|
*/
|
|
2465
2551
|
export declare interface RetryWaitEvent extends WorkflowExecutionStepEventBase {
|
|
2466
|
-
readonly type: 'retry
|
|
2552
|
+
readonly type: 'retry:wait';
|
|
2467
2553
|
readonly attempt: number;
|
|
2468
2554
|
readonly delayMs: number;
|
|
2469
2555
|
}
|
|
@@ -2816,7 +2902,7 @@ export declare abstract class SourceDescriptionsLocatorNormalizer {
|
|
|
2816
2902
|
* @public
|
|
2817
2903
|
*/
|
|
2818
2904
|
export declare interface StepAttemptEvent extends WorkflowExecutionStepEventBase {
|
|
2819
|
-
readonly type: 'step
|
|
2905
|
+
readonly type: 'step:attempt';
|
|
2820
2906
|
/**
|
|
2821
2907
|
* The attempt number, starting at 1. Each `retry` increments it. The
|
|
2822
2908
|
* attempt a `retry` reference makes at another step is that reference's
|
|
@@ -3133,21 +3219,25 @@ export declare interface StepScope {
|
|
|
3133
3219
|
}
|
|
3134
3220
|
|
|
3135
3221
|
/**
|
|
3136
|
-
* A step settled: its retries are done and its terminal action is selected
|
|
3222
|
+
* A step settled: its retries are done and its terminal action is selected,
|
|
3223
|
+
* or it threw. A step that threw is not `successful` and carries the `error`.
|
|
3137
3224
|
* @public
|
|
3138
3225
|
*/
|
|
3139
3226
|
export declare interface StepSettledEvent extends WorkflowExecutionStepEventBase {
|
|
3140
|
-
readonly type: 'step
|
|
3227
|
+
readonly type: 'step:settled';
|
|
3141
3228
|
readonly successful: boolean;
|
|
3229
|
+
/** The attempts made, the one that threw included. */
|
|
3142
3230
|
readonly attempts: number;
|
|
3231
|
+
/** What the step threw, as for {@link WorkflowSettledEvent.error}. */
|
|
3232
|
+
readonly error?: unknown;
|
|
3143
3233
|
}
|
|
3144
3234
|
|
|
3145
3235
|
/**
|
|
3146
|
-
* A step began. Its attempts follow it.
|
|
3236
|
+
* A step began. Its attempts follow it, and its `step:settled` always does.
|
|
3147
3237
|
* @public
|
|
3148
3238
|
*/
|
|
3149
3239
|
export declare interface StepStartEvent extends WorkflowExecutionStepEventBase {
|
|
3150
|
-
readonly type: 'step
|
|
3240
|
+
readonly type: 'step:start';
|
|
3151
3241
|
/**
|
|
3152
3242
|
* Where the step is written.
|
|
3153
3243
|
*/
|
|
@@ -3303,7 +3393,7 @@ export declare interface WorkflowExecuteOptions {
|
|
|
3303
3393
|
}
|
|
3304
3394
|
|
|
3305
3395
|
/**
|
|
3306
|
-
* The workflow a `dependency
|
|
3396
|
+
* The workflow a `dependency:*` event is about.
|
|
3307
3397
|
* @public
|
|
3308
3398
|
*/
|
|
3309
3399
|
export declare interface WorkflowExecutionDependency {
|
|
@@ -3325,7 +3415,7 @@ export declare interface WorkflowExecutionDependency {
|
|
|
3325
3415
|
/**
|
|
3326
3416
|
* An event the {@link WorkflowExecutor} emits, discriminated by `type`.
|
|
3327
3417
|
*
|
|
3328
|
-
* The events other than `workflow
|
|
3418
|
+
* The events other than `workflow:normalize:*` mark the boundaries the
|
|
3329
3419
|
* {@link WorkflowExecutionResult} trace records, plus the criterion and
|
|
3330
3420
|
* action decisions behind each step, so folding a run's events rebuilds its
|
|
3331
3421
|
* trace. A workflow's or step's start and settled events are stamped with the
|
|
@@ -3353,7 +3443,7 @@ export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBas
|
|
|
3353
3443
|
readonly runId: string;
|
|
3354
3444
|
/**
|
|
3355
3445
|
* The bare id of the workflow in progress when the event fired. For a
|
|
3356
|
-
* `dependency
|
|
3446
|
+
* `dependency:*` event, this is the dependent workflow, not the dependency.
|
|
3357
3447
|
*/
|
|
3358
3448
|
readonly workflowId: string;
|
|
3359
3449
|
/**
|
|
@@ -3664,7 +3754,7 @@ export declare type WorkflowId = string;
|
|
|
3664
3754
|
* @public
|
|
3665
3755
|
*/
|
|
3666
3756
|
export declare interface WorkflowNormalizeSettledEvent extends WorkflowExecutionEventBase {
|
|
3667
|
-
readonly type: 'workflow
|
|
3757
|
+
readonly type: 'workflow:normalize:settled';
|
|
3668
3758
|
/**
|
|
3669
3759
|
* Where the workflow is written.
|
|
3670
3760
|
*/
|
|
@@ -3679,7 +3769,7 @@ export declare interface WorkflowNormalizeSettledEvent extends WorkflowExecution
|
|
|
3679
3769
|
* @public
|
|
3680
3770
|
*/
|
|
3681
3771
|
export declare interface WorkflowNormalizeStartEvent extends WorkflowExecutionEventBase {
|
|
3682
|
-
readonly type: 'workflow
|
|
3772
|
+
readonly type: 'workflow:normalize:start';
|
|
3683
3773
|
/**
|
|
3684
3774
|
* Where the workflow is written.
|
|
3685
3775
|
*/
|
|
@@ -3734,25 +3824,32 @@ export declare interface WorkflowReferenceContext {
|
|
|
3734
3824
|
}
|
|
3735
3825
|
|
|
3736
3826
|
/**
|
|
3737
|
-
* A workflow invocation produced its result. The fields repeat
|
|
3738
|
-
* {@link WorkflowExecutionResult} fields of the same name
|
|
3827
|
+
* A workflow invocation produced its result, or threw. The fields repeat
|
|
3828
|
+
* the {@link WorkflowExecutionResult} fields of the same name; an invocation
|
|
3829
|
+
* that threw settles as `failed`, with no outputs, and carries the `error`.
|
|
3739
3830
|
* @public
|
|
3740
3831
|
*/
|
|
3741
3832
|
export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase {
|
|
3742
|
-
readonly type: 'workflow
|
|
3833
|
+
readonly type: 'workflow:settled';
|
|
3743
3834
|
readonly status: WorkflowExecutionResult['status'];
|
|
3744
3835
|
readonly settledStatus: WorkflowExecutionResult['settledStatus'];
|
|
3745
3836
|
readonly outputs: WorkflowExecutionResult['outputs'];
|
|
3837
|
+
/**
|
|
3838
|
+
* What the invocation threw, as `execute` rejects with it: an
|
|
3839
|
+
* {@link ArazzoRunnerError} for an error in the document, an abort, or the
|
|
3840
|
+
* transport's own error. Only when it threw.
|
|
3841
|
+
*/
|
|
3842
|
+
readonly error?: unknown;
|
|
3746
3843
|
}
|
|
3747
3844
|
|
|
3748
3845
|
/**
|
|
3749
3846
|
* A workflow invocation began: it entered the call stack, before it is
|
|
3750
|
-
* normalized and its definition checked.
|
|
3751
|
-
*
|
|
3847
|
+
* normalized and its definition checked. Its `workflow:settled` always
|
|
3848
|
+
* follows, carrying the `error` when the invocation throws.
|
|
3752
3849
|
* @public
|
|
3753
3850
|
*/
|
|
3754
3851
|
export declare interface WorkflowStartEvent extends WorkflowExecutionEventBase {
|
|
3755
|
-
readonly type: 'workflow
|
|
3852
|
+
readonly type: 'workflow:start';
|
|
3756
3853
|
/** Where the workflow is written. */
|
|
3757
3854
|
readonly location: DocumentLocation;
|
|
3758
3855
|
/**
|