@kortyx/otel 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.1](https://github.com/kortyx-io/kortyx/compare/otel-v0.7.0...otel-v0.7.1) (2026-09-21)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @kortyx/hooks bumped to 0.28.0
11
+ * @kortyx/core bumped to 0.10.0
12
+
13
+ ## [0.7.0](https://github.com/kortyx-io/kortyx/compare/otel-v0.6.0...otel-v0.7.0) (2026-09-21)
14
+
15
+
16
+ ### Features
17
+
18
+ * **observability:** report handled workflow errors ([#222](https://github.com/kortyx-io/kortyx/issues/222)) ([68a3b0e](https://github.com/kortyx-io/kortyx/commit/68a3b0eea5d93cb89bdcef63c4767f3b0d59e60d))
19
+
20
+
21
+ ### Dependencies
22
+
23
+ * The following workspace dependencies were updated
24
+ * dependencies
25
+ * @kortyx/hooks bumped to 0.27.0
26
+
3
27
  ## [0.6.0](https://github.com/kortyx-io/kortyx/compare/otel-v0.5.3...otel-v0.6.0) (2026-09-18)
4
28
 
5
29
 
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ interface OpenTelemetryTraceAdapterOptions {
27
27
  instrumentationName?: string | undefined;
28
28
  instrumentationVersion?: string | undefined;
29
29
  defaultAttributes?: ReasonTraceAttributes | undefined;
30
- /** Optional replacement/suppression of automatically captured model fault diagnostics. */
30
+ /** Optional replacement or suppression of captured error diagnostics. */
31
31
  error?: _kortyx_hooks.KortyxTraceErrorProjection;
32
32
  captureContent?: boolean | {
33
33
  input?: boolean | undefined;
package/dist/index.js CHANGED
@@ -24,6 +24,8 @@ __export(index_exports, {
24
24
  module.exports = __toCommonJS(index_exports);
25
25
 
26
26
  // src/adapter.ts
27
+ var import_node_async_hooks = require("async_hooks");
28
+ var import_internal3 = require("@kortyx/hooks/internal");
27
29
  var import_api2 = require("@opentelemetry/api");
28
30
 
29
31
  // src/attributes.ts
@@ -278,15 +280,20 @@ var createSpanWrapper = (span, name, options) => {
278
280
  return;
279
281
  }
280
282
  const failure = (0, import_errors.serializeFailure)(error);
281
- const diagnostic = (0, import_internal2.isModelTraceSpan)(name) ? (0, import_internal2.errorDiagnostics)(error, options.error) : { errorType: failure.code, errorMessage: failure.message };
282
- const message = diagnostic.errorMessage ?? "Model execution failed.";
283
+ const diagnostic = (0, import_internal2.exceptionDiagnostics)(error, options.error);
284
+ const message = diagnostic?.message ?? failure.message;
283
285
  span.recordException({
284
- name: diagnostic.errorType ?? failure.code,
285
- message
286
+ name: diagnostic?.type ?? failure.code,
287
+ message,
288
+ ...diagnostic?.stack ? { stack: diagnostic.stack } : {}
286
289
  });
287
290
  span.setStatus({ code: import_api.SpanStatusCode.ERROR, message });
288
291
  try {
289
- const attributes = spanErrorAttributes(error, args, diagnostic);
292
+ const attributes = spanErrorAttributes(error, args, {
293
+ type: diagnostic?.type,
294
+ message: diagnostic?.message,
295
+ cause: diagnostic?.cause
296
+ });
290
297
  span.setAttributes(
291
298
  toAttributes(
292
299
  applyAttributeMapping(name, attributes, options, {
@@ -311,12 +318,13 @@ var spanEndAttributes = (args, options) => ({
311
318
  });
312
319
  var spanErrorAttributes = (error, args, diagnostic) => {
313
320
  const failure = (0, import_errors.serializeFailure)(error);
314
- const message = diagnostic.errorMessage ?? "Model execution failed.";
321
+ const message = diagnostic.message ?? failure.message;
315
322
  return {
316
323
  ...args?.attributes ?? {},
317
- "error.type": diagnostic.errorType ?? failure.code,
324
+ "error.type": diagnostic.type ?? failure.code,
318
325
  "kortyx.error.category": failure.category,
319
326
  "error.message": message,
327
+ ...diagnostic.cause ? { "kortyx.error.cause": diagnostic.cause } : {},
320
328
  ...usageAttributes(args)
321
329
  };
322
330
  };
@@ -327,6 +335,7 @@ function createOpenTelemetryTraceAdapter(options = {}) {
327
335
  options.instrumentationName ?? "kortyx",
328
336
  options.instrumentationVersion
329
337
  );
338
+ const activeSpans = new import_node_async_hooks.AsyncLocalStorage();
330
339
  const start = (args) => {
331
340
  const attributes = startAttributes(args, options);
332
341
  const span = tracer.startSpan(
@@ -371,28 +380,65 @@ function createOpenTelemetryTraceAdapter(options = {}) {
371
380
  });
372
381
  } catch {
373
382
  }
374
- try {
375
- const result = await fn(wrapped);
376
- if (!wrapped.ended) wrapped.end?.();
377
- return result;
378
- } catch (error) {
383
+ return activeSpans.run(span, async () => {
379
384
  try {
380
- wrapped.fail?.(error);
381
- } catch {
385
+ const result = await fn(wrapped);
386
+ if (!wrapped.ended) wrapped.end?.();
387
+ return result;
388
+ } catch (error) {
389
+ try {
390
+ wrapped.fail?.(error);
391
+ } catch {
392
+ }
393
+ throw error;
382
394
  }
383
- throw error;
384
- }
395
+ });
385
396
  }
386
397
  );
387
398
  },
388
399
  getActiveContext: () => {
389
- const span = import_api2.trace.getActiveSpan();
400
+ const span = activeSpans.getStore() ?? import_api2.trace.getActiveSpan();
390
401
  if (!span) return void 0;
391
402
  const spanContext = span.spanContext();
392
403
  return {
393
404
  traceId: spanContext.traceId,
394
405
  spanId: spanContext.spanId
395
406
  };
407
+ },
408
+ reportError: (error, reportOptions = {}) => {
409
+ try {
410
+ const span = activeSpans.getStore() ?? import_api2.trace.getActiveSpan();
411
+ if (!span) return;
412
+ const diagnostic = (0, import_internal3.exceptionDiagnostics)(error, options.error);
413
+ if (!diagnostic) return;
414
+ span.recordException({
415
+ name: diagnostic.type ?? "Error",
416
+ message: diagnostic.message,
417
+ ...diagnostic.stack ? { stack: diagnostic.stack } : {}
418
+ });
419
+ span.addEvent(
420
+ "kortyx.error.reported",
421
+ toAttributes({
422
+ "exception.type": diagnostic.type ?? "Error",
423
+ "exception.message": diagnostic.message,
424
+ ...diagnostic.stack ? { "exception.stacktrace": diagnostic.stack } : {},
425
+ ...diagnostic.cause ? { "kortyx.error.cause": diagnostic.cause } : {},
426
+ "exception.escaped": false,
427
+ "kortyx.error.handled": true,
428
+ "kortyx.error.severity": reportOptions.severity === "warning" ? "warning" : "error",
429
+ ...reportOptions.tags?.length ? { "kortyx.trace.tags": reportOptions.tags } : {},
430
+ ...reportOptions.metadata ? Object.fromEntries(
431
+ Object.entries(
432
+ (0, import_internal3.safeTelemetryMetadata)(reportOptions.metadata)
433
+ ).map(([key, value]) => [
434
+ `kortyx.error.metadata.${key}`,
435
+ value
436
+ ])
437
+ ) : {}
438
+ })
439
+ );
440
+ } catch {
441
+ }
396
442
  }
397
443
  };
398
444
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/attributes.ts","../src/content.ts","../src/span-wrapper.ts"],"sourcesContent":["export { createOpenTelemetryTraceAdapter } from \"./adapter\";\nexport type {\n OpenTelemetryMapAttributesArgs,\n OpenTelemetrySpanEndInfo,\n OpenTelemetrySpanStartInfo,\n OpenTelemetryTraceAdapterOptions,\n OpenTelemetryTracePhase,\n} from \"./types\";\n","import type {\n ReasonTraceAdapter,\n ReasonTraceAttributes,\n ReasonTraceSpan,\n ReasonTraceSpanStartArgs,\n} from \"@kortyx/hooks\";\nimport { context, SpanKind, trace } from \"@opentelemetry/api\";\nimport {\n applyAttributeMapping,\n startAttributes,\n toAttributes,\n} from \"./attributes\";\nimport { createSpanWrapper } from \"./span-wrapper\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport function createOpenTelemetryTraceAdapter(\n options: OpenTelemetryTraceAdapterOptions = {},\n): ReasonTraceAdapter {\n const tracer =\n options.tracer ??\n trace.getTracer(\n options.instrumentationName ?? \"kortyx\",\n options.instrumentationVersion,\n );\n\n const start = (args: ReasonTraceSpanStartArgs): ReasonTraceSpan => {\n const attributes = startAttributes(args, options);\n const span = tracer.startSpan(\n args.name,\n {\n kind: SpanKind.INTERNAL,\n attributes: spanStartOtelAttributes(args, attributes, options),\n },\n context.active(),\n );\n const spanContext = span.spanContext();\n try {\n options.onSpanStart?.({\n name: args.name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n attributes,\n });\n } catch {}\n return createSpanWrapper(span, args.name, options);\n };\n\n return {\n startSpan: start,\n withSpan: async (args, fn) => {\n const attributes = startAttributes(args, options);\n return tracer.startActiveSpan(\n args.name,\n {\n kind: SpanKind.INTERNAL,\n attributes: spanStartOtelAttributes(args, attributes, options),\n },\n async (span) => {\n const wrapped = createSpanWrapper(span, args.name, options);\n const spanContext = span.spanContext();\n try {\n options.onSpanStart?.({\n name: args.name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n attributes,\n });\n } catch {}\n try {\n const result = await fn(wrapped);\n if (!wrapped.ended) wrapped.end?.();\n return result;\n } catch (error) {\n try {\n wrapped.fail?.(error);\n } catch {\n /* Preserve the callback failure. */\n }\n throw error;\n }\n },\n );\n },\n getActiveContext: () => {\n const span = trace.getActiveSpan();\n if (!span) return undefined;\n const spanContext = span.spanContext();\n return {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n };\n },\n };\n}\n\nconst spanStartOtelAttributes = (\n args: ReasonTraceSpanStartArgs,\n attributes: ReasonTraceAttributes,\n options: OpenTelemetryTraceAdapterOptions,\n) =>\n toAttributes(\n applyAttributeMapping(args.name, attributes, options, {\n phase: \"start\",\n telemetry: args.telemetry,\n }),\n );\n","import type {\n KortyxTraceMetadata,\n ReasonTraceAttributes,\n ReasonTraceSpanEndArgs,\n ReasonTraceSpanStartArgs,\n} from \"@kortyx/hooks\";\nimport { safeTelemetryMetadata } from \"@kortyx/hooks/internal\";\nimport type { Attributes } from \"@opentelemetry/api\";\nimport { type ContentCaptureSide, shouldCapture } from \"./content\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\ntype OpenTelemetryAttributeValue =\n | string\n | number\n | boolean\n | string[]\n | number[]\n | boolean[];\n\nexport const toAttributeValue = (\n value: unknown,\n): OpenTelemetryAttributeValue | undefined => {\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (Array.isArray(value)) {\n if (value.every((item) => typeof item === \"string\")) {\n return value as string[];\n }\n if (value.every((item) => typeof item === \"number\")) {\n return value as number[];\n }\n if (value.every((item) => typeof item === \"boolean\")) {\n return value as boolean[];\n }\n }\n if (value === null || value === undefined) return undefined;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\nexport const toAttributes = (attributes: ReasonTraceAttributes): Attributes => {\n const result: Attributes = {};\n for (const [key, value] of Object.entries(attributes)) {\n const attributeValue = toAttributeValue(value);\n if (attributeValue !== undefined) result[key] = attributeValue;\n }\n return result;\n};\n\nexport const normalizeKnownAttributes = (\n attributes: ReasonTraceAttributes,\n): ReasonTraceAttributes => {\n const normalized: ReasonTraceAttributes = { ...attributes };\n\n if (typeof attributes.providerId === \"string\") {\n normalized[\"gen_ai.provider.name\"] = attributes.providerId;\n normalized[\"kortyx.provider.id\"] = attributes.providerId;\n }\n if (typeof attributes.modelId === \"string\") {\n normalized[\"gen_ai.request.model\"] = attributes.modelId;\n normalized[\"kortyx.model.id\"] = attributes.modelId;\n }\n if (typeof attributes.stream === \"boolean\") {\n normalized[\"gen_ai.request.stream\"] = attributes.stream;\n }\n if (typeof attributes.operation === \"string\") {\n normalized[\"gen_ai.operation.name\"] = attributes.operation;\n normalized[\"kortyx.operation.name\"] = attributes.operation;\n }\n if (typeof attributes.nodeId === \"string\") {\n normalized[\"kortyx.node.id\"] = attributes.nodeId;\n }\n if (typeof attributes.workflowId === \"string\") {\n normalized[\"kortyx.workflow.id\"] = attributes.workflowId;\n }\n if (typeof attributes.runId === \"string\") {\n normalized[\"kortyx.run.id\"] = attributes.runId;\n }\n if (typeof attributes.sessionId === \"string\") {\n normalized[\"session.id\"] = attributes.sessionId;\n normalized[\"gen_ai.conversation.id\"] = attributes.sessionId;\n normalized[\"kortyx.session.id\"] = attributes.sessionId;\n }\n if (typeof attributes.userId === \"string\") {\n normalized[\"user.id\"] = attributes.userId;\n }\n if (typeof attributes.tenantId === \"string\") {\n normalized[\"kortyx.tenant.id\"] = attributes.tenantId;\n }\n if (typeof attributes.promptName === \"string\") {\n normalized[\"gen_ai.prompt.name\"] = attributes.promptName;\n normalized[\"kortyx.prompt.name\"] = attributes.promptName;\n }\n if (attributes.promptVersion !== undefined) {\n normalized[\"gen_ai.prompt.version\"] = attributes.promptVersion;\n normalized[\"kortyx.prompt.version\"] = attributes.promptVersion;\n }\n if (typeof attributes.promptType === \"string\") {\n normalized[\"gen_ai.prompt.type\"] = attributes.promptType;\n normalized[\"kortyx.prompt.type\"] = attributes.promptType;\n }\n if (typeof attributes.toolCallCount === \"number\") {\n normalized[\"kortyx.tool.call.count\"] = attributes.toolCallCount;\n }\n if (typeof attributes.toolResultCount === \"number\") {\n normalized[\"kortyx.tool.result.count\"] = attributes.toolResultCount;\n }\n if (typeof attributes.toolStepCount === \"number\") {\n normalized[\"kortyx.tool.step.count\"] = attributes.toolStepCount;\n }\n if (typeof attributes.tool === \"string\") {\n normalized[\"gen_ai.tool.name\"] = attributes.tool;\n normalized[\"kortyx.tool.name\"] = attributes.tool;\n }\n if (typeof attributes.toolCallId === \"string\") {\n normalized[\"kortyx.tool.call.id\"] = attributes.toolCallId;\n }\n\n if (attributes.version === 1 && typeof attributes.attemptId === \"string\") {\n normalized[\"gen_ai.operation.name\"] = \"execute_tool\";\n normalized[\"gen_ai.tool.name\"] = attributes.name;\n normalized[\"gen_ai.tool.call.id\"] = attributes.toolCallId;\n normalized[\"kortyx.tool.attempt.id\"] = attributes.attemptId;\n normalized[\"kortyx.tool.outcome\"] = attributes.outcome;\n normalized[\"kortyx.tool.executed\"] = attributes.executed;\n normalized[\"kortyx.tool.denial.code\"] = attributes.denialCode;\n normalized[\"error.type\"] = attributes.errorType;\n normalized[\"error.message\"] = attributes.errorMessage;\n }\n return normalized;\n};\n\nexport const telemetryAttributes = (\n telemetry: KortyxTraceMetadata | undefined,\n options: OpenTelemetryTraceAdapterOptions,\n side?: ContentCaptureSide,\n): ReasonTraceAttributes => {\n const attributes: ReasonTraceAttributes = {};\n if (!telemetry) return attributes;\n\n if (telemetry.operation) {\n attributes.operation = telemetry.operation;\n attributes[\"gen_ai.operation.name\"] = telemetry.operation;\n }\n\n if (telemetry.prompt) {\n const prompt = telemetry.prompt;\n if (prompt.name) attributes[\"gen_ai.prompt.name\"] = prompt.name;\n if (prompt.name) attributes[\"kortyx.prompt.name\"] = prompt.name;\n if (prompt.version !== undefined) {\n attributes[\"gen_ai.prompt.version\"] = prompt.version;\n attributes[\"kortyx.prompt.version\"] = prompt.version;\n }\n if (prompt.type) attributes[\"gen_ai.prompt.type\"] = prompt.type;\n if (prompt.type) attributes[\"kortyx.prompt.type\"] = prompt.type;\n if (prompt.source) attributes[\"kortyx.prompt.source\"] = prompt.source;\n try {\n Object.assign(attributes, options.mapPromptMetadata?.(prompt) ?? {});\n } catch {}\n }\n\n if (telemetry.tags?.length) {\n attributes[\"kortyx.trace.tags\"] = telemetry.tags;\n }\n\n if (telemetry.metadata) {\n for (const [key, value] of Object.entries(\n safeTelemetryMetadata(telemetry.metadata),\n )) {\n attributes[`kortyx.trace.metadata.${key}`] = value;\n }\n }\n\n if (\n side === \"input\" &&\n shouldCapture(telemetry.captureContent ?? options.captureContent, \"input\")\n ) {\n attributes[\"gen_ai.prompt\"] = telemetry.input;\n attributes[\"kortyx.trace.input\"] = telemetry.input;\n }\n if (\n side === \"output\" &&\n shouldCapture(telemetry.captureContent ?? options.captureContent, \"output\")\n ) {\n attributes[\"gen_ai.completion\"] = telemetry.output;\n attributes[\"kortyx.trace.output\"] = telemetry.output;\n }\n\n return attributes;\n};\n\nexport const usageAttributes = (\n args: ReasonTraceSpanEndArgs | undefined,\n): ReasonTraceAttributes => {\n const usage = args?.usage;\n if (!usage) return {};\n return {\n ...(usage.input !== undefined\n ? { \"gen_ai.usage.input_tokens\": usage.input }\n : {}),\n ...(usage.output !== undefined\n ? { \"gen_ai.usage.output_tokens\": usage.output }\n : {}),\n ...(usage.total !== undefined\n ? { \"gen_ai.usage.total_tokens\": usage.total }\n : {}),\n ...(usage.reasoning !== undefined\n ? { \"gen_ai.usage.reasoning.output_tokens\": usage.reasoning }\n : {}),\n ...(usage.cacheRead !== undefined\n ? { \"gen_ai.usage.cache_read.input_tokens\": usage.cacheRead }\n : {}),\n ...(usage.cacheWrite !== undefined\n ? { \"gen_ai.usage.cache_creation.input_tokens\": usage.cacheWrite }\n : {}),\n ...(args.finishReason?.unified\n ? { \"gen_ai.response.finish_reasons\": [args.finishReason.unified] }\n : {}),\n ...(args.finishReason?.raw\n ? { \"kortyx.finish_reason.raw\": args.finishReason.raw }\n : {}),\n ...(args.warnings?.length\n ? { \"kortyx.warning.count\": args.warnings.length }\n : {}),\n };\n};\n\nexport const startAttributes = (\n args: ReasonTraceSpanStartArgs,\n options: OpenTelemetryTraceAdapterOptions,\n): ReasonTraceAttributes => ({\n ...(options.defaultAttributes ?? {}),\n ...(args.attributes ?? {}),\n ...telemetryAttributes(args.telemetry, options, \"input\"),\n});\n\nexport const applyAttributeMapping = (\n name: string,\n attributes: ReasonTraceAttributes,\n options: OpenTelemetryTraceAdapterOptions,\n args: Omit<\n Parameters<\n NonNullable<OpenTelemetryTraceAdapterOptions[\"mapAttributes\"]>\n >[0],\n \"name\" | \"attributes\"\n >,\n): ReasonTraceAttributes => {\n let mapped: ReasonTraceAttributes = {};\n try {\n mapped = options.mapAttributes?.({ ...args, name, attributes }) ?? {};\n } catch {}\n return normalizeKnownAttributes({ ...attributes, ...mapped });\n};\n","import type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport type ContentCaptureSide = \"input\" | \"output\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n\nexport const shouldCapture = (\n value: OpenTelemetryTraceAdapterOptions[\"captureContent\"],\n side: ContentCaptureSide,\n): boolean => {\n if (value === true) return true;\n if (!isRecord(value)) return false;\n return Boolean(value[side]);\n};\n","import { isControlFlowError, serializeFailure } from \"@kortyx/core/errors\";\nimport type { ReasonTraceSpan, ReasonTraceSpanEndArgs } from \"@kortyx/hooks\";\nimport { errorDiagnostics, isModelTraceSpan } from \"@kortyx/hooks/internal\";\nimport { type Span, SpanStatusCode } from \"@opentelemetry/api\";\nimport {\n applyAttributeMapping,\n normalizeKnownAttributes,\n telemetryAttributes,\n toAttributes,\n usageAttributes,\n} from \"./attributes\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport type OpenTelemetryReasonSpan = ReasonTraceSpan & { ended: boolean };\n\nexport const createSpanWrapper = (\n span: Span,\n name: string,\n options: OpenTelemetryTraceAdapterOptions,\n): OpenTelemetryReasonSpan => {\n const wrapper: OpenTelemetryReasonSpan = {\n ended: false,\n setAttributes: (attributes) => {\n span.setAttributes(toAttributes(normalizeKnownAttributes(attributes)));\n },\n addEvent: (eventName, attributes) => {\n span.addEvent(\n eventName,\n toAttributes(\n applyAttributeMapping(name, attributes ?? {}, options, {\n phase: \"event\",\n }),\n ),\n );\n },\n end: (args) => {\n if (wrapper.ended) return;\n try {\n const attributes = spanEndAttributes(args, options);\n if (name === \"kortyx.tool\" && args?.attributes?.outcome === \"fault\")\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"Tool execution failed.\",\n });\n span.setAttributes(\n toAttributes(\n applyAttributeMapping(name, attributes, options, {\n phase: \"end\",\n telemetry: args?.telemetry,\n end: args,\n }),\n ),\n );\n } catch {\n /* Attribute callbacks are observers. */\n }\n wrapper.ended = true;\n span.end();\n const spanContext = span.spanContext();\n try {\n options.onSpanEnd?.({\n name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n });\n } catch {}\n },\n fail: (error, args) => {\n if (wrapper.ended) return;\n if (isControlFlowError(error)) {\n span.setAttribute(\"kortyx.control_flow\", true);\n wrapper.end?.(args);\n return;\n }\n const failure = serializeFailure(error);\n const diagnostic = isModelTraceSpan(name)\n ? errorDiagnostics(error, options.error)\n : { errorType: failure.code, errorMessage: failure.message };\n const message = diagnostic.errorMessage ?? \"Model execution failed.\";\n span.recordException({\n name: diagnostic.errorType ?? failure.code,\n message,\n });\n span.setStatus({ code: SpanStatusCode.ERROR, message });\n try {\n const attributes = spanErrorAttributes(error, args, diagnostic);\n span.setAttributes(\n toAttributes(\n applyAttributeMapping(name, attributes, options, {\n phase: \"error\",\n telemetry: args?.telemetry,\n end: args,\n error,\n }),\n ),\n );\n } catch {\n /* Preserve execution failure and finish the physical span. */\n }\n wrapper.end?.(args);\n },\n };\n return wrapper;\n};\n\nconst spanEndAttributes = (\n args: ReasonTraceSpanEndArgs | undefined,\n options: OpenTelemetryTraceAdapterOptions,\n) => ({\n ...(args?.attributes ?? {}),\n ...usageAttributes(args),\n ...telemetryAttributes(args?.telemetry, options, \"output\"),\n});\n\nconst spanErrorAttributes = (\n error: unknown,\n args: ReasonTraceSpanEndArgs | undefined,\n diagnostic: { errorType?: string; errorMessage?: string },\n) => {\n const failure = serializeFailure(error);\n const message = diagnostic.errorMessage ?? \"Model execution failed.\";\n return {\n ...(args?.attributes ?? {}),\n \"error.type\": diagnostic.errorType ?? failure.code,\n \"kortyx.error.category\": failure.category,\n \"error.message\": message,\n ...usageAttributes(args),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAAA,cAAyC;;;ACAzC,sBAAsC;;;ACFtC,IAAM,WAAW,CAAC,UAChB,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAE9D,IAAM,gBAAgB,CAC3B,OACA,SACY;AACZ,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,SAAO,QAAQ,MAAM,IAAI,CAAC;AAC5B;;;ADKO,IAAM,mBAAmB,CAC9B,UAC4C;AAC5C,MACE,OAAO,UAAU,YACjB,OAAO,UAAU,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,QACA,OAAO,SAAS;AACd,gBAAM,UAAU,kBAAkB,MAAM,KAAK,MAAM,OAAO;AAC1D,gBAAM,cAAc,KAAK,YAAY;AACrC,cAAI;AACF,oBAAQ,cAAc;AAAA,cACpB,MAAM,KAAK;AAAA,cACX,SAAS,YAAY;AAAA,cACrB,QAAQ,YAAY;AAAA,cACpB;AAAA,YACF,CAAC;AAAA,UACH,QAAQ;AAAA,UAAC;AACT,cAAI;AACF,kBAAM,SAAS,MAAM,GAAG,OAAO;AAC/B,gBAAI,CAAC,QAAQ,MAAO,SAAQ,MAAM;AAClC,mBAAO;AAAA,UACT,SAAS,OAAO;AACd,gBAAI;AACF,sBAAQ,OAAO,KAAK;AAAA,YACtB,QAAQ;AAAA,YAER;AACA,kBAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,kBAAkB,MAAM;AACtB,YAAM,OAAO,kBAAM,cAAc;AACjC,UAAI,CAAC,KAAM,QAAO;AAClB,YAAM,cAAc,KAAK,YAAY;AACrC,aAAO;AAAA,QACL,SAAS,YAAY;AAAA,QACrB,QAAQ,YAAY;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,0BAA0B,CAC9B,MACA,YACA,YAEA;AAAA,EACE,sBAAsB,KAAK,MAAM,YAAY,SAAS;AAAA,IACpD,OAAO;AAAA,IACP,WAAW,KAAK;AAAA,EAClB,CAAC;AACH;","names":["import_api","import_internal"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/attributes.ts","../src/content.ts","../src/span-wrapper.ts"],"sourcesContent":["export { createOpenTelemetryTraceAdapter } from \"./adapter\";\nexport type {\n OpenTelemetryMapAttributesArgs,\n OpenTelemetrySpanEndInfo,\n OpenTelemetrySpanStartInfo,\n OpenTelemetryTraceAdapterOptions,\n OpenTelemetryTracePhase,\n} from \"./types\";\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type {\n ReasonTraceAdapter,\n ReasonTraceAttributes,\n ReasonTraceSpan,\n ReasonTraceSpanStartArgs,\n} from \"@kortyx/hooks\";\nimport {\n exceptionDiagnostics,\n safeTelemetryMetadata,\n} from \"@kortyx/hooks/internal\";\nimport { context, type Span, SpanKind, trace } from \"@opentelemetry/api\";\nimport {\n applyAttributeMapping,\n startAttributes,\n toAttributes,\n} from \"./attributes\";\nimport { createSpanWrapper } from \"./span-wrapper\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport function createOpenTelemetryTraceAdapter(\n options: OpenTelemetryTraceAdapterOptions = {},\n): ReasonTraceAdapter {\n const tracer =\n options.tracer ??\n trace.getTracer(\n options.instrumentationName ?? \"kortyx\",\n options.instrumentationVersion,\n );\n const activeSpans = new AsyncLocalStorage<Span>();\n\n const start = (args: ReasonTraceSpanStartArgs): ReasonTraceSpan => {\n const attributes = startAttributes(args, options);\n const span = tracer.startSpan(\n args.name,\n {\n kind: SpanKind.INTERNAL,\n attributes: spanStartOtelAttributes(args, attributes, options),\n },\n context.active(),\n );\n const spanContext = span.spanContext();\n try {\n options.onSpanStart?.({\n name: args.name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n attributes,\n });\n } catch {}\n return createSpanWrapper(span, args.name, options);\n };\n\n return {\n startSpan: start,\n withSpan: async (args, fn) => {\n const attributes = startAttributes(args, options);\n return tracer.startActiveSpan(\n args.name,\n {\n kind: SpanKind.INTERNAL,\n attributes: spanStartOtelAttributes(args, attributes, options),\n },\n async (span) => {\n const wrapped = createSpanWrapper(span, args.name, options);\n const spanContext = span.spanContext();\n try {\n options.onSpanStart?.({\n name: args.name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n attributes,\n });\n } catch {}\n return activeSpans.run(span, async () => {\n try {\n const result = await fn(wrapped);\n if (!wrapped.ended) wrapped.end?.();\n return result;\n } catch (error) {\n try {\n wrapped.fail?.(error);\n } catch {\n /* Preserve the callback failure. */\n }\n throw error;\n }\n });\n },\n );\n },\n getActiveContext: () => {\n const span = activeSpans.getStore() ?? trace.getActiveSpan();\n if (!span) return undefined;\n const spanContext = span.spanContext();\n return {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n };\n },\n reportError: (error, reportOptions = {}) => {\n try {\n const span = activeSpans.getStore() ?? trace.getActiveSpan();\n if (!span) return;\n const diagnostic = exceptionDiagnostics(error, options.error);\n if (!diagnostic) return;\n span.recordException({\n name: diagnostic.type ?? \"Error\",\n message: diagnostic.message,\n ...(diagnostic.stack ? { stack: diagnostic.stack } : {}),\n });\n span.addEvent(\n \"kortyx.error.reported\",\n toAttributes({\n \"exception.type\": diagnostic.type ?? \"Error\",\n \"exception.message\": diagnostic.message,\n ...(diagnostic.stack\n ? { \"exception.stacktrace\": diagnostic.stack }\n : {}),\n ...(diagnostic.cause\n ? { \"kortyx.error.cause\": diagnostic.cause }\n : {}),\n \"exception.escaped\": false,\n \"kortyx.error.handled\": true,\n \"kortyx.error.severity\":\n reportOptions.severity === \"warning\" ? \"warning\" : \"error\",\n ...(reportOptions.tags?.length\n ? { \"kortyx.trace.tags\": reportOptions.tags }\n : {}),\n ...(reportOptions.metadata\n ? Object.fromEntries(\n Object.entries(\n safeTelemetryMetadata(reportOptions.metadata),\n ).map(([key, value]) => [\n `kortyx.error.metadata.${key}`,\n value,\n ]),\n )\n : {}),\n }),\n );\n } catch {\n // Error reporting is an observer and cannot change execution.\n }\n },\n };\n}\n\nconst spanStartOtelAttributes = (\n args: ReasonTraceSpanStartArgs,\n attributes: ReasonTraceAttributes,\n options: OpenTelemetryTraceAdapterOptions,\n) =>\n toAttributes(\n applyAttributeMapping(args.name, attributes, options, {\n phase: \"start\",\n telemetry: args.telemetry,\n }),\n );\n","import type {\n KortyxTraceMetadata,\n ReasonTraceAttributes,\n ReasonTraceSpanEndArgs,\n ReasonTraceSpanStartArgs,\n} from \"@kortyx/hooks\";\nimport { safeTelemetryMetadata } from \"@kortyx/hooks/internal\";\nimport type { Attributes } from \"@opentelemetry/api\";\nimport { type ContentCaptureSide, shouldCapture } from \"./content\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\ntype OpenTelemetryAttributeValue =\n | string\n | number\n | boolean\n | string[]\n | number[]\n | boolean[];\n\nexport const toAttributeValue = (\n value: unknown,\n): OpenTelemetryAttributeValue | undefined => {\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (Array.isArray(value)) {\n if (value.every((item) => typeof item === \"string\")) {\n return value as string[];\n }\n if (value.every((item) => typeof item === \"number\")) {\n return value as number[];\n }\n if (value.every((item) => typeof item === \"boolean\")) {\n return value as boolean[];\n }\n }\n if (value === null || value === undefined) return undefined;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\nexport const toAttributes = (attributes: ReasonTraceAttributes): Attributes => {\n const result: Attributes = {};\n for (const [key, value] of Object.entries(attributes)) {\n const attributeValue = toAttributeValue(value);\n if (attributeValue !== undefined) result[key] = attributeValue;\n }\n return result;\n};\n\nexport const normalizeKnownAttributes = (\n attributes: ReasonTraceAttributes,\n): ReasonTraceAttributes => {\n const normalized: ReasonTraceAttributes = { ...attributes };\n\n if (typeof attributes.providerId === \"string\") {\n normalized[\"gen_ai.provider.name\"] = attributes.providerId;\n normalized[\"kortyx.provider.id\"] = attributes.providerId;\n }\n if (typeof attributes.modelId === \"string\") {\n normalized[\"gen_ai.request.model\"] = attributes.modelId;\n normalized[\"kortyx.model.id\"] = attributes.modelId;\n }\n if (typeof attributes.stream === \"boolean\") {\n normalized[\"gen_ai.request.stream\"] = attributes.stream;\n }\n if (typeof attributes.operation === \"string\") {\n normalized[\"gen_ai.operation.name\"] = attributes.operation;\n normalized[\"kortyx.operation.name\"] = attributes.operation;\n }\n if (typeof attributes.nodeId === \"string\") {\n normalized[\"kortyx.node.id\"] = attributes.nodeId;\n }\n if (typeof attributes.workflowId === \"string\") {\n normalized[\"kortyx.workflow.id\"] = attributes.workflowId;\n }\n if (typeof attributes.runId === \"string\") {\n normalized[\"kortyx.run.id\"] = attributes.runId;\n }\n if (typeof attributes.sessionId === \"string\") {\n normalized[\"session.id\"] = attributes.sessionId;\n normalized[\"gen_ai.conversation.id\"] = attributes.sessionId;\n normalized[\"kortyx.session.id\"] = attributes.sessionId;\n }\n if (typeof attributes.userId === \"string\") {\n normalized[\"user.id\"] = attributes.userId;\n }\n if (typeof attributes.tenantId === \"string\") {\n normalized[\"kortyx.tenant.id\"] = attributes.tenantId;\n }\n if (typeof attributes.promptName === \"string\") {\n normalized[\"gen_ai.prompt.name\"] = attributes.promptName;\n normalized[\"kortyx.prompt.name\"] = attributes.promptName;\n }\n if (attributes.promptVersion !== undefined) {\n normalized[\"gen_ai.prompt.version\"] = attributes.promptVersion;\n normalized[\"kortyx.prompt.version\"] = attributes.promptVersion;\n }\n if (typeof attributes.promptType === \"string\") {\n normalized[\"gen_ai.prompt.type\"] = attributes.promptType;\n normalized[\"kortyx.prompt.type\"] = attributes.promptType;\n }\n if (typeof attributes.toolCallCount === \"number\") {\n normalized[\"kortyx.tool.call.count\"] = attributes.toolCallCount;\n }\n if (typeof attributes.toolResultCount === \"number\") {\n normalized[\"kortyx.tool.result.count\"] = attributes.toolResultCount;\n }\n if (typeof attributes.toolStepCount === \"number\") {\n normalized[\"kortyx.tool.step.count\"] = attributes.toolStepCount;\n }\n if (typeof attributes.tool === \"string\") {\n normalized[\"gen_ai.tool.name\"] = attributes.tool;\n normalized[\"kortyx.tool.name\"] = attributes.tool;\n }\n if (typeof attributes.toolCallId === \"string\") {\n normalized[\"kortyx.tool.call.id\"] = attributes.toolCallId;\n }\n\n if (attributes.version === 1 && typeof attributes.attemptId === \"string\") {\n normalized[\"gen_ai.operation.name\"] = \"execute_tool\";\n normalized[\"gen_ai.tool.name\"] = attributes.name;\n normalized[\"gen_ai.tool.call.id\"] = attributes.toolCallId;\n normalized[\"kortyx.tool.attempt.id\"] = attributes.attemptId;\n normalized[\"kortyx.tool.outcome\"] = attributes.outcome;\n normalized[\"kortyx.tool.executed\"] = attributes.executed;\n normalized[\"kortyx.tool.denial.code\"] = attributes.denialCode;\n normalized[\"error.type\"] = attributes.errorType;\n normalized[\"error.message\"] = attributes.errorMessage;\n }\n return normalized;\n};\n\nexport const telemetryAttributes = (\n telemetry: KortyxTraceMetadata | undefined,\n options: OpenTelemetryTraceAdapterOptions,\n side?: ContentCaptureSide,\n): ReasonTraceAttributes => {\n const attributes: ReasonTraceAttributes = {};\n if (!telemetry) return attributes;\n\n if (telemetry.operation) {\n attributes.operation = telemetry.operation;\n attributes[\"gen_ai.operation.name\"] = telemetry.operation;\n }\n\n if (telemetry.prompt) {\n const prompt = telemetry.prompt;\n if (prompt.name) attributes[\"gen_ai.prompt.name\"] = prompt.name;\n if (prompt.name) attributes[\"kortyx.prompt.name\"] = prompt.name;\n if (prompt.version !== undefined) {\n attributes[\"gen_ai.prompt.version\"] = prompt.version;\n attributes[\"kortyx.prompt.version\"] = prompt.version;\n }\n if (prompt.type) attributes[\"gen_ai.prompt.type\"] = prompt.type;\n if (prompt.type) attributes[\"kortyx.prompt.type\"] = prompt.type;\n if (prompt.source) attributes[\"kortyx.prompt.source\"] = prompt.source;\n try {\n Object.assign(attributes, options.mapPromptMetadata?.(prompt) ?? {});\n } catch {}\n }\n\n if (telemetry.tags?.length) {\n attributes[\"kortyx.trace.tags\"] = telemetry.tags;\n }\n\n if (telemetry.metadata) {\n for (const [key, value] of Object.entries(\n safeTelemetryMetadata(telemetry.metadata),\n )) {\n attributes[`kortyx.trace.metadata.${key}`] = value;\n }\n }\n\n if (\n side === \"input\" &&\n shouldCapture(telemetry.captureContent ?? options.captureContent, \"input\")\n ) {\n attributes[\"gen_ai.prompt\"] = telemetry.input;\n attributes[\"kortyx.trace.input\"] = telemetry.input;\n }\n if (\n side === \"output\" &&\n shouldCapture(telemetry.captureContent ?? options.captureContent, \"output\")\n ) {\n attributes[\"gen_ai.completion\"] = telemetry.output;\n attributes[\"kortyx.trace.output\"] = telemetry.output;\n }\n\n return attributes;\n};\n\nexport const usageAttributes = (\n args: ReasonTraceSpanEndArgs | undefined,\n): ReasonTraceAttributes => {\n const usage = args?.usage;\n if (!usage) return {};\n return {\n ...(usage.input !== undefined\n ? { \"gen_ai.usage.input_tokens\": usage.input }\n : {}),\n ...(usage.output !== undefined\n ? { \"gen_ai.usage.output_tokens\": usage.output }\n : {}),\n ...(usage.total !== undefined\n ? { \"gen_ai.usage.total_tokens\": usage.total }\n : {}),\n ...(usage.reasoning !== undefined\n ? { \"gen_ai.usage.reasoning.output_tokens\": usage.reasoning }\n : {}),\n ...(usage.cacheRead !== undefined\n ? { \"gen_ai.usage.cache_read.input_tokens\": usage.cacheRead }\n : {}),\n ...(usage.cacheWrite !== undefined\n ? { \"gen_ai.usage.cache_creation.input_tokens\": usage.cacheWrite }\n : {}),\n ...(args.finishReason?.unified\n ? { \"gen_ai.response.finish_reasons\": [args.finishReason.unified] }\n : {}),\n ...(args.finishReason?.raw\n ? { \"kortyx.finish_reason.raw\": args.finishReason.raw }\n : {}),\n ...(args.warnings?.length\n ? { \"kortyx.warning.count\": args.warnings.length }\n : {}),\n };\n};\n\nexport const startAttributes = (\n args: ReasonTraceSpanStartArgs,\n options: OpenTelemetryTraceAdapterOptions,\n): ReasonTraceAttributes => ({\n ...(options.defaultAttributes ?? {}),\n ...(args.attributes ?? {}),\n ...telemetryAttributes(args.telemetry, options, \"input\"),\n});\n\nexport const applyAttributeMapping = (\n name: string,\n attributes: ReasonTraceAttributes,\n options: OpenTelemetryTraceAdapterOptions,\n args: Omit<\n Parameters<\n NonNullable<OpenTelemetryTraceAdapterOptions[\"mapAttributes\"]>\n >[0],\n \"name\" | \"attributes\"\n >,\n): ReasonTraceAttributes => {\n let mapped: ReasonTraceAttributes = {};\n try {\n mapped = options.mapAttributes?.({ ...args, name, attributes }) ?? {};\n } catch {}\n return normalizeKnownAttributes({ ...attributes, ...mapped });\n};\n","import type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport type ContentCaptureSide = \"input\" | \"output\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n\nexport const shouldCapture = (\n value: OpenTelemetryTraceAdapterOptions[\"captureContent\"],\n side: ContentCaptureSide,\n): boolean => {\n if (value === true) return true;\n if (!isRecord(value)) return false;\n return Boolean(value[side]);\n};\n","import { isControlFlowError, serializeFailure } from \"@kortyx/core/errors\";\nimport type { ReasonTraceSpan, ReasonTraceSpanEndArgs } from \"@kortyx/hooks\";\nimport { exceptionDiagnostics } from \"@kortyx/hooks/internal\";\nimport { type Span, SpanStatusCode } from \"@opentelemetry/api\";\nimport {\n applyAttributeMapping,\n normalizeKnownAttributes,\n telemetryAttributes,\n toAttributes,\n usageAttributes,\n} from \"./attributes\";\nimport type { OpenTelemetryTraceAdapterOptions } from \"./types\";\n\nexport type OpenTelemetryReasonSpan = ReasonTraceSpan & { ended: boolean };\n\nexport const createSpanWrapper = (\n span: Span,\n name: string,\n options: OpenTelemetryTraceAdapterOptions,\n): OpenTelemetryReasonSpan => {\n const wrapper: OpenTelemetryReasonSpan = {\n ended: false,\n setAttributes: (attributes) => {\n span.setAttributes(toAttributes(normalizeKnownAttributes(attributes)));\n },\n addEvent: (eventName, attributes) => {\n span.addEvent(\n eventName,\n toAttributes(\n applyAttributeMapping(name, attributes ?? {}, options, {\n phase: \"event\",\n }),\n ),\n );\n },\n end: (args) => {\n if (wrapper.ended) return;\n try {\n const attributes = spanEndAttributes(args, options);\n if (name === \"kortyx.tool\" && args?.attributes?.outcome === \"fault\")\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"Tool execution failed.\",\n });\n span.setAttributes(\n toAttributes(\n applyAttributeMapping(name, attributes, options, {\n phase: \"end\",\n telemetry: args?.telemetry,\n end: args,\n }),\n ),\n );\n } catch {\n /* Attribute callbacks are observers. */\n }\n wrapper.ended = true;\n span.end();\n const spanContext = span.spanContext();\n try {\n options.onSpanEnd?.({\n name,\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n });\n } catch {}\n },\n fail: (error, args) => {\n if (wrapper.ended) return;\n if (isControlFlowError(error)) {\n span.setAttribute(\"kortyx.control_flow\", true);\n wrapper.end?.(args);\n return;\n }\n const failure = serializeFailure(error);\n const diagnostic = exceptionDiagnostics(error, options.error);\n const message = diagnostic?.message ?? failure.message;\n span.recordException({\n name: diagnostic?.type ?? failure.code,\n message,\n ...(diagnostic?.stack ? { stack: diagnostic.stack } : {}),\n });\n span.setStatus({ code: SpanStatusCode.ERROR, message });\n try {\n const attributes = spanErrorAttributes(error, args, {\n type: diagnostic?.type,\n message: diagnostic?.message,\n cause: diagnostic?.cause,\n });\n span.setAttributes(\n toAttributes(\n applyAttributeMapping(name, attributes, options, {\n phase: \"error\",\n telemetry: args?.telemetry,\n end: args,\n error,\n }),\n ),\n );\n } catch {\n /* Preserve execution failure and finish the physical span. */\n }\n wrapper.end?.(args);\n },\n };\n return wrapper;\n};\n\nconst spanEndAttributes = (\n args: ReasonTraceSpanEndArgs | undefined,\n options: OpenTelemetryTraceAdapterOptions,\n) => ({\n ...(args?.attributes ?? {}),\n ...usageAttributes(args),\n ...telemetryAttributes(args?.telemetry, options, \"output\"),\n});\n\nconst spanErrorAttributes = (\n error: unknown,\n args: ReasonTraceSpanEndArgs | undefined,\n diagnostic: {\n type: string | undefined;\n message: string | undefined;\n cause: import(\"@kortyx/hooks\").KortyxErrorDetails | undefined;\n },\n) => {\n const failure = serializeFailure(error);\n const message = diagnostic.message ?? failure.message;\n return {\n ...(args?.attributes ?? {}),\n \"error.type\": diagnostic.type ?? failure.code,\n \"kortyx.error.category\": failure.category,\n \"error.message\": message,\n ...(diagnostic.cause ? { \"kortyx.error.cause\": diagnostic.cause } : {}),\n ...usageAttributes(args),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAkC;AAOlC,IAAAA,mBAGO;AACP,IAAAC,cAAoD;;;ACLpD,sBAAsC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AAAA,IACpD,OAAO;AAAA,IACP,WAAW,KAAK;AAAA,EAClB,CAAC;AACH;","names":["import_internal","import_api","import_internal"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kortyx/otel",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "private": false,
5
5
  "description": "OpenTelemetry adapter for Kortyx tracing.",
6
6
  "keywords": [
@@ -32,8 +32,8 @@
32
32
  "CHANGELOG.md"
33
33
  ],
34
34
  "dependencies": {
35
- "@kortyx/hooks": "0.26.0",
36
- "@kortyx/core": "0.9.0"
35
+ "@kortyx/hooks": "0.28.0",
36
+ "@kortyx/core": "0.10.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@opentelemetry/api": "^1.9.0"