duron 0.3.0-beta.11 → 0.3.0-beta.13
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-job.d.ts +2 -2
- package/dist/action-job.d.ts.map +1 -1
- package/dist/action-job.js +30 -24
- package/dist/action-manager.d.ts +2 -2
- package/dist/action-manager.d.ts.map +1 -1
- package/dist/action-manager.js +3 -3
- package/dist/action.d.ts +7 -7
- package/dist/action.d.ts.map +1 -1
- package/dist/adapters/adapter.d.ts +24 -26
- package/dist/adapters/adapter.d.ts.map +1 -1
- package/dist/adapters/adapter.js +25 -27
- package/dist/adapters/postgres/base.d.ts +21 -9
- package/dist/adapters/postgres/base.d.ts.map +1 -1
- package/dist/adapters/postgres/base.js +157 -62
- package/dist/adapters/postgres/schema.d.ts +118 -35
- package/dist/adapters/postgres/schema.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.d.ts +119 -36
- package/dist/adapters/postgres/schema.default.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.js +2 -2
- package/dist/adapters/postgres/schema.js +45 -22
- package/dist/adapters/schemas.d.ts +98 -80
- package/dist/adapters/schemas.d.ts.map +1 -1
- package/dist/adapters/schemas.js +59 -26
- package/dist/client.d.ts +106 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +90 -30
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/server.d.ts +51 -41
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +27 -27
- package/dist/step-manager.d.ts +30 -6
- package/dist/step-manager.d.ts.map +1 -1
- package/dist/step-manager.js +124 -85
- package/dist/telemetry/index.d.ts +1 -4
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -5
- package/dist/telemetry/local-span-exporter.d.ts +56 -0
- package/dist/telemetry/local-span-exporter.d.ts.map +1 -0
- package/dist/telemetry/local-span-exporter.js +118 -0
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/migration.sql +27 -19
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/snapshot.json +172 -65
- package/package.json +7 -2
- package/src/action-job.ts +32 -28
- package/src/action-manager.ts +5 -5
- package/src/action.ts +7 -7
- package/src/adapters/adapter.ts +54 -54
- package/src/adapters/postgres/base.ts +201 -70
- package/src/adapters/postgres/schema.default.ts +2 -2
- package/src/adapters/postgres/schema.ts +47 -23
- package/src/adapters/schemas.ts +72 -35
- package/src/client.ts +195 -42
- package/src/index.ts +1 -0
- package/src/server.ts +37 -37
- package/src/step-manager.ts +170 -86
- package/src/telemetry/index.ts +2 -20
- package/src/telemetry/local-span-exporter.ts +148 -0
- package/src/telemetry/adapter.ts +0 -642
- package/src/telemetry/local.ts +0 -429
- package/src/telemetry/noop.ts +0 -141
- package/src/telemetry/opentelemetry.ts +0 -453
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { JobSortFieldSchema,
|
|
3
|
+
import { JobSortFieldSchema, SortOrderSchema, SpanSortFieldSchema } from './adapters/schemas.js';
|
|
4
4
|
import type { Client } from './client.js';
|
|
5
5
|
/**
|
|
6
6
|
* Error thrown when a requested resource is not found.
|
|
@@ -166,34 +166,26 @@ export declare const GetActionsMetadataResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
166
166
|
}, z.core.$strip>>;
|
|
167
167
|
export type GetJobsQueryInput = z.input<typeof GetJobsQuerySchema>;
|
|
168
168
|
export type GetJobStepsQueryInput = z.input<typeof GetJobStepsQuerySchema>;
|
|
169
|
-
export declare const
|
|
169
|
+
export declare const GetSpansQuerySchema: z.ZodPipe<z.ZodObject<{
|
|
170
170
|
fName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
span_event: "span_event";
|
|
174
|
-
span_attribute: "span_attribute";
|
|
175
|
-
}>, z.ZodArray<z.ZodEnum<{
|
|
176
|
-
metric: "metric";
|
|
177
|
-
span_event: "span_event";
|
|
178
|
-
span_attribute: "span_attribute";
|
|
179
|
-
}>>]>>;
|
|
180
|
-
fTimestampRange: z.ZodOptional<z.ZodArray<z.ZodCoercedDate<unknown>>>;
|
|
171
|
+
fKind: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>]>>;
|
|
172
|
+
fTraceId: z.ZodOptional<z.ZodString>;
|
|
181
173
|
fAttributesFilter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
182
174
|
sort: z.ZodOptional<z.ZodString>;
|
|
183
175
|
}, z.core.$strip>, z.ZodTransform<{
|
|
184
176
|
filters: any;
|
|
185
177
|
sort: {
|
|
186
|
-
field: z.infer<typeof
|
|
178
|
+
field: z.infer<typeof SpanSortFieldSchema>;
|
|
187
179
|
order: z.infer<typeof SortOrderSchema>;
|
|
188
180
|
} | undefined;
|
|
189
181
|
}, {
|
|
190
182
|
fName?: string | string[] | undefined;
|
|
191
|
-
|
|
192
|
-
|
|
183
|
+
fKind?: 0 | 4 | 1 | 3 | 2 | (0 | 4 | 1 | 3 | 2)[] | undefined;
|
|
184
|
+
fTraceId?: string | undefined;
|
|
193
185
|
fAttributesFilter?: Record<string, any> | undefined;
|
|
194
186
|
sort?: string | undefined;
|
|
195
187
|
}>>;
|
|
196
|
-
export type
|
|
188
|
+
export type GetSpansQueryInput = z.input<typeof GetSpansQuerySchema>;
|
|
197
189
|
export declare const ErrorResponseSchema: z.ZodObject<{
|
|
198
190
|
error: z.ZodString;
|
|
199
191
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -224,12 +216,12 @@ export interface CreateServerOptions<P extends string> {
|
|
|
224
216
|
*/
|
|
225
217
|
prefix?: P;
|
|
226
218
|
/**
|
|
227
|
-
* Enable
|
|
228
|
-
* Only works when client is configured with
|
|
229
|
-
* When true, enables the dashboard to show
|
|
230
|
-
* @default auto-detected from client.
|
|
219
|
+
* Enable spans endpoints (/jobs/:id/spans, /steps/:id/spans).
|
|
220
|
+
* Only works when client is configured with telemetry.local enabled.
|
|
221
|
+
* When true, enables the dashboard to show spans buttons.
|
|
222
|
+
* @default auto-detected from client.spansEnabled
|
|
231
223
|
*/
|
|
232
|
-
|
|
224
|
+
spansEnabled?: boolean;
|
|
233
225
|
login?: {
|
|
234
226
|
onLogin: (body: {
|
|
235
227
|
email: string;
|
|
@@ -253,7 +245,7 @@ export interface CreateServerOptions<P extends string> {
|
|
|
253
245
|
* @param options - Configuration options
|
|
254
246
|
* @returns Elysia server instance
|
|
255
247
|
*/
|
|
256
|
-
export declare function createServer<P extends string>({ client, prefix, login,
|
|
248
|
+
export declare function createServer<P extends string>({ client, prefix, login, spansEnabled }: CreateServerOptions<P>): Elysia<P, {
|
|
257
249
|
decorator: {};
|
|
258
250
|
store: {};
|
|
259
251
|
derive: {};
|
|
@@ -1185,7 +1177,7 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1185
1177
|
headers: unknown;
|
|
1186
1178
|
response: {
|
|
1187
1179
|
200: {
|
|
1188
|
-
|
|
1180
|
+
spansEnabled: boolean;
|
|
1189
1181
|
authEnabled: boolean;
|
|
1190
1182
|
};
|
|
1191
1183
|
422: {
|
|
@@ -1203,7 +1195,7 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1203
1195
|
};
|
|
1204
1196
|
};
|
|
1205
1197
|
};
|
|
1206
|
-
}> & import("elysia").CreateEden<`${P}/jobs/:id/
|
|
1198
|
+
}> & import("elysia").CreateEden<`${P}/jobs/:id/spans`, {
|
|
1207
1199
|
get: {
|
|
1208
1200
|
body: {};
|
|
1209
1201
|
params: {
|
|
@@ -1212,7 +1204,7 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1212
1204
|
query: {
|
|
1213
1205
|
filters: any;
|
|
1214
1206
|
sort: {
|
|
1215
|
-
field: z.infer<typeof
|
|
1207
|
+
field: z.infer<typeof SpanSortFieldSchema>;
|
|
1216
1208
|
order: z.infer<typeof SortOrderSchema>;
|
|
1217
1209
|
} | undefined;
|
|
1218
1210
|
};
|
|
@@ -1221,16 +1213,25 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1221
1213
|
};
|
|
1222
1214
|
response: {
|
|
1223
1215
|
200: {
|
|
1224
|
-
|
|
1225
|
-
id:
|
|
1226
|
-
|
|
1216
|
+
spans: {
|
|
1217
|
+
id: number;
|
|
1218
|
+
traceId: string;
|
|
1219
|
+
spanId: string;
|
|
1220
|
+
parentSpanId: string | null;
|
|
1221
|
+
jobId: string | null;
|
|
1227
1222
|
stepId: string | null;
|
|
1228
1223
|
name: string;
|
|
1229
|
-
|
|
1224
|
+
kind: 0 | 4 | 1 | 3 | 2;
|
|
1225
|
+
startTimeUnixNano: string | null;
|
|
1226
|
+
endTimeUnixNano: string | null;
|
|
1227
|
+
statusCode: 0 | 1 | 2;
|
|
1228
|
+
statusMessage: string | null;
|
|
1230
1229
|
attributes: Record<string, any>;
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1230
|
+
events: {
|
|
1231
|
+
name: string;
|
|
1232
|
+
timeUnixNano: string;
|
|
1233
|
+
attributes?: Record<string, any> | undefined;
|
|
1234
|
+
}[];
|
|
1234
1235
|
}[];
|
|
1235
1236
|
total: number;
|
|
1236
1237
|
};
|
|
@@ -1257,7 +1258,7 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1257
1258
|
};
|
|
1258
1259
|
};
|
|
1259
1260
|
};
|
|
1260
|
-
}> & import("elysia").CreateEden<`${P}/steps/:id/
|
|
1261
|
+
}> & import("elysia").CreateEden<`${P}/steps/:id/spans`, {
|
|
1261
1262
|
get: {
|
|
1262
1263
|
body: {};
|
|
1263
1264
|
params: {
|
|
@@ -1266,7 +1267,7 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1266
1267
|
query: {
|
|
1267
1268
|
filters: any;
|
|
1268
1269
|
sort: {
|
|
1269
|
-
field: z.infer<typeof
|
|
1270
|
+
field: z.infer<typeof SpanSortFieldSchema>;
|
|
1270
1271
|
order: z.infer<typeof SortOrderSchema>;
|
|
1271
1272
|
} | undefined;
|
|
1272
1273
|
};
|
|
@@ -1275,16 +1276,25 @@ export declare function createServer<P extends string>({ client, prefix, login,
|
|
|
1275
1276
|
};
|
|
1276
1277
|
response: {
|
|
1277
1278
|
200: {
|
|
1278
|
-
|
|
1279
|
-
id:
|
|
1280
|
-
|
|
1279
|
+
spans: {
|
|
1280
|
+
id: number;
|
|
1281
|
+
traceId: string;
|
|
1282
|
+
spanId: string;
|
|
1283
|
+
parentSpanId: string | null;
|
|
1284
|
+
jobId: string | null;
|
|
1281
1285
|
stepId: string | null;
|
|
1282
1286
|
name: string;
|
|
1283
|
-
|
|
1287
|
+
kind: 0 | 4 | 1 | 3 | 2;
|
|
1288
|
+
startTimeUnixNano: string | null;
|
|
1289
|
+
endTimeUnixNano: string | null;
|
|
1290
|
+
statusCode: 0 | 1 | 2;
|
|
1291
|
+
statusMessage: string | null;
|
|
1284
1292
|
attributes: Record<string, any>;
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1293
|
+
events: {
|
|
1294
|
+
name: string;
|
|
1295
|
+
timeUnixNano: string;
|
|
1296
|
+
attributes?: Record<string, any> | undefined;
|
|
1297
|
+
}[];
|
|
1288
1298
|
}[];
|
|
1289
1299
|
total: number;
|
|
1290
1300
|
};
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts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C,OAAO,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAiFhF,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;uBAAS,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA3E,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;uBAAS,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiqBjG"}
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { jwtVerify, SignJWT } from 'jose';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { GetActionsResultSchema, GetJobStepsResultSchema, GetJobsResultSchema,
|
|
4
|
+
import { GetActionsResultSchema, GetJobStepsResultSchema, GetJobsResultSchema, GetSpansResultSchema, JobSchema, JobSortFieldSchema, JobStatusResultSchema, JobStatusSchema, JobStepSchema, JobStepStatusResultSchema, SortOrderSchema, SpanKindSchema, SpanSortFieldSchema, } from './adapters/schemas.js';
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// Custom Errors
|
|
7
7
|
// ============================================================================
|
|
@@ -144,13 +144,13 @@ export const GetActionsMetadataResponseSchema = z.array(z.object({
|
|
|
144
144
|
name: z.string(),
|
|
145
145
|
mockInput: z.any(),
|
|
146
146
|
}));
|
|
147
|
-
//
|
|
148
|
-
export const
|
|
147
|
+
// Spans query schema
|
|
148
|
+
export const GetSpansQuerySchema = z
|
|
149
149
|
.object({
|
|
150
150
|
// Filters
|
|
151
151
|
fName: z.union([z.string(), z.array(z.string())]).optional(),
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
fKind: z.union([SpanKindSchema, z.array(SpanKindSchema)]).optional(),
|
|
153
|
+
fTraceId: z.string().optional(),
|
|
154
154
|
fAttributesFilter: z.record(z.string(), z.any()).optional(),
|
|
155
155
|
// Sort - format: "field:asc" or "field:desc"
|
|
156
156
|
sort: z.string().optional(),
|
|
@@ -159,10 +159,10 @@ export const GetMetricsQuerySchema = z
|
|
|
159
159
|
const filters = {};
|
|
160
160
|
if (data.fName)
|
|
161
161
|
filters.name = data.fName;
|
|
162
|
-
if (data.
|
|
163
|
-
filters.
|
|
164
|
-
if (data.
|
|
165
|
-
filters.
|
|
162
|
+
if (data.fKind)
|
|
163
|
+
filters.kind = data.fKind;
|
|
164
|
+
if (data.fTraceId)
|
|
165
|
+
filters.traceId = data.fTraceId;
|
|
166
166
|
if (data.fAttributesFilter)
|
|
167
167
|
filters.attributesFilter = data.fAttributesFilter;
|
|
168
168
|
// Parse sort string: "field:asc" -> { field: 'field', order: 'asc' }
|
|
@@ -170,7 +170,7 @@ export const GetMetricsQuerySchema = z
|
|
|
170
170
|
if (data.sort) {
|
|
171
171
|
const [field, order] = data.sort.split(':').map((s) => s.trim());
|
|
172
172
|
if (field && order) {
|
|
173
|
-
const fieldResult =
|
|
173
|
+
const fieldResult = SpanSortFieldSchema.safeParse(field);
|
|
174
174
|
const orderResult = SortOrderSchema.safeParse(order.toLowerCase());
|
|
175
175
|
if (fieldResult.success && orderResult.success) {
|
|
176
176
|
sort = {
|
|
@@ -218,12 +218,12 @@ export const TimeTravelJobResponseSchema = z.object({
|
|
|
218
218
|
* @param options - Configuration options
|
|
219
219
|
* @returns Elysia server instance
|
|
220
220
|
*/
|
|
221
|
-
export function createServer({ client, prefix, login,
|
|
221
|
+
export function createServer({ client, prefix, login, spansEnabled }) {
|
|
222
222
|
// Convert string secret to Uint8Array if needed
|
|
223
223
|
const secretKey = typeof login?.jwtSecret === 'string' ? new TextEncoder().encode(login?.jwtSecret) : login?.jwtSecret;
|
|
224
224
|
const routePrefix = (prefix ?? '/api');
|
|
225
|
-
// Auto-detect
|
|
226
|
-
const
|
|
225
|
+
// Auto-detect spansEnabled from client if not explicitly set
|
|
226
|
+
const isSpansEnabled = spansEnabled ?? client.spansEnabled;
|
|
227
227
|
return new Elysia({
|
|
228
228
|
prefix: routePrefix,
|
|
229
229
|
})
|
|
@@ -523,54 +523,54 @@ export function createServer({ client, prefix, login, metricsEnabled }) {
|
|
|
523
523
|
})
|
|
524
524
|
.get('/config', async () => {
|
|
525
525
|
return {
|
|
526
|
-
|
|
526
|
+
spansEnabled: isSpansEnabled,
|
|
527
527
|
authEnabled: !!login,
|
|
528
528
|
};
|
|
529
529
|
}, {
|
|
530
530
|
response: {
|
|
531
531
|
200: z.object({
|
|
532
|
-
|
|
532
|
+
spansEnabled: z.boolean(),
|
|
533
533
|
authEnabled: z.boolean(),
|
|
534
534
|
}),
|
|
535
535
|
500: ErrorResponseSchema,
|
|
536
536
|
},
|
|
537
537
|
})
|
|
538
|
-
.get('/jobs/:id/
|
|
539
|
-
if (!
|
|
540
|
-
throw new Error('
|
|
538
|
+
.get('/jobs/:id/spans', async ({ params, query }) => {
|
|
539
|
+
if (!isSpansEnabled) {
|
|
540
|
+
throw new Error('Spans are not enabled. Enable telemetry.local to enable spans.');
|
|
541
541
|
}
|
|
542
542
|
const options = {
|
|
543
543
|
jobId: params.id,
|
|
544
544
|
filters: query.filters,
|
|
545
545
|
sort: query.sort,
|
|
546
546
|
};
|
|
547
|
-
return client.
|
|
547
|
+
return client.getSpans(options);
|
|
548
548
|
}, {
|
|
549
549
|
params: JobIdParamsSchema,
|
|
550
|
-
query:
|
|
550
|
+
query: GetSpansQuerySchema,
|
|
551
551
|
response: {
|
|
552
|
-
200:
|
|
552
|
+
200: GetSpansResultSchema,
|
|
553
553
|
400: ErrorResponseSchema,
|
|
554
554
|
500: ErrorResponseSchema,
|
|
555
555
|
401: ErrorResponseSchema,
|
|
556
556
|
},
|
|
557
557
|
auth: true,
|
|
558
558
|
})
|
|
559
|
-
.get('/steps/:id/
|
|
560
|
-
if (!
|
|
561
|
-
throw new Error('
|
|
559
|
+
.get('/steps/:id/spans', async ({ params, query }) => {
|
|
560
|
+
if (!isSpansEnabled) {
|
|
561
|
+
throw new Error('Spans are not enabled. Enable telemetry.local to enable spans.');
|
|
562
562
|
}
|
|
563
563
|
const options = {
|
|
564
564
|
stepId: params.id,
|
|
565
565
|
filters: query.filters,
|
|
566
566
|
sort: query.sort,
|
|
567
567
|
};
|
|
568
|
-
return client.
|
|
568
|
+
return client.getSpans(options);
|
|
569
569
|
}, {
|
|
570
570
|
params: StepIdParamsSchema,
|
|
571
|
-
query:
|
|
571
|
+
query: GetSpansQuerySchema,
|
|
572
572
|
response: {
|
|
573
|
-
200:
|
|
573
|
+
200: GetSpansResultSchema,
|
|
574
574
|
400: ErrorResponseSchema,
|
|
575
575
|
500: ErrorResponseSchema,
|
|
576
576
|
401: ErrorResponseSchema,
|
package/dist/step-manager.d.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
+
import { type Span, type Tracer } from '@opentelemetry/api';
|
|
1
2
|
import type { Logger } from 'pino';
|
|
2
3
|
import type { z } from 'zod';
|
|
3
4
|
import { type Action, type ActionHandlerContext, type StepHandlerContext, type StepOptions } from './action.js';
|
|
4
5
|
import type { Adapter } from './adapters/adapter.js';
|
|
5
6
|
import { type StepStatus } from './constants.js';
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Telemetry context provided to action and step handlers.
|
|
9
|
+
* Provides access to OpenTelemetry APIs for recording traces and metrics.
|
|
10
|
+
*/
|
|
11
|
+
export interface TelemetryContext {
|
|
12
|
+
/**
|
|
13
|
+
* Get the active OpenTelemetry span for the current job/step.
|
|
14
|
+
*/
|
|
15
|
+
getActiveSpan(): Span | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Get an OpenTelemetry tracer for creating custom spans.
|
|
18
|
+
*/
|
|
19
|
+
getTracer(name: string): Tracer;
|
|
20
|
+
/**
|
|
21
|
+
* Start a new span as a child of the current job/step span.
|
|
22
|
+
* This is a convenience method that properly links the span to the trace hierarchy.
|
|
23
|
+
*/
|
|
24
|
+
startSpan(name: string, options?: {
|
|
25
|
+
attributes?: Record<string, any>;
|
|
26
|
+
}): Span;
|
|
27
|
+
/**
|
|
28
|
+
* Record a custom metric as a span event.
|
|
29
|
+
*/
|
|
30
|
+
recordMetric(name: string, value: number, attributes?: Record<string, any>): void;
|
|
31
|
+
}
|
|
7
32
|
export interface TaskStep {
|
|
8
33
|
name: string;
|
|
9
34
|
cb: (ctx: StepHandlerContext) => Promise<any>;
|
|
@@ -71,7 +96,7 @@ export interface StepManagerOptions {
|
|
|
71
96
|
jobId: string;
|
|
72
97
|
actionName: string;
|
|
73
98
|
adapter: Adapter;
|
|
74
|
-
|
|
99
|
+
tracer: Tracer;
|
|
75
100
|
logger: Logger;
|
|
76
101
|
concurrencyLimit: number;
|
|
77
102
|
}
|
|
@@ -108,18 +133,17 @@ export declare class StepManager {
|
|
|
108
133
|
* @param variables - Variables available to the action
|
|
109
134
|
* @param abortSignal - Abort signal for cancelling the action
|
|
110
135
|
* @param logger - Pino child logger for this job
|
|
111
|
-
* @param observeContext - Observability context for telemetry
|
|
112
136
|
* @returns ActionHandlerContext instance
|
|
113
137
|
*/
|
|
114
138
|
createActionContext<TInput extends z.ZodObject, TOutput extends z.ZodObject, TVariables = Record<string, unknown>>(job: {
|
|
115
139
|
id: string;
|
|
116
140
|
input: z.infer<TInput>;
|
|
117
141
|
groupKey?: string;
|
|
118
|
-
}, action: Action<TInput, TOutput, TVariables>, variables: TVariables, abortSignal: AbortSignal, logger: Logger
|
|
142
|
+
}, action: Action<TInput, TOutput, TVariables>, variables: TVariables, abortSignal: AbortSignal, logger: Logger): ActionHandlerContext<TInput, TVariables>;
|
|
119
143
|
/**
|
|
120
|
-
* Create
|
|
144
|
+
* Create a telemetry context for a step.
|
|
121
145
|
*/
|
|
122
|
-
|
|
146
|
+
createStepTelemetryContext(stepId: string): TelemetryContext;
|
|
123
147
|
/**
|
|
124
148
|
* Queue a step task for execution.
|
|
125
149
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-manager.d.ts","sourceRoot":"","sources":["../src/step-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-manager.d.ts","sourceRoot":"","sources":["../src/step-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EAIT,KAAK,MAAM,EAEZ,MAAM,oBAAoB,CAAA;AAE3B,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;AAalH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,aAAa,IAAI,IAAI,GAAG,SAAS,CAAA;IAEjC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAE/B;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,IAAI,CAAA;IA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