Skip to main content

Function: withChildSpans()

withChildSpans<T>(name, operations): Promise<T>

Defined in: src/observability/tracer.ts:327

Creates a span that wraps multiple child operations.

Type Parameters​

• T extends unknown[]

Parameters​

name​

string

Parent span name

operations​

{ [K in string | number | symbol]: { fn: () => T[K<K>] | Promise<T[K<K>]>; name: string } }

Array of named operations to execute

Returns​

Promise<T>

Promise resolving to array of operation results

Remarks​

Executes operations sequentially, each in its own child span. If any operation fails, subsequent operations are not executed.

Example​

const [fetchResult, indexResult, notifyResult] = await withChildSpans(
'processEprint',
[
{ name: 'fetchEprint', fn: () => fetchEprint(uri) },
{ name: 'indexToSearch', fn: () => indexToElasticsearch(eprint) },
{ name: 'sendNotification', fn: () => sendNotification(eprint) },
]
);

Since​

0.1.0