duron 0.3.0-beta.6 → 0.3.0-beta.7
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/dist/action.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.js +3 -1
- package/dist/step-manager.d.ts.map +1 -1
- package/dist/step-manager.js +28 -0
- package/dist/telemetry/adapter.d.ts +22 -0
- package/dist/telemetry/adapter.d.ts.map +1 -1
- package/dist/telemetry/adapter.js +6 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/local.d.ts +2 -1
- package/dist/telemetry/local.d.ts.map +1 -1
- package/dist/telemetry/local.js +63 -0
- package/dist/telemetry/noop.d.ts +2 -1
- package/dist/telemetry/noop.d.ts.map +1 -1
- package/dist/telemetry/noop.js +27 -0
- package/dist/telemetry/opentelemetry.d.ts +2 -1
- package/dist/telemetry/opentelemetry.d.ts.map +1 -1
- package/dist/telemetry/opentelemetry.js +110 -0
- package/migrations/postgres/20260119153838_flimsy_thor_girl/snapshot.json +12 -36
- package/package.json +1 -1
- package/src/action.ts +5 -11
- package/src/adapters/postgres/schema.ts +3 -1
- package/src/step-manager.ts +43 -1
- package/src/telemetry/adapter.ts +174 -0
- package/src/telemetry/index.ts +3 -0
- package/src/telemetry/local.ts +93 -0
- package/src/telemetry/noop.ts +46 -0
- package/src/telemetry/opentelemetry.ts +145 -2
package/dist/action.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG5D,MAAM,MAAM,YAAY,GAAG,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2E1F"}
|
|
@@ -79,7 +79,9 @@ export default function createSchema(schemaName) {
|
|
|
79
79
|
index('idx_job_steps_job_status').on(table.job_id, table.status),
|
|
80
80
|
index('idx_job_steps_job_name').on(table.job_id, table.name),
|
|
81
81
|
index('idx_job_steps_output_fts').using('gin', sql `to_tsvector('english', ${table.output}::text)`),
|
|
82
|
-
unique('unique_job_step_name_parent')
|
|
82
|
+
unique('unique_job_step_name_parent')
|
|
83
|
+
.on(table.job_id, table.name, table.parent_step_id)
|
|
84
|
+
.nullsNotDistinct(),
|
|
83
85
|
check('job_steps_status_check', sql `${table.status} IN ${sql.raw(`(${STEP_STATUSES.map((s) => `'${s}'`).join(',')})`)}`),
|
|
84
86
|
]);
|
|
85
87
|
const metricsTable = schema.table('metrics', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-manager.d.ts","sourceRoot":"","sources":["../src/step-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,EACL,KAAK,MAAM,EACX,KAAK,oBAAoB,EAGzB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,OAAO,EAAgC,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAoE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAWlH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"step-manager.d.ts","sourceRoot":"","sources":["../src/step-manager.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
import { STEP_STATUS_CANCELLED, STEP_STATUS_COMPLETED, STEP_STATUS_FAILED } from './constants.js';
|
|
4
4
|
import { ActionCancelError, isCancelError, isNonRetriableError, NonRetriableError, StepAlreadyExecutedError, StepTimeoutError, serializeError, UnhandledChildStepsError, } from './errors.js';
|
|
5
|
+
const noopTracerSpan = {
|
|
6
|
+
setAttribute() {
|
|
7
|
+
},
|
|
8
|
+
setAttributes() {
|
|
9
|
+
},
|
|
10
|
+
addEvent() {
|
|
11
|
+
},
|
|
12
|
+
recordException() {
|
|
13
|
+
},
|
|
14
|
+
setStatusOk() {
|
|
15
|
+
},
|
|
16
|
+
setStatusError() {
|
|
17
|
+
},
|
|
18
|
+
end() {
|
|
19
|
+
},
|
|
20
|
+
isRecording() {
|
|
21
|
+
return false;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const createNoopTracer = (name) => ({
|
|
25
|
+
name,
|
|
26
|
+
startSpan() {
|
|
27
|
+
return noopTracerSpan;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
5
30
|
import pRetry from './utils/p-retry.js';
|
|
6
31
|
import waitForAbort from './utils/wait-for-abort.js';
|
|
7
32
|
export class StepStore {
|
|
@@ -90,6 +115,9 @@ export class StepManager {
|
|
|
90
115
|
},
|
|
91
116
|
addSpanEvent: () => {
|
|
92
117
|
},
|
|
118
|
+
getTracer: (name) => {
|
|
119
|
+
return createNoopTracer(name);
|
|
120
|
+
},
|
|
93
121
|
};
|
|
94
122
|
}
|
|
95
123
|
async push(task) {
|
|
@@ -47,10 +47,30 @@ export interface AddSpanAttributeOptions {
|
|
|
47
47
|
key: string;
|
|
48
48
|
value: string | number | boolean;
|
|
49
49
|
}
|
|
50
|
+
export interface StartSpanOptions {
|
|
51
|
+
kind?: 'internal' | 'client' | 'server' | 'producer' | 'consumer';
|
|
52
|
+
attributes?: Record<string, string | number | boolean>;
|
|
53
|
+
parentSpan?: TracerSpan;
|
|
54
|
+
}
|
|
55
|
+
export interface TracerSpan {
|
|
56
|
+
setAttribute(key: string, value: string | number | boolean): void;
|
|
57
|
+
setAttributes(attributes: Record<string, string | number | boolean>): void;
|
|
58
|
+
addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
59
|
+
recordException(error: Error): void;
|
|
60
|
+
setStatusOk(): void;
|
|
61
|
+
setStatusError(message?: string): void;
|
|
62
|
+
end(): void;
|
|
63
|
+
isRecording(): boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface Tracer {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
startSpan(name: string, options?: StartSpanOptions): TracerSpan;
|
|
68
|
+
}
|
|
50
69
|
export interface ObserveContext {
|
|
51
70
|
recordMetric(name: string, value: number, attributes?: Record<string, any>): void;
|
|
52
71
|
addSpanAttribute(key: string, value: string | number | boolean): void;
|
|
53
72
|
addSpanEvent(name: string, attributes?: Record<string, any>): void;
|
|
73
|
+
getTracer(name: string): Tracer;
|
|
54
74
|
}
|
|
55
75
|
export declare abstract class TelemetryAdapter {
|
|
56
76
|
#private;
|
|
@@ -69,6 +89,7 @@ export declare abstract class TelemetryAdapter {
|
|
|
69
89
|
recordMetric(options: RecordMetricOptions): Promise<void>;
|
|
70
90
|
addSpanEvent(options: AddSpanEventOptions): Promise<void>;
|
|
71
91
|
addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
|
|
92
|
+
getTracer(name: string): Tracer;
|
|
72
93
|
createObserveContext(jobId: string, stepId: string | null, span: Span): ObserveContext;
|
|
73
94
|
protected abstract _start(): Promise<void>;
|
|
74
95
|
protected abstract _stop(): Promise<void>;
|
|
@@ -81,5 +102,6 @@ export declare abstract class TelemetryAdapter {
|
|
|
81
102
|
protected abstract _recordMetric(options: RecordMetricOptions): Promise<void>;
|
|
82
103
|
protected abstract _addSpanEvent(options: AddSpanEventOptions): Promise<void>;
|
|
83
104
|
protected abstract _addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
|
|
105
|
+
protected abstract _getTracer(name: string): Tracer;
|
|
84
106
|
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100
|
await this.start();
|
|
101
101
|
return this._addSpanAttribute(options);
|
|
102
102
|
}
|
|
103
|
+
getTracer(name) {
|
|
104
|
+
return this._getTracer(name);
|
|
105
|
+
}
|
|
103
106
|
createObserveContext(jobId, stepId, span) {
|
|
104
107
|
return {
|
|
105
108
|
recordMetric: (name, value, attributes) => {
|
|
@@ -123,6 +126,9 @@ export class TelemetryAdapter {
|
|
|
123
126
|
this.#logger?.error(err, 'Error adding span event');
|
|
124
127
|
});
|
|
125
128
|
},
|
|
129
|
+
getTracer: (name) => {
|
|
130
|
+
return this.getTracer(name);
|
|
131
|
+
},
|
|
126
132
|
};
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type ObserveContext, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter, } from './adapter.js';
|
|
1
|
+
export { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type ObserveContext, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartSpanOptions, type StartStepSpanOptions, TelemetryAdapter, type Tracer, type TracerSpan, } from './adapter.js';
|
|
2
2
|
export { LocalTelemetryAdapter, type LocalTelemetryAdapterOptions, localTelemetryAdapter } from './local.js';
|
|
3
3
|
export { NoopTelemetryAdapter, noopTelemetryAdapter } from './noop.js';
|
|
4
4
|
export { OpenTelemetryAdapter, type OpenTelemetryAdapterOptions, openTelemetryAdapter } from './opentelemetry.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAC5G,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter } from './adapter.js';
|
|
1
|
+
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter, type Tracer } from './adapter.js';
|
|
2
2
|
export interface LocalTelemetryAdapterOptions {
|
|
3
3
|
flushDelayMs?: number;
|
|
4
4
|
}
|
|
@@ -16,6 +16,7 @@ export declare class LocalTelemetryAdapter extends TelemetryAdapter {
|
|
|
16
16
|
protected _recordMetric(options: RecordMetricOptions): Promise<void>;
|
|
17
17
|
protected _addSpanEvent(options: AddSpanEventOptions): Promise<void>;
|
|
18
18
|
protected _addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
|
|
19
|
+
protected _getTracer(name: string): Tracer;
|
|
19
20
|
}
|
|
20
21
|
export declare const localTelemetryAdapter: (options?: LocalTelemetryAdapterOptions) => LocalTelemetryAdapter;
|
|
21
22
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/telemetry/local.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/telemetry/local.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,MAAM,EAEZ,MAAM,cAAc,CAAA;AAMrB,MAAM,WAAW,4BAA4B;IAM3C,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AA4BD,qBAAa,qBAAsB,SAAQ,gBAAgB;;gBAO7C,OAAO,CAAC,EAAE,4BAA4B;cAwFlC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;cAIvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAUtB,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cAyB1D,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAoB/D,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;cA2B5D,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAqBhE,kBAAkB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;cAK5E,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAQtE,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cAW1D,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cAc1D,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBlF,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAqF3C;AA6BD,eAAO,MAAM,qBAAqB,GAAI,UAAU,4BAA4B,0BAAuC,CAAA"}
|
package/dist/telemetry/local.js
CHANGED
|
@@ -176,5 +176,68 @@ export class LocalTelemetryAdapter extends TelemetryAdapter {
|
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
+
_getTracer(name) {
|
|
180
|
+
const adapter = this;
|
|
181
|
+
return {
|
|
182
|
+
name,
|
|
183
|
+
startSpan(spanName, options) {
|
|
184
|
+
const spanId = `tracer:${name}:${globalThis.crypto.randomUUID()}`;
|
|
185
|
+
const startTime = Date.now();
|
|
186
|
+
let ended = false;
|
|
187
|
+
const attributes = {
|
|
188
|
+
...options?.attributes,
|
|
189
|
+
};
|
|
190
|
+
const tracerSpan = {
|
|
191
|
+
setAttribute(key, value) {
|
|
192
|
+
if (!ended) {
|
|
193
|
+
attributes[key] = value;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
setAttributes(attrs) {
|
|
197
|
+
if (!ended) {
|
|
198
|
+
Object.assign(attributes, attrs);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
addEvent(eventName, eventAttrs) {
|
|
202
|
+
if (!ended) {
|
|
203
|
+
adapter.logger?.debug({ spanId, event: eventName, attributes: eventAttrs }, 'Tracer span event');
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
recordException(error) {
|
|
207
|
+
if (!ended) {
|
|
208
|
+
attributes['error.message'] = error.message;
|
|
209
|
+
attributes['error.name'] = error.name;
|
|
210
|
+
adapter.logger?.debug({ spanId, error: error.message }, 'Tracer span exception');
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
setStatusOk() {
|
|
214
|
+
if (!ended) {
|
|
215
|
+
attributes['status'] = 'ok';
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
setStatusError(message) {
|
|
219
|
+
if (!ended) {
|
|
220
|
+
attributes['status'] = 'error';
|
|
221
|
+
if (message) {
|
|
222
|
+
attributes['status.message'] = message;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
end() {
|
|
227
|
+
if (!ended) {
|
|
228
|
+
ended = true;
|
|
229
|
+
const duration = Date.now() - startTime;
|
|
230
|
+
adapter.logger?.debug({ spanId, spanName, tracerName: name, durationMs: duration, attributes }, 'Tracer span ended');
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
isRecording() {
|
|
234
|
+
return !ended;
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
adapter.logger?.debug({ spanId, spanName, tracerName: name }, 'Tracer span started');
|
|
238
|
+
return tracerSpan;
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
179
242
|
}
|
|
180
243
|
export const localTelemetryAdapter = (options) => new LocalTelemetryAdapter(options);
|
package/dist/telemetry/noop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter } from './adapter.js';
|
|
1
|
+
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter, type Tracer } from './adapter.js';
|
|
2
2
|
export declare class NoopTelemetryAdapter extends TelemetryAdapter {
|
|
3
3
|
protected _start(): Promise<void>;
|
|
4
4
|
protected _stop(): Promise<void>;
|
|
@@ -11,6 +11,7 @@ export declare class NoopTelemetryAdapter extends TelemetryAdapter {
|
|
|
11
11
|
protected _recordMetric(_options: RecordMetricOptions): Promise<void>;
|
|
12
12
|
protected _addSpanEvent(_options: AddSpanEventOptions): Promise<void>;
|
|
13
13
|
protected _addSpanAttribute(_options: AddSpanAttributeOptions): Promise<void>;
|
|
14
|
+
protected _getTracer(name: string): Tracer;
|
|
14
15
|
}
|
|
15
16
|
export declare const noopTelemetryAdapter: () => NoopTelemetryAdapter;
|
|
16
17
|
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/telemetry/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/telemetry/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,MAAM,EAEZ,MAAM,c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
11
|
+
setStatusOk() {
|
|
12
|
+
},
|
|
13
|
+
setStatusError() {
|
|
14
|
+
},
|
|
15
|
+
end() {
|
|
16
|
+
},
|
|
17
|
+
isRecording() {
|
|
18
|
+
return false;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
2
21
|
export class NoopTelemetryAdapter extends TelemetryAdapter {
|
|
3
22
|
async _start() {
|
|
4
23
|
}
|
|
@@ -35,5 +54,13 @@ export class NoopTelemetryAdapter extends TelemetryAdapter {
|
|
|
35
54
|
}
|
|
36
55
|
async _addSpanAttribute(_options) {
|
|
37
56
|
}
|
|
57
|
+
_getTracer(name) {
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
startSpan() {
|
|
61
|
+
return noopTracerSpan;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
38
65
|
}
|
|
39
66
|
export const noopTelemetryAdapter = () => new NoopTelemetryAdapter();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TracerProvider } from '@opentelemetry/api';
|
|
2
|
-
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter } from './adapter.js';
|
|
2
|
+
import { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartStepSpanOptions, TelemetryAdapter, type Tracer } from './adapter.js';
|
|
3
3
|
export interface OpenTelemetryAdapterOptions {
|
|
4
4
|
serviceName?: string;
|
|
5
5
|
tracerProvider?: TracerProvider;
|
|
@@ -19,6 +19,7 @@ export declare class OpenTelemetryAdapter extends TelemetryAdapter {
|
|
|
19
19
|
protected _recordMetric(options: RecordMetricOptions): Promise<void>;
|
|
20
20
|
protected _addSpanEvent(options: AddSpanEventOptions): Promise<void>;
|
|
21
21
|
protected _addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
|
|
22
|
+
protected _getTracer(name: string): Tracer;
|
|
22
23
|
}
|
|
23
24
|
export declare const openTelemetryAdapter: (options?: OpenTelemetryAdapterOptions) => OpenTelemetryAdapter;
|
|
24
25
|
//# sourceMappingURL=opentelemetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opentelemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry/opentelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"opentelemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry/opentelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0C,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEhG,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,MAAM,EAEZ,MAAM,cAAc,CAAA;AAMrB,MAAM,WAAW,2BAA2B;IAK1C,WAAW,CAAC,EAAE,MAAM,CAAA;IAMpB,cAAc,CAAC,EAAE,cAAc,CAAA;IAM/B,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAcD,qBAAa,oBAAqB,SAAQ,gBAAgB;;gBAQ5C,OAAO,GAAE,2BAAgC;cAWrC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;cAYvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAStB,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cA8B1D,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cA2B/D,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;cA4C5D,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cA2BhE,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;cA8B3E,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAyBpE,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cAe1D,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;cAO1D,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlF,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAsI3C;AASD,eAAO,MAAM,oBAAoB,GAAI,UAAU,2BAA2B,yBAAsC,CAAA"}
|
|
@@ -5,6 +5,7 @@ export class OpenTelemetryAdapter extends TelemetryAdapter {
|
|
|
5
5
|
#traceDatabaseQueries;
|
|
6
6
|
#tracer = null;
|
|
7
7
|
#spanMap = new Map();
|
|
8
|
+
#tracerCache = new Map();
|
|
8
9
|
constructor(options = {}) {
|
|
9
10
|
super();
|
|
10
11
|
this.#serviceName = options.serviceName ?? 'duron';
|
|
@@ -198,5 +199,114 @@ export class OpenTelemetryAdapter extends TelemetryAdapter {
|
|
|
198
199
|
extSpan.otelSpan.setAttribute(options.key, options.value);
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
_getTracer(name) {
|
|
203
|
+
const cached = this.#tracerCache.get(name);
|
|
204
|
+
if (cached) {
|
|
205
|
+
return cached;
|
|
206
|
+
}
|
|
207
|
+
const adapter = this;
|
|
208
|
+
const tracer = {
|
|
209
|
+
name,
|
|
210
|
+
startSpan(spanName, options) {
|
|
211
|
+
let otelSpan = null;
|
|
212
|
+
let api = null;
|
|
213
|
+
let ended = false;
|
|
214
|
+
const initPromise = (async () => {
|
|
215
|
+
api = await import('@opentelemetry/api');
|
|
216
|
+
let otelTracer;
|
|
217
|
+
if (adapter.#tracerProvider) {
|
|
218
|
+
otelTracer = adapter.#tracerProvider.getTracer(name);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
otelTracer = api.trace.getTracer(name);
|
|
222
|
+
}
|
|
223
|
+
let spanKind = api.SpanKind.INTERNAL;
|
|
224
|
+
if (options?.kind === 'client')
|
|
225
|
+
spanKind = api.SpanKind.CLIENT;
|
|
226
|
+
else if (options?.kind === 'server')
|
|
227
|
+
spanKind = api.SpanKind.SERVER;
|
|
228
|
+
else if (options?.kind === 'producer')
|
|
229
|
+
spanKind = api.SpanKind.PRODUCER;
|
|
230
|
+
else if (options?.kind === 'consumer')
|
|
231
|
+
spanKind = api.SpanKind.CONSUMER;
|
|
232
|
+
let parentContext = api.context.active();
|
|
233
|
+
if (options?.parentSpan) {
|
|
234
|
+
const parentOtelSpan = options.parentSpan._otelSpan;
|
|
235
|
+
if (parentOtelSpan) {
|
|
236
|
+
parentContext = api.trace.setSpan(api.context.active(), parentOtelSpan);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
otelSpan = otelTracer.startSpan(spanName, {
|
|
240
|
+
kind: spanKind,
|
|
241
|
+
attributes: options?.attributes,
|
|
242
|
+
}, parentContext);
|
|
243
|
+
})();
|
|
244
|
+
const tracerSpan = {
|
|
245
|
+
setAttribute(key, value) {
|
|
246
|
+
initPromise.then(() => {
|
|
247
|
+
if (otelSpan && !ended) {
|
|
248
|
+
otelSpan.setAttribute(key, value);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
setAttributes(attributes) {
|
|
253
|
+
initPromise.then(() => {
|
|
254
|
+
if (otelSpan && !ended) {
|
|
255
|
+
otelSpan.setAttributes(attributes);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
addEvent(eventName, attributes) {
|
|
260
|
+
initPromise.then(() => {
|
|
261
|
+
if (otelSpan && !ended) {
|
|
262
|
+
otelSpan.addEvent(eventName, attributes);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
recordException(error) {
|
|
267
|
+
initPromise.then(() => {
|
|
268
|
+
if (otelSpan && !ended) {
|
|
269
|
+
otelSpan.recordException(error);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
setStatusOk() {
|
|
274
|
+
initPromise.then(() => {
|
|
275
|
+
if (otelSpan && api && !ended) {
|
|
276
|
+
otelSpan.setStatus({ code: api.SpanStatusCode.OK });
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
setStatusError(message) {
|
|
281
|
+
initPromise.then(() => {
|
|
282
|
+
if (otelSpan && api && !ended) {
|
|
283
|
+
otelSpan.setStatus({ code: api.SpanStatusCode.ERROR, message });
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
end() {
|
|
288
|
+
initPromise.then(() => {
|
|
289
|
+
if (otelSpan && !ended) {
|
|
290
|
+
ended = true;
|
|
291
|
+
otelSpan.end();
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
isRecording() {
|
|
296
|
+
return otelSpan?.isRecording() ?? false;
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
initPromise.then(() => {
|
|
300
|
+
if (otelSpan) {
|
|
301
|
+
;
|
|
302
|
+
tracerSpan._otelSpan = otelSpan;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return tracerSpan;
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
this.#tracerCache.set(name, tracer);
|
|
309
|
+
return tracer;
|
|
310
|
+
}
|
|
201
311
|
}
|
|
202
312
|
export const openTelemetryAdapter = (options) => new OpenTelemetryAdapter(options);
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
"version": "8",
|
|
3
3
|
"dialect": "postgres",
|
|
4
4
|
"id": "4e93c0bf-b135-40b4-b130-0cf0968bffe3",
|
|
5
|
-
"prevIds": [
|
|
6
|
-
"00000000-0000-0000-0000-000000000000"
|
|
7
|
-
],
|
|
5
|
+
"prevIds": ["00000000-0000-0000-0000-000000000000"],
|
|
8
6
|
"ddl": [
|
|
9
7
|
{
|
|
10
8
|
"name": "duron",
|
|
@@ -1268,14 +1266,10 @@
|
|
|
1268
1266
|
},
|
|
1269
1267
|
{
|
|
1270
1268
|
"nameExplicit": false,
|
|
1271
|
-
"columns": [
|
|
1272
|
-
"job_id"
|
|
1273
|
-
],
|
|
1269
|
+
"columns": ["job_id"],
|
|
1274
1270
|
"schemaTo": "duron",
|
|
1275
1271
|
"tableTo": "jobs",
|
|
1276
|
-
"columnsTo": [
|
|
1277
|
-
"id"
|
|
1278
|
-
],
|
|
1272
|
+
"columnsTo": ["id"],
|
|
1279
1273
|
"onUpdate": "NO ACTION",
|
|
1280
1274
|
"onDelete": "CASCADE",
|
|
1281
1275
|
"name": "job_steps_job_id_jobs_id_fkey",
|
|
@@ -1285,14 +1279,10 @@
|
|
|
1285
1279
|
},
|
|
1286
1280
|
{
|
|
1287
1281
|
"nameExplicit": false,
|
|
1288
|
-
"columns": [
|
|
1289
|
-
"job_id"
|
|
1290
|
-
],
|
|
1282
|
+
"columns": ["job_id"],
|
|
1291
1283
|
"schemaTo": "duron",
|
|
1292
1284
|
"tableTo": "jobs",
|
|
1293
|
-
"columnsTo": [
|
|
1294
|
-
"id"
|
|
1295
|
-
],
|
|
1285
|
+
"columnsTo": ["id"],
|
|
1296
1286
|
"onUpdate": "NO ACTION",
|
|
1297
1287
|
"onDelete": "CASCADE",
|
|
1298
1288
|
"name": "metrics_job_id_jobs_id_fkey",
|
|
@@ -1302,14 +1292,10 @@
|
|
|
1302
1292
|
},
|
|
1303
1293
|
{
|
|
1304
1294
|
"nameExplicit": false,
|
|
1305
|
-
"columns": [
|
|
1306
|
-
"step_id"
|
|
1307
|
-
],
|
|
1295
|
+
"columns": ["step_id"],
|
|
1308
1296
|
"schemaTo": "duron",
|
|
1309
1297
|
"tableTo": "job_steps",
|
|
1310
|
-
"columnsTo": [
|
|
1311
|
-
"id"
|
|
1312
|
-
],
|
|
1298
|
+
"columnsTo": ["id"],
|
|
1313
1299
|
"onUpdate": "NO ACTION",
|
|
1314
1300
|
"onDelete": "CASCADE",
|
|
1315
1301
|
"name": "metrics_step_id_job_steps_id_fkey",
|
|
@@ -1318,9 +1304,7 @@
|
|
|
1318
1304
|
"table": "metrics"
|
|
1319
1305
|
},
|
|
1320
1306
|
{
|
|
1321
|
-
"columns": [
|
|
1322
|
-
"id"
|
|
1323
|
-
],
|
|
1307
|
+
"columns": ["id"],
|
|
1324
1308
|
"nameExplicit": false,
|
|
1325
1309
|
"name": "job_steps_pkey",
|
|
1326
1310
|
"schema": "duron",
|
|
@@ -1328,9 +1312,7 @@
|
|
|
1328
1312
|
"entityType": "pks"
|
|
1329
1313
|
},
|
|
1330
1314
|
{
|
|
1331
|
-
"columns": [
|
|
1332
|
-
"id"
|
|
1333
|
-
],
|
|
1315
|
+
"columns": ["id"],
|
|
1334
1316
|
"nameExplicit": false,
|
|
1335
1317
|
"name": "jobs_pkey",
|
|
1336
1318
|
"schema": "duron",
|
|
@@ -1338,9 +1320,7 @@
|
|
|
1338
1320
|
"entityType": "pks"
|
|
1339
1321
|
},
|
|
1340
1322
|
{
|
|
1341
|
-
"columns": [
|
|
1342
|
-
"id"
|
|
1343
|
-
],
|
|
1323
|
+
"columns": ["id"],
|
|
1344
1324
|
"nameExplicit": false,
|
|
1345
1325
|
"name": "metrics_pkey",
|
|
1346
1326
|
"schema": "duron",
|
|
@@ -1349,11 +1329,7 @@
|
|
|
1349
1329
|
},
|
|
1350
1330
|
{
|
|
1351
1331
|
"nameExplicit": true,
|
|
1352
|
-
"columns": [
|
|
1353
|
-
"job_id",
|
|
1354
|
-
"name",
|
|
1355
|
-
"parent_step_id"
|
|
1356
|
-
],
|
|
1332
|
+
"columns": ["job_id", "name", "parent_step_id"],
|
|
1357
1333
|
"nullsNotDistinct": true,
|
|
1358
1334
|
"name": "unique_job_step_name_parent",
|
|
1359
1335
|
"entityType": "uniques",
|
|
@@ -1383,4 +1359,4 @@
|
|
|
1383
1359
|
}
|
|
1384
1360
|
],
|
|
1385
1361
|
"renames": []
|
|
1386
|
-
}
|
|
1362
|
+
}
|
package/package.json
CHANGED
package/src/action.ts
CHANGED
|
@@ -133,18 +133,13 @@ export interface StepDefinitionHandlerContext<TInput extends z.ZodObject, TVaria
|
|
|
133
133
|
* The job ID this step belongs to.
|
|
134
134
|
*/
|
|
135
135
|
jobId: string
|
|
136
|
-
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
/**
|
|
140
139
|
* A reusable step definition created with createStep().
|
|
141
140
|
* Can be executed within an action handler using ctx.run().
|
|
142
141
|
*/
|
|
143
|
-
export interface StepDefinition<
|
|
144
|
-
TInput extends z.ZodObject,
|
|
145
|
-
TResult,
|
|
146
|
-
TVariables = Record<string, unknown>,
|
|
147
|
-
> {
|
|
142
|
+
export interface StepDefinition<TInput extends z.ZodObject, TResult, TVariables = Record<string, unknown>> {
|
|
148
143
|
/**
|
|
149
144
|
* The name of the step.
|
|
150
145
|
* Can be a static string or a function that generates the name from the input.
|
|
@@ -417,11 +412,10 @@ export const defineAction = <TVariables = Record<string, unknown>>() => {
|
|
|
417
412
|
/**
|
|
418
413
|
* Input type for createStep() - the definition object before transformation.
|
|
419
414
|
*/
|
|
420
|
-
export type StepDefinitionInput<
|
|
421
|
-
TInput
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
> = Omit<StepDefinition<TInput, TResult, TVariables>, '__stepDefinition'>
|
|
415
|
+
export type StepDefinitionInput<TInput extends z.ZodObject, TResult, TVariables = Record<string, unknown>> = Omit<
|
|
416
|
+
StepDefinition<TInput, TResult, TVariables>,
|
|
417
|
+
'__stepDefinition'
|
|
418
|
+
>
|
|
425
419
|
|
|
426
420
|
/**
|
|
427
421
|
* Creates a reusable step definition that can be executed within action handlers.
|
|
@@ -119,7 +119,9 @@ export default function createSchema(schemaName: string) {
|
|
|
119
119
|
index('idx_job_steps_output_fts').using('gin', sql`to_tsvector('english', ${table.output}::text)`),
|
|
120
120
|
// Unique constraint - step name is unique within a parent (name + parentStepId)
|
|
121
121
|
// nullsNotDistinct ensures NULL parent_step_id values are treated as equal for uniqueness
|
|
122
|
-
unique('unique_job_step_name_parent')
|
|
122
|
+
unique('unique_job_step_name_parent')
|
|
123
|
+
.on(table.job_id, table.name, table.parent_step_id)
|
|
124
|
+
.nullsNotDistinct(),
|
|
123
125
|
check(
|
|
124
126
|
'job_steps_status_check',
|
|
125
127
|
sql`${table.status} IN ${sql.raw(`(${STEP_STATUSES.map((s) => `'${s}'`).join(',')})`)}`,
|
package/src/step-manager.ts
CHANGED
|
@@ -23,7 +23,46 @@ import {
|
|
|
23
23
|
serializeError,
|
|
24
24
|
UnhandledChildStepsError,
|
|
25
25
|
} from './errors.js'
|
|
26
|
-
import type { ObserveContext, Span, TelemetryAdapter } from './telemetry/adapter.js'
|
|
26
|
+
import type { ObserveContext, Span, TelemetryAdapter, Tracer, TracerSpan } from './telemetry/adapter.js'
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Noop Tracer (for fallback observe context)
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
const noopTracerSpan: TracerSpan = {
|
|
33
|
+
setAttribute() {
|
|
34
|
+
// No-op
|
|
35
|
+
},
|
|
36
|
+
setAttributes() {
|
|
37
|
+
// No-op
|
|
38
|
+
},
|
|
39
|
+
addEvent() {
|
|
40
|
+
// No-op
|
|
41
|
+
},
|
|
42
|
+
recordException() {
|
|
43
|
+
// No-op
|
|
44
|
+
},
|
|
45
|
+
setStatusOk() {
|
|
46
|
+
// No-op
|
|
47
|
+
},
|
|
48
|
+
setStatusError() {
|
|
49
|
+
// No-op
|
|
50
|
+
},
|
|
51
|
+
end() {
|
|
52
|
+
// No-op
|
|
53
|
+
},
|
|
54
|
+
isRecording() {
|
|
55
|
+
return false
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const createNoopTracer = (name: string): Tracer => ({
|
|
60
|
+
name,
|
|
61
|
+
startSpan(): TracerSpan {
|
|
62
|
+
return noopTracerSpan
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
27
66
|
import pRetry from './utils/p-retry.js'
|
|
28
67
|
import waitForAbort from './utils/wait-for-abort.js'
|
|
29
68
|
|
|
@@ -251,6 +290,9 @@ export class StepManager {
|
|
|
251
290
|
addSpanEvent: () => {
|
|
252
291
|
// No-op
|
|
253
292
|
},
|
|
293
|
+
getTracer: (name: string) => {
|
|
294
|
+
return createNoopTracer(name)
|
|
295
|
+
},
|
|
254
296
|
}
|
|
255
297
|
}
|
|
256
298
|
|
package/src/telemetry/adapter.ts
CHANGED
|
@@ -108,6 +108,106 @@ export interface AddSpanAttributeOptions {
|
|
|
108
108
|
value: string | number | boolean
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Options for starting a custom span with the tracer.
|
|
113
|
+
*/
|
|
114
|
+
export interface StartSpanOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Span kind (internal, client, server, producer, consumer).
|
|
117
|
+
* @default 'internal'
|
|
118
|
+
*/
|
|
119
|
+
kind?: 'internal' | 'client' | 'server' | 'producer' | 'consumer'
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Initial attributes for the span.
|
|
123
|
+
*/
|
|
124
|
+
attributes?: Record<string, string | number | boolean>
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Parent span to use for context propagation.
|
|
128
|
+
* If not provided, uses the current active context.
|
|
129
|
+
*/
|
|
130
|
+
parentSpan?: TracerSpan
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A span created by the Tracer for manual instrumentation.
|
|
135
|
+
*/
|
|
136
|
+
export interface TracerSpan {
|
|
137
|
+
/**
|
|
138
|
+
* Set an attribute on the span.
|
|
139
|
+
*
|
|
140
|
+
* @param key - The attribute key
|
|
141
|
+
* @param value - The attribute value
|
|
142
|
+
*/
|
|
143
|
+
setAttribute(key: string, value: string | number | boolean): void
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set multiple attributes on the span.
|
|
147
|
+
*
|
|
148
|
+
* @param attributes - The attributes to set
|
|
149
|
+
*/
|
|
150
|
+
setAttributes(attributes: Record<string, string | number | boolean>): void
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Add an event to the span.
|
|
154
|
+
*
|
|
155
|
+
* @param name - The event name
|
|
156
|
+
* @param attributes - Optional event attributes
|
|
157
|
+
*/
|
|
158
|
+
addEvent(name: string, attributes?: Record<string, string | number | boolean>): void
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Record an exception on the span.
|
|
162
|
+
*
|
|
163
|
+
* @param error - The error to record
|
|
164
|
+
*/
|
|
165
|
+
recordException(error: Error): void
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Set the span status to OK.
|
|
169
|
+
*/
|
|
170
|
+
setStatusOk(): void
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set the span status to error.
|
|
174
|
+
*
|
|
175
|
+
* @param message - Optional error message
|
|
176
|
+
*/
|
|
177
|
+
setStatusError(message?: string): void
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* End the span.
|
|
181
|
+
* After calling this, no more operations can be performed on the span.
|
|
182
|
+
*/
|
|
183
|
+
end(): void
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Check if this span is recording.
|
|
187
|
+
*/
|
|
188
|
+
isRecording(): boolean
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A Tracer provides methods for creating spans.
|
|
193
|
+
* Similar to OpenTelemetry's Tracer interface.
|
|
194
|
+
*/
|
|
195
|
+
export interface Tracer {
|
|
196
|
+
/**
|
|
197
|
+
* The name of this tracer.
|
|
198
|
+
*/
|
|
199
|
+
readonly name: string
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Start a new span.
|
|
203
|
+
*
|
|
204
|
+
* @param name - The name of the span
|
|
205
|
+
* @param options - Optional span configuration
|
|
206
|
+
* @returns A TracerSpan for manual instrumentation
|
|
207
|
+
*/
|
|
208
|
+
startSpan(name: string, options?: StartSpanOptions): TracerSpan
|
|
209
|
+
}
|
|
210
|
+
|
|
111
211
|
/**
|
|
112
212
|
* Observe context provided to action and step handlers.
|
|
113
213
|
*/
|
|
@@ -136,6 +236,37 @@ export interface ObserveContext {
|
|
|
136
236
|
* @param attributes - Optional event attributes
|
|
137
237
|
*/
|
|
138
238
|
addSpanEvent(name: string, attributes?: Record<string, any>): void
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get a tracer for manual instrumentation.
|
|
242
|
+
* Similar to OpenTelemetry's `trace.getTracer()` method.
|
|
243
|
+
*
|
|
244
|
+
* @param name - The name of the tracer (typically your service or library name)
|
|
245
|
+
* @returns A Tracer for creating custom spans
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const tracer = ctx.observe.getTracer('my-service')
|
|
250
|
+
*
|
|
251
|
+
* const span = tracer.startSpan('external-api-call', {
|
|
252
|
+
* kind: 'client',
|
|
253
|
+
* attributes: { 'api.endpoint': '/users' }
|
|
254
|
+
* })
|
|
255
|
+
*
|
|
256
|
+
* try {
|
|
257
|
+
* const result = await fetch('https://api.example.com/users')
|
|
258
|
+
* span.setStatusOk()
|
|
259
|
+
* return result
|
|
260
|
+
* } catch (error) {
|
|
261
|
+
* span.recordException(error)
|
|
262
|
+
* span.setStatusError(error.message)
|
|
263
|
+
* throw error
|
|
264
|
+
* } finally {
|
|
265
|
+
* span.end()
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
getTracer(name: string): Tracer
|
|
139
270
|
}
|
|
140
271
|
|
|
141
272
|
// ============================================================================
|
|
@@ -369,6 +500,41 @@ export abstract class TelemetryAdapter {
|
|
|
369
500
|
return this._addSpanAttribute(options)
|
|
370
501
|
}
|
|
371
502
|
|
|
503
|
+
// ============================================================================
|
|
504
|
+
// Tracer Methods
|
|
505
|
+
// ============================================================================
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Get a tracer for manual instrumentation.
|
|
509
|
+
* Similar to OpenTelemetry's `trace.getTracer()` method.
|
|
510
|
+
*
|
|
511
|
+
* @param name - The name of the tracer (typically your service or library name)
|
|
512
|
+
* @returns A Tracer for creating custom spans
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* const tracer = telemetry.getTracer('my-service')
|
|
517
|
+
*
|
|
518
|
+
* const span = tracer.startSpan('process-order', {
|
|
519
|
+
* attributes: { 'order.id': orderId }
|
|
520
|
+
* })
|
|
521
|
+
*
|
|
522
|
+
* try {
|
|
523
|
+
* // Do some work
|
|
524
|
+
* span.addEvent('order.validated')
|
|
525
|
+
* span.setStatusOk()
|
|
526
|
+
* } catch (error) {
|
|
527
|
+
* span.recordException(error)
|
|
528
|
+
* span.setStatusError(error.message)
|
|
529
|
+
* } finally {
|
|
530
|
+
* span.end()
|
|
531
|
+
* }
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
getTracer(name: string): Tracer {
|
|
535
|
+
return this._getTracer(name)
|
|
536
|
+
}
|
|
537
|
+
|
|
372
538
|
// ============================================================================
|
|
373
539
|
// Context Methods
|
|
374
540
|
// ============================================================================
|
|
@@ -404,6 +570,9 @@ export abstract class TelemetryAdapter {
|
|
|
404
570
|
this.#logger?.error(err, 'Error adding span event')
|
|
405
571
|
})
|
|
406
572
|
},
|
|
573
|
+
getTracer: (name: string) => {
|
|
574
|
+
return this.getTracer(name)
|
|
575
|
+
},
|
|
407
576
|
}
|
|
408
577
|
}
|
|
409
578
|
|
|
@@ -465,4 +634,9 @@ export abstract class TelemetryAdapter {
|
|
|
465
634
|
* Internal method to add a span attribute.
|
|
466
635
|
*/
|
|
467
636
|
protected abstract _addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Internal method to get a tracer for manual instrumentation.
|
|
640
|
+
*/
|
|
641
|
+
protected abstract _getTracer(name: string): Tracer
|
|
468
642
|
}
|
package/src/telemetry/index.ts
CHANGED
|
@@ -9,8 +9,11 @@ export {
|
|
|
9
9
|
type Span,
|
|
10
10
|
type StartDatabaseSpanOptions,
|
|
11
11
|
type StartJobSpanOptions,
|
|
12
|
+
type StartSpanOptions,
|
|
12
13
|
type StartStepSpanOptions,
|
|
13
14
|
TelemetryAdapter,
|
|
15
|
+
type Tracer,
|
|
16
|
+
type TracerSpan,
|
|
14
17
|
} from './adapter.js'
|
|
15
18
|
export { LocalTelemetryAdapter, type LocalTelemetryAdapterOptions, localTelemetryAdapter } from './local.js'
|
|
16
19
|
export { NoopTelemetryAdapter, noopTelemetryAdapter } from './noop.js'
|
package/src/telemetry/local.ts
CHANGED
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
type Span,
|
|
8
8
|
type StartDatabaseSpanOptions,
|
|
9
9
|
type StartJobSpanOptions,
|
|
10
|
+
type StartSpanOptions,
|
|
10
11
|
type StartStepSpanOptions,
|
|
11
12
|
TelemetryAdapter,
|
|
13
|
+
type Tracer,
|
|
14
|
+
type TracerSpan,
|
|
12
15
|
} from './adapter.js'
|
|
13
16
|
|
|
14
17
|
// ============================================================================
|
|
@@ -304,6 +307,96 @@ export class LocalTelemetryAdapter extends TelemetryAdapter {
|
|
|
304
307
|
},
|
|
305
308
|
})
|
|
306
309
|
}
|
|
310
|
+
|
|
311
|
+
// ============================================================================
|
|
312
|
+
// Tracer Methods
|
|
313
|
+
// ============================================================================
|
|
314
|
+
|
|
315
|
+
protected _getTracer(name: string): Tracer {
|
|
316
|
+
const adapter = this
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
name,
|
|
320
|
+
|
|
321
|
+
startSpan(spanName: string, options?: StartSpanOptions): TracerSpan {
|
|
322
|
+
const spanId = `tracer:${name}:${globalThis.crypto.randomUUID()}`
|
|
323
|
+
const startTime = Date.now()
|
|
324
|
+
let ended = false
|
|
325
|
+
const attributes: Record<string, string | number | boolean> = {
|
|
326
|
+
...options?.attributes,
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Note: Local adapter tracer spans don't have a jobId context,
|
|
330
|
+
// so they can't be stored in the database. They're essentially no-ops
|
|
331
|
+
// but provide a consistent API for code that needs a tracer.
|
|
332
|
+
// For actual metrics storage, use ctx.observe within action/step handlers.
|
|
333
|
+
|
|
334
|
+
const tracerSpan: TracerSpan = {
|
|
335
|
+
setAttribute(key: string, value: string | number | boolean): void {
|
|
336
|
+
if (!ended) {
|
|
337
|
+
attributes[key] = value
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
setAttributes(attrs: Record<string, string | number | boolean>): void {
|
|
342
|
+
if (!ended) {
|
|
343
|
+
Object.assign(attributes, attrs)
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
addEvent(eventName: string, eventAttrs?: Record<string, string | number | boolean>): void {
|
|
348
|
+
if (!ended) {
|
|
349
|
+
adapter.logger?.debug({ spanId, event: eventName, attributes: eventAttrs }, 'Tracer span event')
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
recordException(error: Error): void {
|
|
354
|
+
if (!ended) {
|
|
355
|
+
attributes['error.message'] = error.message
|
|
356
|
+
attributes['error.name'] = error.name
|
|
357
|
+
adapter.logger?.debug({ spanId, error: error.message }, 'Tracer span exception')
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
setStatusOk(): void {
|
|
362
|
+
if (!ended) {
|
|
363
|
+
// biome-ignore lint/complexity/useLiteralKeys: Index signature requires bracket notation
|
|
364
|
+
attributes['status'] = 'ok'
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
|
|
368
|
+
setStatusError(message?: string): void {
|
|
369
|
+
if (!ended) {
|
|
370
|
+
// biome-ignore lint/complexity/useLiteralKeys: Index signature requires bracket notation
|
|
371
|
+
attributes['status'] = 'error'
|
|
372
|
+
if (message) {
|
|
373
|
+
attributes['status.message'] = message
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
end(): void {
|
|
379
|
+
if (!ended) {
|
|
380
|
+
ended = true
|
|
381
|
+
const duration = Date.now() - startTime
|
|
382
|
+
adapter.logger?.debug(
|
|
383
|
+
{ spanId, spanName, tracerName: name, durationMs: duration, attributes },
|
|
384
|
+
'Tracer span ended',
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
isRecording(): boolean {
|
|
390
|
+
return !ended
|
|
391
|
+
},
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
adapter.logger?.debug({ spanId, spanName, tracerName: name }, 'Tracer span started')
|
|
395
|
+
|
|
396
|
+
return tracerSpan
|
|
397
|
+
},
|
|
398
|
+
}
|
|
399
|
+
}
|
|
307
400
|
}
|
|
308
401
|
|
|
309
402
|
/**
|
package/src/telemetry/noop.ts
CHANGED
|
@@ -8,8 +8,41 @@ import {
|
|
|
8
8
|
type StartJobSpanOptions,
|
|
9
9
|
type StartStepSpanOptions,
|
|
10
10
|
TelemetryAdapter,
|
|
11
|
+
type Tracer,
|
|
12
|
+
type TracerSpan,
|
|
11
13
|
} from './adapter.js'
|
|
12
14
|
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Noop Tracer Span
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
const noopTracerSpan: TracerSpan = {
|
|
20
|
+
setAttribute() {
|
|
21
|
+
// No-op
|
|
22
|
+
},
|
|
23
|
+
setAttributes() {
|
|
24
|
+
// No-op
|
|
25
|
+
},
|
|
26
|
+
addEvent() {
|
|
27
|
+
// No-op
|
|
28
|
+
},
|
|
29
|
+
recordException() {
|
|
30
|
+
// No-op
|
|
31
|
+
},
|
|
32
|
+
setStatusOk() {
|
|
33
|
+
// No-op
|
|
34
|
+
},
|
|
35
|
+
setStatusError() {
|
|
36
|
+
// No-op
|
|
37
|
+
},
|
|
38
|
+
end() {
|
|
39
|
+
// No-op
|
|
40
|
+
},
|
|
41
|
+
isRecording() {
|
|
42
|
+
return false
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
13
46
|
// ============================================================================
|
|
14
47
|
// Noop Telemetry Adapter
|
|
15
48
|
// ============================================================================
|
|
@@ -84,6 +117,19 @@ export class NoopTelemetryAdapter extends TelemetryAdapter {
|
|
|
84
117
|
protected async _addSpanAttribute(_options: AddSpanAttributeOptions): Promise<void> {
|
|
85
118
|
// No-op
|
|
86
119
|
}
|
|
120
|
+
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Tracer Methods
|
|
123
|
+
// ============================================================================
|
|
124
|
+
|
|
125
|
+
protected _getTracer(name: string): Tracer {
|
|
126
|
+
return {
|
|
127
|
+
name,
|
|
128
|
+
startSpan(): TracerSpan {
|
|
129
|
+
return noopTracerSpan
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
}
|
|
87
133
|
}
|
|
88
134
|
|
|
89
135
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Span as OTelSpan, Tracer, TracerProvider } from '@opentelemetry/api'
|
|
1
|
+
import type { Span as OTelSpan, Tracer as OTelTracer, TracerProvider } from '@opentelemetry/api'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type AddSpanAttributeOptions,
|
|
@@ -8,8 +8,11 @@ import {
|
|
|
8
8
|
type Span,
|
|
9
9
|
type StartDatabaseSpanOptions,
|
|
10
10
|
type StartJobSpanOptions,
|
|
11
|
+
type StartSpanOptions,
|
|
11
12
|
type StartStepSpanOptions,
|
|
12
13
|
TelemetryAdapter,
|
|
14
|
+
type Tracer,
|
|
15
|
+
type TracerSpan,
|
|
13
16
|
} from './adapter.js'
|
|
14
17
|
|
|
15
18
|
// ============================================================================
|
|
@@ -52,8 +55,9 @@ export class OpenTelemetryAdapter extends TelemetryAdapter {
|
|
|
52
55
|
#serviceName: string
|
|
53
56
|
#tracerProvider: TracerProvider | null
|
|
54
57
|
#traceDatabaseQueries: boolean
|
|
55
|
-
#tracer:
|
|
58
|
+
#tracer: OTelTracer | null = null
|
|
56
59
|
#spanMap = new Map<string, OTelSpan>()
|
|
60
|
+
#tracerCache = new Map<string, Tracer>()
|
|
57
61
|
|
|
58
62
|
constructor(options: OpenTelemetryAdapterOptions = {}) {
|
|
59
63
|
super()
|
|
@@ -298,6 +302,145 @@ export class OpenTelemetryAdapter extends TelemetryAdapter {
|
|
|
298
302
|
extSpan.otelSpan.setAttribute(options.key, options.value)
|
|
299
303
|
}
|
|
300
304
|
}
|
|
305
|
+
|
|
306
|
+
// ============================================================================
|
|
307
|
+
// Tracer Methods
|
|
308
|
+
// ============================================================================
|
|
309
|
+
|
|
310
|
+
protected _getTracer(name: string): Tracer {
|
|
311
|
+
// Return cached tracer if available
|
|
312
|
+
const cached = this.#tracerCache.get(name)
|
|
313
|
+
if (cached) {
|
|
314
|
+
return cached
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const adapter = this
|
|
318
|
+
|
|
319
|
+
const tracer: Tracer = {
|
|
320
|
+
name,
|
|
321
|
+
|
|
322
|
+
startSpan(spanName: string, options?: StartSpanOptions): TracerSpan {
|
|
323
|
+
// We need to dynamically get the OpenTelemetry API
|
|
324
|
+
// Since _getTracer is synchronous, we need to handle this carefully
|
|
325
|
+
let otelSpan: OTelSpan | null = null
|
|
326
|
+
let api: typeof import('@opentelemetry/api') | null = null
|
|
327
|
+
let ended = false
|
|
328
|
+
|
|
329
|
+
// Initialize the span asynchronously but return synchronously
|
|
330
|
+
const initPromise = (async () => {
|
|
331
|
+
api = await import('@opentelemetry/api')
|
|
332
|
+
|
|
333
|
+
// Get the tracer
|
|
334
|
+
let otelTracer: OTelTracer
|
|
335
|
+
if (adapter.#tracerProvider) {
|
|
336
|
+
otelTracer = adapter.#tracerProvider.getTracer(name)
|
|
337
|
+
} else {
|
|
338
|
+
otelTracer = api.trace.getTracer(name)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Map kind
|
|
342
|
+
let spanKind = api.SpanKind.INTERNAL
|
|
343
|
+
if (options?.kind === 'client') spanKind = api.SpanKind.CLIENT
|
|
344
|
+
else if (options?.kind === 'server') spanKind = api.SpanKind.SERVER
|
|
345
|
+
else if (options?.kind === 'producer') spanKind = api.SpanKind.PRODUCER
|
|
346
|
+
else if (options?.kind === 'consumer') spanKind = api.SpanKind.CONSUMER
|
|
347
|
+
|
|
348
|
+
// Get parent context
|
|
349
|
+
let parentContext = api.context.active()
|
|
350
|
+
if (options?.parentSpan) {
|
|
351
|
+
const parentOtelSpan = (options.parentSpan as any)._otelSpan as OTelSpan | undefined
|
|
352
|
+
if (parentOtelSpan) {
|
|
353
|
+
parentContext = api.trace.setSpan(api.context.active(), parentOtelSpan)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
otelSpan = otelTracer.startSpan(
|
|
358
|
+
spanName,
|
|
359
|
+
{
|
|
360
|
+
kind: spanKind,
|
|
361
|
+
attributes: options?.attributes,
|
|
362
|
+
},
|
|
363
|
+
parentContext,
|
|
364
|
+
)
|
|
365
|
+
})()
|
|
366
|
+
|
|
367
|
+
const tracerSpan: TracerSpan & { _otelSpan?: OTelSpan } = {
|
|
368
|
+
setAttribute(key: string, value: string | number | boolean): void {
|
|
369
|
+
initPromise.then(() => {
|
|
370
|
+
if (otelSpan && !ended) {
|
|
371
|
+
otelSpan.setAttribute(key, value)
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
setAttributes(attributes: Record<string, string | number | boolean>): void {
|
|
377
|
+
initPromise.then(() => {
|
|
378
|
+
if (otelSpan && !ended) {
|
|
379
|
+
otelSpan.setAttributes(attributes)
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
addEvent(eventName: string, attributes?: Record<string, string | number | boolean>): void {
|
|
385
|
+
initPromise.then(() => {
|
|
386
|
+
if (otelSpan && !ended) {
|
|
387
|
+
otelSpan.addEvent(eventName, attributes)
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
},
|
|
391
|
+
|
|
392
|
+
recordException(error: Error): void {
|
|
393
|
+
initPromise.then(() => {
|
|
394
|
+
if (otelSpan && !ended) {
|
|
395
|
+
otelSpan.recordException(error)
|
|
396
|
+
}
|
|
397
|
+
})
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
setStatusOk(): void {
|
|
401
|
+
initPromise.then(() => {
|
|
402
|
+
if (otelSpan && api && !ended) {
|
|
403
|
+
otelSpan.setStatus({ code: api.SpanStatusCode.OK })
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
setStatusError(message?: string): void {
|
|
409
|
+
initPromise.then(() => {
|
|
410
|
+
if (otelSpan && api && !ended) {
|
|
411
|
+
otelSpan.setStatus({ code: api.SpanStatusCode.ERROR, message })
|
|
412
|
+
}
|
|
413
|
+
})
|
|
414
|
+
},
|
|
415
|
+
|
|
416
|
+
end(): void {
|
|
417
|
+
initPromise.then(() => {
|
|
418
|
+
if (otelSpan && !ended) {
|
|
419
|
+
ended = true
|
|
420
|
+
otelSpan.end()
|
|
421
|
+
}
|
|
422
|
+
})
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
isRecording(): boolean {
|
|
426
|
+
return otelSpan?.isRecording() ?? false
|
|
427
|
+
},
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Store reference for parent context propagation
|
|
431
|
+
initPromise.then(() => {
|
|
432
|
+
if (otelSpan) {
|
|
433
|
+
;(tracerSpan as any)._otelSpan = otelSpan
|
|
434
|
+
}
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
return tracerSpan
|
|
438
|
+
},
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.#tracerCache.set(name, tracer)
|
|
442
|
+
return tracer
|
|
443
|
+
}
|
|
301
444
|
}
|
|
302
445
|
|
|
303
446
|
/**
|