@kortyx/otel 0.8.2 → 0.9.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 +29 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.1](https://github.com/kortyx-io/kortyx/compare/otel-v0.9.0...otel-v0.9.1) (2026-10-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **website:** reconcile credibility branch with current main ([60199f9](https://github.com/kortyx-io/kortyx/commit/60199f992242eb7c409a95bc7a6898d31bac601d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @kortyx/hooks bumped to 0.34.0
|
|
16
|
+
* @kortyx/core bumped to 0.13.1
|
|
17
|
+
|
|
18
|
+
## [0.9.0](https://github.com/kortyx-io/kortyx/compare/otel-v0.8.2...otel-v0.9.0) (2026-10-10)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* version, evaluate, serve and migrate Studio prompts ([#288](https://github.com/kortyx-io/kortyx/issues/288)) ([0802f8b](https://github.com/kortyx-io/kortyx/commit/0802f8b91c4a541d176dd8a75c659063e2c28c8c))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @kortyx/hooks bumped to 0.33.0
|
|
31
|
+
|
|
3
32
|
## [0.8.2](https://github.com/kortyx-io/kortyx/compare/otel-v0.8.1...otel-v0.8.2) (2026-10-09)
|
|
4
33
|
|
|
5
34
|
|
package/dist/index.js
CHANGED
|
@@ -166,6 +166,12 @@ var telemetryAttributes = (telemetry, options, side) => {
|
|
|
166
166
|
if (prompt.type) attributes["gen_ai.prompt.type"] = prompt.type;
|
|
167
167
|
if (prompt.type) attributes["kortyx.prompt.type"] = prompt.type;
|
|
168
168
|
if (prompt.source) attributes["kortyx.prompt.source"] = prompt.source;
|
|
169
|
+
if (prompt.metadata && typeof prompt.metadata === "object") {
|
|
170
|
+
const metadata = prompt.metadata;
|
|
171
|
+
for (const key of ["hash", "environment", "snapshotRevision"])
|
|
172
|
+
if (typeof metadata[key] === "string")
|
|
173
|
+
attributes[`kortyx.prompt.${key}`] = metadata[key];
|
|
174
|
+
}
|
|
169
175
|
try {
|
|
170
176
|
Object.assign(attributes, options.mapPromptMetadata?.(prompt) ?? {});
|
|
171
177
|
} catch {
|
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 { 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 summarizeDiagnostic,\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 captured = exceptionDiagnostics(error, options.error);\n const diagnostic = captured ? summarizeDiagnostic(captured) : null;\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 {\n exceptionDiagnostics,\n summarizeDiagnostic,\n} 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 captured = exceptionDiagnostics(error, options.error);\n const diagnostic = captured ? summarizeDiagnostic(captured) : null;\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 as\n | import(\"@kortyx/hooks\").KortyxErrorDetails\n | undefined,\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,mBAIO;AACP,IAAAC,cAAoD;;;ACNpD,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,E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"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 summarizeDiagnostic,\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 captured = exceptionDiagnostics(error, options.error);\n const diagnostic = captured ? summarizeDiagnostic(captured) : null;\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 if (prompt.metadata && typeof prompt.metadata === \"object\") {\n const metadata = prompt.metadata as Record<string, unknown>;\n for (const key of [\"hash\", \"environment\", \"snapshotRevision\"])\n if (typeof metadata[key] === \"string\")\n attributes[`kortyx.prompt.${key}`] = metadata[key];\n }\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 {\n exceptionDiagnostics,\n summarizeDiagnostic,\n} 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 captured = exceptionDiagnostics(error, options.error);\n const diagnostic = captured ? summarizeDiagnostic(captured) : null;\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 as\n | import(\"@kortyx/hooks\").KortyxErrorDetails\n | undefined,\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,mBAIO;AACP,IAAAC,cAAoD;;;ACNpD,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,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,QAAI,MAAM,MAAM,CAAC,SAAS,OAAO,SAAS,QAAQ,GAAG;AACnD,aAAO;AAAA,IACT;AACA,QAAI,MAAM,MAAM,CAAC,SAAS,OAAO,SAAS,QAAQ,GAAG;AACnD,aAAO;AAAA,IACT;AACA,QAAI,MAAM,MAAM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jB,aAAK,gBAAgB;AAAA,UACnB,MAAM,WAAW,QAAQ;AAAA,UACzB,SAAS,WAAW;AAAA,UACpB,GAAI,WAAW,QAAQ,EAAE,OAAO,WAAW,MAAM,IAAI,CAAC;AAAA,QACxD,CAAC;AACD,aAAK;AAAA,UACH;AAAA,UACA,aAAa;AAAA,YACX,kBAAkB,WAAW,QAAQ;AAAA,YACrC,qBAAqB,WAAW;AAAA,YAChC,GAAI,WAAW,QACX,EAAE,wBAAwB,WAAW,MAAM,IAC3C,CAAC;AAAA,YACL,GAAI,WAAW,QACX,EAAE,sBAAsB,WAAW,MAAM,IACzC,CAAC;AAAA,YACL,qBAAqB;AAAA,YACrB,wBAAwB;AAAA,YACxB,yBACE,cAAc,aAAa,YAAY,YAAY;AAAA,YACrD,GAAI,cAAc,MAAM,SACpB,EAAE,qBAAqB,cAAc,KAAK,IAC1C,CAAC;AAAA,YACL,GAAI,cAAc,WACd,OAAO;AAAA,cACL,OAAO;AAAA,oBACL,wCAAsB,cAAc,QAAQ;AAAA,cAC9C,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,gBACtB,yBAAyB,GAAG;AAAA,gBAC5B;AAAA,cACF,CAAC;AAAA,YACH,IACA,CAAC;AAAA,UACP,CAAC;AAAA,QACH;AAAA,MACF,QAAQ;AAAA,MAER;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_internal","import_api","import_internal"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kortyx/otel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.
|
|
36
|
-
"@kortyx/core": "0.13.
|
|
35
|
+
"@kortyx/hooks": "0.34.0",
|
|
36
|
+
"@kortyx/core": "0.13.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@opentelemetry/api": "^1.9.0"
|