@teamkeel/functions-runtime 0.421.2 → 0.421.3

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/index.d.cts CHANGED
@@ -216,14 +216,18 @@ declare function withSpan(name: any, fn: any): Promise<any>;
216
216
  declare function init(): void;
217
217
  declare function forceFlush(): Promise<void>;
218
218
  declare function spanNameForModelAPI(modelName: any, action: any): string;
219
+ declare const KEEL_INTERNAL_ATTR: "keel_internal";
220
+ declare const KEEL_INTERNAL_CHILDREN: "includeChildrenSpans";
219
221
 
222
+ declare const tracing_KEEL_INTERNAL_ATTR: typeof KEEL_INTERNAL_ATTR;
223
+ declare const tracing_KEEL_INTERNAL_CHILDREN: typeof KEEL_INTERNAL_CHILDREN;
220
224
  declare const tracing_forceFlush: typeof forceFlush;
221
225
  declare const tracing_getTracer: typeof getTracer;
222
226
  declare const tracing_init: typeof init;
223
227
  declare const tracing_spanNameForModelAPI: typeof spanNameForModelAPI;
224
228
  declare const tracing_withSpan: typeof withSpan;
225
229
  declare namespace tracing {
226
- export { tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
230
+ export { tracing_KEEL_INTERNAL_ATTR as KEEL_INTERNAL_ATTR, tracing_KEEL_INTERNAL_CHILDREN as KEEL_INTERNAL_CHILDREN, tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
227
231
  }
228
232
 
229
233
  type MimeType = "application/json" | "application/gzip" | "application/pdf" | "application/rtf" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-excel" | "application/vnd.ms-powerpoint" | "application/msword" | "application/zip" | "application/xml" | "application/x-7z-compressed" | "application/x-tar" | "image/gif" | "image/jpeg" | "image/svg+xml" | "image/png" | "text/html" | "text/csv" | "text/javascript" | "text/plain" | "text/calendar" | (string & {});
package/dist/index.d.ts CHANGED
@@ -216,14 +216,18 @@ declare function withSpan(name: any, fn: any): Promise<any>;
216
216
  declare function init(): void;
217
217
  declare function forceFlush(): Promise<void>;
218
218
  declare function spanNameForModelAPI(modelName: any, action: any): string;
219
+ declare const KEEL_INTERNAL_ATTR: "keel_internal";
220
+ declare const KEEL_INTERNAL_CHILDREN: "includeChildrenSpans";
219
221
 
222
+ declare const tracing_KEEL_INTERNAL_ATTR: typeof KEEL_INTERNAL_ATTR;
223
+ declare const tracing_KEEL_INTERNAL_CHILDREN: typeof KEEL_INTERNAL_CHILDREN;
220
224
  declare const tracing_forceFlush: typeof forceFlush;
221
225
  declare const tracing_getTracer: typeof getTracer;
222
226
  declare const tracing_init: typeof init;
223
227
  declare const tracing_spanNameForModelAPI: typeof spanNameForModelAPI;
224
228
  declare const tracing_withSpan: typeof withSpan;
225
229
  declare namespace tracing {
226
- export { tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
230
+ export { tracing_KEEL_INTERNAL_ATTR as KEEL_INTERNAL_ATTR, tracing_KEEL_INTERNAL_CHILDREN as KEEL_INTERNAL_CHILDREN, tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
227
231
  }
228
232
 
229
233
  type MimeType = "application/json" | "application/gzip" | "application/pdf" | "application/rtf" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-excel" | "application/vnd.ms-powerpoint" | "application/msword" | "application/zip" | "application/xml" | "application/x-7z-compressed" | "application/x-tar" | "image/gif" | "image/jpeg" | "image/svg+xml" | "image/png" | "text/html" | "text/csv" | "text/javascript" | "text/plain" | "text/calendar" | (string & {});
package/dist/index.js CHANGED
@@ -193,6 +193,8 @@ import { Pool as Pool2, Client, types as pgTypes } from "pg";
193
193
  // src/tracing.js
194
194
  var tracing_exports = {};
195
195
  __export(tracing_exports, {
196
+ KEEL_INTERNAL_ATTR: () => KEEL_INTERNAL_ATTR,
197
+ KEEL_INTERNAL_CHILDREN: () => KEEL_INTERNAL_CHILDREN,
196
198
  forceFlush: () => forceFlush,
197
199
  getTracer: () => getTracer,
198
200
  init: () => init,
@@ -209,11 +211,13 @@ async function withSpan(name, fn) {
209
211
  try {
210
212
  return await fn(span);
211
213
  } catch (err) {
212
- span.recordException(err);
213
- span.setStatus({
214
- code: opentelemetry.SpanStatusCode.ERROR,
215
- message: err.message
216
- });
214
+ if (err instanceof Error) {
215
+ span.recordException(err);
216
+ span.setStatus({
217
+ code: opentelemetry.SpanStatusCode.ERROR,
218
+ message: err.message
219
+ });
220
+ }
217
221
  throw err;
218
222
  } finally {
219
223
  span.end();
@@ -351,6 +355,8 @@ function spanNameForModelAPI(modelName, action) {
351
355
  return `Database ${modelName}.${action}`;
352
356
  }
353
357
  __name(spanNameForModelAPI, "spanNameForModelAPI");
358
+ var KEEL_INTERNAL_ATTR = "keel_internal";
359
+ var KEEL_INTERNAL_CHILDREN = "includeChildrenSpans";
354
360
 
355
361
  // src/database.ts
356
362
  import WebSocket from "ws";
@@ -419,6 +425,7 @@ var InstrumentedPool = class extends Pool2 {
419
425
  const _super = super.connect.bind(this);
420
426
  return withSpan("Database Connect", function(span) {
421
427
  span.setAttribute("dialect", process.env["KEEL_DB_CONN_TYPE"]);
428
+ span.setAttribute(KEEL_INTERNAL_ATTR, true);
422
429
  return _super.apply(null, args);
423
430
  });
424
431
  }
@@ -431,6 +438,7 @@ var InstrumentedNeonServerlessPool = class extends neon.Pool {
431
438
  const _super = super.connect.bind(this);
432
439
  return withSpan("Database Connect", function(span) {
433
440
  span.setAttribute("dialect", process.env["KEEL_DB_CONN_TYPE"]);
441
+ span.setAttribute(KEEL_INTERNAL_ATTR, true);
434
442
  return _super.apply(null, args);
435
443
  });
436
444
  }
@@ -3006,112 +3014,19 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
3006
3014
  };
3007
3015
  }, "complete"),
3008
3016
  step: /* @__PURE__ */ __name(async (name, optionsOrFn, fn) => {
3009
- const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
3010
- const actualFn = typeof optionsOrFn === "function" ? optionsOrFn : fn;
3011
- options.retries = options.retries ?? defaultOpts.retries;
3012
- options.timeout = options.timeout ?? defaultOpts.timeout;
3013
- const db = useDatabase();
3014
- if (usedNames.has(name)) {
3015
- await db.insertInto("keel.flow_step").values({
3016
- run_id: runId,
3017
- name,
3018
- stage: options.stage,
3019
- status: "FAILED" /* FAILED */,
3020
- type: "FUNCTION" /* FUNCTION */,
3021
- error: `Duplicate step name: ${name}`,
3022
- startTime: /* @__PURE__ */ new Date(),
3023
- endTime: /* @__PURE__ */ new Date()
3024
- }).returningAll().executeTakeFirst();
3025
- throw new Error(`Duplicate step name: ${name}`);
3026
- }
3027
- usedNames.add(name);
3028
- const past = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().execute();
3029
- const newSteps = past.filter((step) => step.status === "NEW" /* NEW */);
3030
- const completedSteps = past.filter(
3031
- (step) => step.status === "COMPLETED" /* COMPLETED */
3032
- );
3033
- const failedSteps = past.filter(
3034
- (step) => step.status === "FAILED" /* FAILED */
3035
- );
3036
- if (newSteps.length > 1) {
3037
- throw new Error("Multiple NEW steps found for the same step");
3038
- }
3039
- if (completedSteps.length > 1) {
3040
- throw new Error("Multiple completed steps found for the same step");
3041
- }
3042
- if (completedSteps.length > 1 && newSteps.length > 1) {
3043
- throw new Error(
3044
- "Multiple completed and new steps found for the same step"
3045
- );
3046
- }
3047
- if (completedSteps.length === 1) {
3048
- return completedSteps[0].value;
3049
- }
3050
- if (newSteps.length === 1) {
3051
- let result = null;
3052
- await db.updateTable("keel.flow_step").set({
3053
- startTime: /* @__PURE__ */ new Date()
3054
- }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3055
- try {
3056
- const stepArgs = {
3057
- attempt: failedSteps.length + 1,
3058
- stepOptions: options
3059
- };
3060
- result = await withTimeout(actualFn(stepArgs), options.timeout);
3061
- } catch (e) {
3062
- await db.updateTable("keel.flow_step").set({
3063
- status: "FAILED" /* FAILED */,
3064
- spanId,
3065
- endTime: /* @__PURE__ */ new Date(),
3066
- error: e instanceof Error ? e.message : "An error occurred"
3067
- }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3068
- if (failedSteps.length >= options.retries || e instanceof NonRetriableError) {
3069
- if (options.onFailure) {
3070
- await options.onFailure();
3071
- }
3072
- throw new ExhuastedRetriesDisrupt();
3073
- }
3074
- await db.insertInto("keel.flow_step").values({
3075
- run_id: runId,
3076
- name,
3077
- stage: options.stage,
3078
- status: "NEW" /* NEW */,
3079
- type: "FUNCTION" /* FUNCTION */
3080
- }).returningAll().executeTakeFirst();
3081
- throw new StepCreatedDisrupt(
3082
- options.retryPolicy ? new Date(
3083
- Date.now() + options.retryPolicy(failedSteps.length + 1)
3084
- ) : void 0
3085
- );
3086
- }
3087
- await db.updateTable("keel.flow_step").set({
3088
- status: "COMPLETED" /* COMPLETED */,
3089
- value: JSON.stringify(result),
3090
- spanId,
3091
- endTime: /* @__PURE__ */ new Date()
3092
- }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3093
- return result;
3094
- }
3095
- await db.insertInto("keel.flow_step").values({
3096
- run_id: runId,
3097
- name,
3098
- stage: options.stage,
3099
- status: "NEW" /* NEW */,
3100
- type: "FUNCTION" /* FUNCTION */
3101
- }).returningAll().executeTakeFirst();
3102
- throw new StepCreatedDisrupt();
3103
- }, "step"),
3104
- ui: {
3105
- page: /* @__PURE__ */ __name(async (name, options) => {
3017
+ return withSpan(`Step - ${name}`, async (span) => {
3018
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
3019
+ const actualFn = typeof optionsOrFn === "function" ? optionsOrFn : fn;
3020
+ options.retries = options.retries ?? defaultOpts.retries;
3021
+ options.timeout = options.timeout ?? defaultOpts.timeout;
3106
3022
  const db = useDatabase();
3107
- const isCallback = element && callback;
3108
3023
  if (usedNames.has(name)) {
3109
3024
  await db.insertInto("keel.flow_step").values({
3110
3025
  run_id: runId,
3111
3026
  name,
3112
3027
  stage: options.stage,
3113
3028
  status: "FAILED" /* FAILED */,
3114
- type: "UI" /* UI */,
3029
+ type: "FUNCTION" /* FUNCTION */,
3115
3030
  error: `Duplicate step name: ${name}`,
3116
3031
  startTime: /* @__PURE__ */ new Date(),
3117
3032
  endTime: /* @__PURE__ */ new Date()
@@ -3119,77 +3034,179 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
3119
3034
  throw new Error(`Duplicate step name: ${name}`);
3120
3035
  }
3121
3036
  usedNames.add(name);
3122
- let step = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
3123
- if (step && step.status === "COMPLETED" /* COMPLETED */) {
3124
- if (step.action) {
3125
- return { data: step.value, action: step.action };
3126
- }
3127
- return step.value;
3037
+ const past = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().execute();
3038
+ const newSteps = past.filter((step) => step.status === "NEW" /* NEW */);
3039
+ const completedSteps = past.filter(
3040
+ (step) => step.status === "COMPLETED" /* COMPLETED */
3041
+ );
3042
+ const failedSteps = past.filter(
3043
+ (step) => step.status === "FAILED" /* FAILED */
3044
+ );
3045
+ if (newSteps.length > 1) {
3046
+ throw new Error("Multiple NEW steps found for the same step");
3128
3047
  }
3129
- if (!step) {
3130
- step = await db.insertInto("keel.flow_step").values({
3131
- run_id: runId,
3132
- name,
3133
- stage: options.stage,
3134
- status: "PENDING" /* PENDING */,
3135
- type: "UI" /* UI */,
3136
- startTime: /* @__PURE__ */ new Date()
3137
- }).returningAll().executeTakeFirst();
3138
- throw new UIRenderDisrupt(
3139
- step?.id,
3140
- (await page(options, null, null)).page
3048
+ if (completedSteps.length > 1) {
3049
+ throw new Error("Multiple completed steps found for the same step");
3050
+ }
3051
+ if (completedSteps.length > 1 && newSteps.length > 1) {
3052
+ throw new Error(
3053
+ "Multiple completed and new steps found for the same step"
3141
3054
  );
3142
3055
  }
3143
- if (isCallback) {
3056
+ if (completedSteps.length === 1) {
3057
+ span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
3058
+ return completedSteps[0].value;
3059
+ }
3060
+ if (newSteps.length === 1) {
3061
+ let result = null;
3062
+ await db.updateTable("keel.flow_step").set({
3063
+ startTime: /* @__PURE__ */ new Date()
3064
+ }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3144
3065
  try {
3145
- const response = await callbackFn(
3146
- options.content,
3147
- element,
3148
- callback,
3149
- data
3150
- );
3151
- throw new CallbackDisrupt(response, false);
3066
+ const stepArgs = {
3067
+ attempt: failedSteps.length + 1,
3068
+ stepOptions: options
3069
+ };
3070
+ result = await withTimeout(actualFn(stepArgs), options.timeout);
3152
3071
  } catch (e) {
3153
- if (e instanceof CallbackDisrupt) {
3154
- throw e;
3072
+ await db.updateTable("keel.flow_step").set({
3073
+ status: "FAILED" /* FAILED */,
3074
+ spanId,
3075
+ endTime: /* @__PURE__ */ new Date(),
3076
+ error: e instanceof Error ? e.message : "An error occurred"
3077
+ }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3078
+ if (failedSteps.length >= options.retries || e instanceof NonRetriableError) {
3079
+ if (options.onFailure) {
3080
+ await options.onFailure();
3081
+ }
3082
+ throw new ExhuastedRetriesDisrupt();
3155
3083
  }
3156
- throw new CallbackDisrupt(
3157
- e instanceof Error ? e.message : `An error occurred`,
3158
- true
3084
+ await db.insertInto("keel.flow_step").values({
3085
+ run_id: runId,
3086
+ name,
3087
+ stage: options.stage,
3088
+ status: "NEW" /* NEW */,
3089
+ type: "FUNCTION" /* FUNCTION */
3090
+ }).returningAll().executeTakeFirst();
3091
+ throw new StepCreatedDisrupt(
3092
+ options.retryPolicy ? new Date(
3093
+ Date.now() + options.retryPolicy(failedSteps.length + 1)
3094
+ ) : void 0
3159
3095
  );
3160
3096
  }
3097
+ await db.updateTable("keel.flow_step").set({
3098
+ status: "COMPLETED" /* COMPLETED */,
3099
+ value: JSON.stringify(result),
3100
+ spanId,
3101
+ endTime: /* @__PURE__ */ new Date()
3102
+ }).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
3103
+ return result;
3161
3104
  }
3162
- if (!data) {
3163
- throw new UIRenderDisrupt(
3164
- step?.id,
3165
- (await page(options, null, null)).page
3166
- );
3167
- }
3168
- try {
3169
- const p = await page(options, data, action);
3170
- if (p.hasValidationErrors) {
3171
- throw new UIRenderDisrupt(step?.id, p.page);
3105
+ await db.insertInto("keel.flow_step").values({
3106
+ run_id: runId,
3107
+ name,
3108
+ stage: options.stage,
3109
+ status: "NEW" /* NEW */,
3110
+ type: "FUNCTION" /* FUNCTION */
3111
+ }).returningAll().executeTakeFirst();
3112
+ span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
3113
+ throw new StepCreatedDisrupt();
3114
+ });
3115
+ }, "step"),
3116
+ ui: {
3117
+ page: /* @__PURE__ */ __name(async (name, options) => {
3118
+ return withSpan(`Page - ${name}`, async (span) => {
3119
+ const db = useDatabase();
3120
+ const isCallback = element && callback;
3121
+ if (usedNames.has(name)) {
3122
+ await db.insertInto("keel.flow_step").values({
3123
+ run_id: runId,
3124
+ name,
3125
+ stage: options.stage,
3126
+ status: "FAILED" /* FAILED */,
3127
+ type: "UI" /* UI */,
3128
+ error: `Duplicate step name: ${name}`,
3129
+ startTime: /* @__PURE__ */ new Date(),
3130
+ endTime: /* @__PURE__ */ new Date()
3131
+ }).returningAll().executeTakeFirst();
3132
+ throw new Error(`Duplicate step name: ${name}`);
3172
3133
  }
3173
- } catch (e) {
3174
- if (e instanceof UIRenderDisrupt) {
3134
+ usedNames.add(name);
3135
+ let step = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
3136
+ if (step && step.status === "COMPLETED" /* COMPLETED */) {
3137
+ span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
3138
+ if (step.action) {
3139
+ return { data: step.value, action: step.action };
3140
+ }
3141
+ return step.value;
3142
+ }
3143
+ if (!step) {
3144
+ step = await db.insertInto("keel.flow_step").values({
3145
+ run_id: runId,
3146
+ name,
3147
+ stage: options.stage,
3148
+ status: "PENDING" /* PENDING */,
3149
+ type: "UI" /* UI */,
3150
+ startTime: /* @__PURE__ */ new Date()
3151
+ }).returningAll().executeTakeFirst();
3152
+ span.setAttribute("rendered", true);
3153
+ throw new UIRenderDisrupt(
3154
+ step?.id,
3155
+ (await page(options, null, null)).page
3156
+ );
3157
+ }
3158
+ if (isCallback) {
3159
+ span.setAttribute("callback", callback);
3160
+ try {
3161
+ const response = await callbackFn(
3162
+ options.content,
3163
+ element,
3164
+ callback,
3165
+ data
3166
+ );
3167
+ throw new CallbackDisrupt(response, false);
3168
+ } catch (e) {
3169
+ if (e instanceof CallbackDisrupt) {
3170
+ throw e;
3171
+ }
3172
+ throw new CallbackDisrupt(
3173
+ e instanceof Error ? e.message : `An error occurred`,
3174
+ true
3175
+ );
3176
+ }
3177
+ }
3178
+ if (!data) {
3179
+ throw new UIRenderDisrupt(
3180
+ step?.id,
3181
+ (await page(options, null, null)).page
3182
+ );
3183
+ }
3184
+ try {
3185
+ const p = await page(options, data, action);
3186
+ if (p.hasValidationErrors) {
3187
+ throw new UIRenderDisrupt(step?.id, p.page);
3188
+ }
3189
+ } catch (e) {
3190
+ if (e instanceof UIRenderDisrupt) {
3191
+ throw e;
3192
+ }
3193
+ await db.updateTable("keel.flow_step").set({
3194
+ status: "FAILED" /* FAILED */,
3195
+ spanId,
3196
+ endTime: /* @__PURE__ */ new Date(),
3197
+ error: e instanceof Error ? e.message : "An error occurred"
3198
+ }).where("id", "=", step?.id).returningAll().executeTakeFirst();
3175
3199
  throw e;
3176
3200
  }
3177
3201
  await db.updateTable("keel.flow_step").set({
3178
- status: "FAILED" /* FAILED */,
3202
+ status: "COMPLETED" /* COMPLETED */,
3203
+ value: JSON.stringify(data),
3204
+ action,
3179
3205
  spanId,
3180
- endTime: /* @__PURE__ */ new Date(),
3181
- error: e instanceof Error ? e.message : "An error occurred"
3182
- }).where("id", "=", step?.id).returningAll().executeTakeFirst();
3183
- throw e;
3184
- }
3185
- await db.updateTable("keel.flow_step").set({
3186
- status: "COMPLETED" /* COMPLETED */,
3187
- value: JSON.stringify(data),
3188
- action,
3189
- spanId,
3190
- endTime: /* @__PURE__ */ new Date()
3191
- }).where("id", "=", step.id).returningAll().executeTakeFirst();
3192
- return { data, action };
3206
+ endTime: /* @__PURE__ */ new Date()
3207
+ }).where("id", "=", step.id).returningAll().executeTakeFirst();
3208
+ return { data, action };
3209
+ });
3193
3210
  }, "page"),
3194
3211
  inputs: {
3195
3212
  text: textInput,
@@ -3268,6 +3285,7 @@ async function handleFlow(request, config) {
3268
3285
  );
3269
3286
  return opentelemetry6.context.with(activeContext, () => {
3270
3287
  return withSpan(request.method, async (span) => {
3288
+ span.setAttribute(KEEL_INTERNAL_ATTR, true);
3271
3289
  let db = null;
3272
3290
  let flowConfig = null;
3273
3291
  const runId = request.meta?.runId;
@@ -3325,6 +3343,7 @@ async function handleFlow(request, config) {
3325
3343
  });
3326
3344
  } catch (e) {
3327
3345
  if (e instanceof StepCreatedDisrupt) {
3346
+ span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
3328
3347
  return createJSONRPCSuccessResponse5(request.id, {
3329
3348
  runId,
3330
3349
  runCompleted: false,
@@ -3346,11 +3365,13 @@ async function handleFlow(request, config) {
3346
3365
  ui: e.contents
3347
3366
  });
3348
3367
  }
3349
- span.recordException(e);
3350
- span.setStatus({
3351
- code: opentelemetry6.SpanStatusCode.ERROR,
3352
- message: e instanceof Error ? e.message : "unknown error"
3353
- });
3368
+ if (e instanceof Error) {
3369
+ span.recordException(e);
3370
+ span.setStatus({
3371
+ code: opentelemetry6.SpanStatusCode.ERROR,
3372
+ message: e instanceof Error ? e.message : "unknown error"
3373
+ });
3374
+ }
3354
3375
  if (e instanceof ExhuastedRetriesDisrupt) {
3355
3376
  return createJSONRPCSuccessResponse5(request.id, {
3356
3377
  runId,