@dexto/core 1.8.4 → 1.8.5
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/llm/executor/turn-executor.cjs +137 -30
- package/dist/llm/executor/turn-executor.d.ts +1 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +137 -30
- package/dist/llm/registry/sync.cjs +15 -2
- package/dist/llm/registry/sync.d.ts.map +1 -1
- package/dist/llm/registry/sync.js +15 -2
- package/dist/llm/services/vercel.cjs +32 -5
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +32 -5
- package/dist/session/chat-session.cjs +41 -11
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +41 -11
- package/dist/telemetry/decorators.cjs +86 -82
- package/dist/telemetry/decorators.d.ts.map +1 -1
- package/dist/telemetry/decorators.js +86 -82
- package/dist/telemetry/operation-span.cjs +28 -27
- package/dist/telemetry/operation-span.d.ts.map +1 -1
- package/dist/telemetry/operation-span.js +28 -27
- package/dist/tools/tool-call-metadata.cjs +7 -4
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +7 -4
- package/package.json +3 -2
|
@@ -14,6 +14,7 @@ import { TurnExecutor } from "../executor/turn-executor.js";
|
|
|
14
14
|
import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
15
15
|
import { ErrorScope, ErrorType } from "../../errors/types.js";
|
|
16
16
|
import { LLMErrorCode } from "../error-codes.js";
|
|
17
|
+
import { recordOperationSpan } from "../../telemetry/operation-span.js";
|
|
17
18
|
function ensureRunContextMatchesServiceSession(serviceSessionId, runContext) {
|
|
18
19
|
if (runContext !== void 0 && runContext.sessionId !== serviceSessionId) {
|
|
19
20
|
throw new DextoRuntimeError(
|
|
@@ -93,11 +94,37 @@ class VercelLLMService {
|
|
|
93
94
|
async createTurnDriver(options = {}) {
|
|
94
95
|
const sessionId = ensureRunContextMatchesServiceSession(this.sessionId, options.runContext);
|
|
95
96
|
const executor = this.createTurnExecutor(options.signal, options.runContext);
|
|
96
|
-
const contributorContext = await
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
const contributorContext = await recordOperationSpan(
|
|
98
|
+
{
|
|
99
|
+
name: "llm.vercel.build_contributor_context",
|
|
100
|
+
attributes: {
|
|
101
|
+
"session.id": sessionId
|
|
102
|
+
},
|
|
103
|
+
resultAttributes: (context2) => ({
|
|
104
|
+
"tool.has_workspace_context": context2.workspace !== null,
|
|
105
|
+
"tool.has_environment_context": context2.environment !== void 0,
|
|
106
|
+
"tool.session_prompt_contributors": context2.session?.systemPromptContributors?.length ?? 0
|
|
107
|
+
})
|
|
108
|
+
},
|
|
109
|
+
() => this.toolManager.buildContributorContext({ sessionId }),
|
|
110
|
+
this.logger
|
|
111
|
+
);
|
|
112
|
+
const streaming = options.streaming ?? true;
|
|
113
|
+
return recordOperationSpan(
|
|
114
|
+
{
|
|
115
|
+
name: "llm.vercel.create_turn_executor_driver",
|
|
116
|
+
attributes: {
|
|
117
|
+
"session.id": sessionId,
|
|
118
|
+
"turn.streaming": streaming,
|
|
119
|
+
"turn.resume": options.state !== void 0
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
() => executor.createDriver(contributorContext, {
|
|
123
|
+
streaming,
|
|
124
|
+
...options.state !== void 0 ? { state: options.state } : {}
|
|
125
|
+
}),
|
|
126
|
+
this.logger
|
|
127
|
+
);
|
|
101
128
|
}
|
|
102
129
|
/**
|
|
103
130
|
* Create a TurnExecutor instance for executing the agent loop.
|
|
@@ -31,6 +31,7 @@ var import_message_queue = require("./message-queue.js");
|
|
|
31
31
|
var import_usage_metadata = require("../llm/usage-metadata.js");
|
|
32
32
|
var import_codex_base_url = require("../llm/providers/codex-base-url.js");
|
|
33
33
|
var import_errors2 = require("./errors.js");
|
|
34
|
+
var import_operation_span = require("../telemetry/operation-span.js");
|
|
34
35
|
class ChatSession {
|
|
35
36
|
/**
|
|
36
37
|
* Creates a new ChatSession instance.
|
|
@@ -426,19 +427,48 @@ class ChatSession {
|
|
|
426
427
|
const detachForwarders = this.attachRunEventForwarders(input.runContext);
|
|
427
428
|
try {
|
|
428
429
|
if (input.kind === "start") {
|
|
429
|
-
const modifiedParts = await
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
const modifiedParts = await (0, import_operation_span.recordOperationSpan)(
|
|
431
|
+
{
|
|
432
|
+
name: "chat_session.prepare_turn_input",
|
|
433
|
+
attributes: {
|
|
434
|
+
"session.id": this.id,
|
|
435
|
+
"turn.kind": input.kind
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
() => this.prepareTurnInput(input.content, signal, input.runContext),
|
|
439
|
+
this.logger
|
|
440
|
+
);
|
|
441
|
+
await (0, import_operation_span.recordOperationSpan)(
|
|
442
|
+
{
|
|
443
|
+
name: "chat_session.add_user_message",
|
|
444
|
+
attributes: {
|
|
445
|
+
"session.id": this.id,
|
|
446
|
+
"turn.kind": input.kind,
|
|
447
|
+
"message.parts": modifiedParts.length
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
() => this.llmService.getContextManager().addUserMessage(modifiedParts),
|
|
451
|
+
this.logger
|
|
433
452
|
);
|
|
434
|
-
await this.llmService.getContextManager().addUserMessage(modifiedParts);
|
|
435
453
|
}
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
454
|
+
const streaming = input.streaming ?? true;
|
|
455
|
+
const driver = await (0, import_operation_span.recordOperationSpan)(
|
|
456
|
+
{
|
|
457
|
+
name: "chat_session.create_llm_turn_driver",
|
|
458
|
+
attributes: {
|
|
459
|
+
"session.id": this.id,
|
|
460
|
+
"turn.kind": input.kind,
|
|
461
|
+
"turn.streaming": streaming
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
() => this.llmService.createTurnDriver({
|
|
465
|
+
signal,
|
|
466
|
+
streaming,
|
|
467
|
+
...input.runContext !== void 0 && { runContext: input.runContext },
|
|
468
|
+
...input.kind === "resume" ? { state: input.state } : {}
|
|
469
|
+
}),
|
|
470
|
+
this.logger
|
|
471
|
+
);
|
|
442
472
|
return this.wrapTurnDriver(driver, signal, input.runContext, detachForwarders);
|
|
443
473
|
} catch (error) {
|
|
444
474
|
if (input.kind === "start" && error instanceof import_errors.DextoRuntimeError && error.code === import_error_codes.HookErrorCode.HOOK_BLOCKED_EXECUTION && error.scope === import_errors.ErrorScope.HOOK && error.type === import_errors.ErrorType.FORBIDDEN) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../src/session/chat-session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,eAAe,EACf,aAAa,EAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,KAAK,EAA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IACI,gBAAgB,IAAI,aAAa,EAAE;IAI1C;;;OAGG;IACI,mBAAmB,IAAI,aAAa,EAAE;IAI7C;;;;OAIG;IACU,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7D;;;;OAIG;IACU,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAO/C;;;OAGG;IACU,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOlD;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQjD;;;OAGG;IACI,MAAM,IAAI,OAAO;CAa3B"}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from "../llm/usage-metadata.js";
|
|
17
17
|
import { parseCodexBaseURL } from "../llm/providers/codex-base-url.js";
|
|
18
18
|
import { SessionError } from "./errors.js";
|
|
19
|
+
import { recordOperationSpan } from "../telemetry/operation-span.js";
|
|
19
20
|
class ChatSession {
|
|
20
21
|
/**
|
|
21
22
|
* Creates a new ChatSession instance.
|
|
@@ -411,19 +412,48 @@ class ChatSession {
|
|
|
411
412
|
const detachForwarders = this.attachRunEventForwarders(input.runContext);
|
|
412
413
|
try {
|
|
413
414
|
if (input.kind === "start") {
|
|
414
|
-
const modifiedParts = await
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
const modifiedParts = await recordOperationSpan(
|
|
416
|
+
{
|
|
417
|
+
name: "chat_session.prepare_turn_input",
|
|
418
|
+
attributes: {
|
|
419
|
+
"session.id": this.id,
|
|
420
|
+
"turn.kind": input.kind
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
() => this.prepareTurnInput(input.content, signal, input.runContext),
|
|
424
|
+
this.logger
|
|
425
|
+
);
|
|
426
|
+
await recordOperationSpan(
|
|
427
|
+
{
|
|
428
|
+
name: "chat_session.add_user_message",
|
|
429
|
+
attributes: {
|
|
430
|
+
"session.id": this.id,
|
|
431
|
+
"turn.kind": input.kind,
|
|
432
|
+
"message.parts": modifiedParts.length
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
() => this.llmService.getContextManager().addUserMessage(modifiedParts),
|
|
436
|
+
this.logger
|
|
418
437
|
);
|
|
419
|
-
await this.llmService.getContextManager().addUserMessage(modifiedParts);
|
|
420
438
|
}
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
439
|
+
const streaming = input.streaming ?? true;
|
|
440
|
+
const driver = await recordOperationSpan(
|
|
441
|
+
{
|
|
442
|
+
name: "chat_session.create_llm_turn_driver",
|
|
443
|
+
attributes: {
|
|
444
|
+
"session.id": this.id,
|
|
445
|
+
"turn.kind": input.kind,
|
|
446
|
+
"turn.streaming": streaming
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
() => this.llmService.createTurnDriver({
|
|
450
|
+
signal,
|
|
451
|
+
streaming,
|
|
452
|
+
...input.runContext !== void 0 && { runContext: input.runContext },
|
|
453
|
+
...input.kind === "resume" ? { state: input.state } : {}
|
|
454
|
+
}),
|
|
455
|
+
this.logger
|
|
456
|
+
);
|
|
427
457
|
return this.wrapTurnDriver(driver, signal, input.runContext, detachForwarders);
|
|
428
458
|
} catch (error) {
|
|
429
459
|
if (input.kind === "start" && error instanceof DextoRuntimeError && error.code === HookErrorCode.HOOK_BLOCKED_EXECUTION && error.scope === ErrorScope.HOOK && error.type === ErrorType.FORBIDDEN) {
|
|
@@ -49,11 +49,7 @@ function withSpan(options) {
|
|
|
49
49
|
if (spanKind !== void 0) {
|
|
50
50
|
spanOptions.kind = spanKind;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
let ctx = import_api.trace.setSpan(import_api.context.active(), span);
|
|
54
|
-
args.forEach((arg, index) => {
|
|
55
|
-
span.setAttribute(`${spanName}.argument.${index}`, (0, import_safe_stringify.safeStringify)(arg, 8192));
|
|
56
|
-
});
|
|
52
|
+
let ctx = import_api.context.active();
|
|
57
53
|
const {
|
|
58
54
|
requestId,
|
|
59
55
|
componentName,
|
|
@@ -63,47 +59,52 @@ function withSpan(options) {
|
|
|
63
59
|
sessionId,
|
|
64
60
|
hostRuntime
|
|
65
61
|
} = (0, import_utils.getBaggageValues)(ctx);
|
|
66
|
-
if (sessionId) {
|
|
67
|
-
span.setAttribute("sessionId", sessionId);
|
|
68
|
-
span.setAttribute("baggage.sessionId", sessionId);
|
|
69
|
-
}
|
|
70
|
-
if (requestId) {
|
|
71
|
-
span.setAttribute("http.request_id", requestId);
|
|
72
|
-
span.setAttribute("baggage.http.request_id", requestId);
|
|
73
|
-
}
|
|
74
|
-
if (threadId) {
|
|
75
|
-
span.setAttribute("threadId", threadId);
|
|
76
|
-
span.setAttribute("baggage.threadId", threadId);
|
|
77
|
-
}
|
|
78
|
-
if (resourceId) {
|
|
79
|
-
span.setAttribute("resourceId", resourceId);
|
|
80
|
-
span.setAttribute("baggage.resourceId", resourceId);
|
|
81
|
-
}
|
|
82
|
-
if (runId !== void 0) {
|
|
83
|
-
span.setAttribute("runId", String(runId));
|
|
84
|
-
span.setAttribute("baggage.runId", String(runId));
|
|
85
|
-
}
|
|
86
|
-
for (const [key, value] of Object.entries((0, import_runtime.getHostRuntimeAttributes)(hostRuntime))) {
|
|
87
|
-
span.setAttribute(key, value);
|
|
88
|
-
}
|
|
89
62
|
const inferredComponentName = options?.componentName;
|
|
90
63
|
const effectiveHostRuntime = hostRuntime;
|
|
91
64
|
const effectiveRunId = effectiveHostRuntime?.ids?.runId ?? runId;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
65
|
+
const applySpanAttributes = (span) => {
|
|
66
|
+
args.forEach((arg, index) => {
|
|
67
|
+
span.setAttribute(`${spanName}.argument.${index}`, (0, import_safe_stringify.safeStringify)(arg, 8192));
|
|
68
|
+
});
|
|
69
|
+
if (sessionId) {
|
|
70
|
+
span.setAttribute("sessionId", sessionId);
|
|
71
|
+
span.setAttribute("baggage.sessionId", sessionId);
|
|
72
|
+
}
|
|
73
|
+
if (requestId) {
|
|
74
|
+
span.setAttribute("http.request_id", requestId);
|
|
75
|
+
span.setAttribute("baggage.http.request_id", requestId);
|
|
76
|
+
}
|
|
77
|
+
if (threadId) {
|
|
78
|
+
span.setAttribute("threadId", threadId);
|
|
79
|
+
span.setAttribute("baggage.threadId", threadId);
|
|
80
|
+
}
|
|
81
|
+
if (resourceId) {
|
|
82
|
+
span.setAttribute("resourceId", resourceId);
|
|
83
|
+
span.setAttribute("baggage.resourceId", resourceId);
|
|
84
|
+
}
|
|
85
|
+
if (runId !== void 0) {
|
|
86
|
+
span.setAttribute("runId", String(runId));
|
|
87
|
+
span.setAttribute("baggage.runId", String(runId));
|
|
88
|
+
}
|
|
89
|
+
for (const [key, value] of Object.entries((0, import_runtime.getHostRuntimeAttributes)(hostRuntime))) {
|
|
90
|
+
span.setAttribute(key, value);
|
|
91
|
+
}
|
|
92
|
+
if (componentName) {
|
|
93
|
+
span.setAttribute("componentName", componentName);
|
|
94
|
+
span.setAttribute("baggage.componentName", componentName);
|
|
95
|
+
} else if (inferredComponentName) {
|
|
96
|
+
span.setAttribute("componentName", inferredComponentName);
|
|
97
|
+
}
|
|
98
|
+
if (effectiveRunId !== void 0) {
|
|
99
|
+
span.setAttribute("runId", String(effectiveRunId));
|
|
100
|
+
span.setAttribute("baggage.runId", String(effectiveRunId));
|
|
101
|
+
}
|
|
102
|
+
for (const [key, value] of Object.entries(
|
|
103
|
+
(0, import_runtime.getHostRuntimeAttributes)(effectiveHostRuntime)
|
|
104
|
+
)) {
|
|
105
|
+
span.setAttribute(key, value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
107
108
|
const existingBaggage = import_api.propagation.getBaggage(ctx);
|
|
108
109
|
const baggageEntries = {};
|
|
109
110
|
if (existingBaggage) {
|
|
@@ -151,48 +152,51 @@ function withSpan(options) {
|
|
|
151
152
|
if (Object.keys(baggageEntries).length > 0) {
|
|
152
153
|
ctx = import_api.propagation.setBaggage(ctx, import_api.propagation.createBaggage(baggageEntries));
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
result
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
155
|
+
return tracer.startActiveSpan(spanName, spanOptions, ctx, (span) => {
|
|
156
|
+
applySpanAttributes(span);
|
|
157
|
+
let result;
|
|
158
|
+
try {
|
|
159
|
+
result = originalMethod.apply(this, args);
|
|
160
|
+
if (result instanceof Promise) {
|
|
161
|
+
return result.then((resolvedValue) => {
|
|
162
|
+
span.setAttribute(
|
|
163
|
+
`${spanName}.result`,
|
|
164
|
+
(0, import_safe_stringify.safeStringify)(resolvedValue, 8192)
|
|
165
|
+
);
|
|
166
|
+
return resolvedValue;
|
|
167
|
+
}).catch((error) => {
|
|
168
|
+
span.recordException(error);
|
|
169
|
+
span.setStatus({
|
|
170
|
+
code: import_api.SpanStatusCode.ERROR,
|
|
171
|
+
message: error?.toString()
|
|
172
|
+
});
|
|
173
|
+
throw error;
|
|
174
|
+
}).finally(() => {
|
|
175
|
+
span.end();
|
|
169
176
|
});
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
177
|
+
}
|
|
178
|
+
span.setAttribute(`${spanName}.result`, (0, import_safe_stringify.safeStringify)(result, 8192));
|
|
179
|
+
return result;
|
|
180
|
+
} catch (error) {
|
|
181
|
+
const logger2 = this?.logger;
|
|
182
|
+
logger2?.error(
|
|
183
|
+
`withSpan: Error in method '${methodName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
184
|
+
{ error }
|
|
185
|
+
);
|
|
186
|
+
span.setStatus({
|
|
187
|
+
code: import_api.SpanStatusCode.ERROR,
|
|
188
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
173
189
|
});
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
span.recordException(error);
|
|
192
|
+
}
|
|
193
|
+
throw error;
|
|
194
|
+
} finally {
|
|
195
|
+
if (!(result instanceof Promise)) {
|
|
196
|
+
span.end();
|
|
197
|
+
}
|
|
174
198
|
}
|
|
175
|
-
|
|
176
|
-
return result;
|
|
177
|
-
} catch (error) {
|
|
178
|
-
const logger2 = this?.logger;
|
|
179
|
-
logger2?.error(
|
|
180
|
-
`withSpan: Error in method '${methodName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
181
|
-
{ error }
|
|
182
|
-
);
|
|
183
|
-
span.setStatus({
|
|
184
|
-
code: import_api.SpanStatusCode.ERROR,
|
|
185
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
186
|
-
});
|
|
187
|
-
if (error instanceof Error) {
|
|
188
|
-
span.recordException(error);
|
|
189
|
-
}
|
|
190
|
-
throw error;
|
|
191
|
-
} finally {
|
|
192
|
-
if (!(result instanceof Promise)) {
|
|
193
|
-
span.end();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
199
|
+
});
|
|
196
200
|
};
|
|
197
201
|
return descriptor;
|
|
198
202
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/telemetry/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,QAAQ,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/telemetry/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,QAAQ,EAKX,MAAM,oBAAoB,CAAC;AAO5B,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,GAAG,CAmON;AAGD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,IACoB,CAAC,SAAS;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;CAAE,EAAE,QAAQ,CAAC,OA6BrE"}
|
|
@@ -32,11 +32,7 @@ function withSpan(options) {
|
|
|
32
32
|
if (spanKind !== void 0) {
|
|
33
33
|
spanOptions.kind = spanKind;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
let ctx = trace.setSpan(context.active(), span);
|
|
37
|
-
args.forEach((arg, index) => {
|
|
38
|
-
span.setAttribute(`${spanName}.argument.${index}`, safeStringify(arg, 8192));
|
|
39
|
-
});
|
|
35
|
+
let ctx = context.active();
|
|
40
36
|
const {
|
|
41
37
|
requestId,
|
|
42
38
|
componentName,
|
|
@@ -46,47 +42,52 @@ function withSpan(options) {
|
|
|
46
42
|
sessionId,
|
|
47
43
|
hostRuntime
|
|
48
44
|
} = getBaggageValues(ctx);
|
|
49
|
-
if (sessionId) {
|
|
50
|
-
span.setAttribute("sessionId", sessionId);
|
|
51
|
-
span.setAttribute("baggage.sessionId", sessionId);
|
|
52
|
-
}
|
|
53
|
-
if (requestId) {
|
|
54
|
-
span.setAttribute("http.request_id", requestId);
|
|
55
|
-
span.setAttribute("baggage.http.request_id", requestId);
|
|
56
|
-
}
|
|
57
|
-
if (threadId) {
|
|
58
|
-
span.setAttribute("threadId", threadId);
|
|
59
|
-
span.setAttribute("baggage.threadId", threadId);
|
|
60
|
-
}
|
|
61
|
-
if (resourceId) {
|
|
62
|
-
span.setAttribute("resourceId", resourceId);
|
|
63
|
-
span.setAttribute("baggage.resourceId", resourceId);
|
|
64
|
-
}
|
|
65
|
-
if (runId !== void 0) {
|
|
66
|
-
span.setAttribute("runId", String(runId));
|
|
67
|
-
span.setAttribute("baggage.runId", String(runId));
|
|
68
|
-
}
|
|
69
|
-
for (const [key, value] of Object.entries(getHostRuntimeAttributes(hostRuntime))) {
|
|
70
|
-
span.setAttribute(key, value);
|
|
71
|
-
}
|
|
72
45
|
const inferredComponentName = options?.componentName;
|
|
73
46
|
const effectiveHostRuntime = hostRuntime;
|
|
74
47
|
const effectiveRunId = effectiveHostRuntime?.ids?.runId ?? runId;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
48
|
+
const applySpanAttributes = (span) => {
|
|
49
|
+
args.forEach((arg, index) => {
|
|
50
|
+
span.setAttribute(`${spanName}.argument.${index}`, safeStringify(arg, 8192));
|
|
51
|
+
});
|
|
52
|
+
if (sessionId) {
|
|
53
|
+
span.setAttribute("sessionId", sessionId);
|
|
54
|
+
span.setAttribute("baggage.sessionId", sessionId);
|
|
55
|
+
}
|
|
56
|
+
if (requestId) {
|
|
57
|
+
span.setAttribute("http.request_id", requestId);
|
|
58
|
+
span.setAttribute("baggage.http.request_id", requestId);
|
|
59
|
+
}
|
|
60
|
+
if (threadId) {
|
|
61
|
+
span.setAttribute("threadId", threadId);
|
|
62
|
+
span.setAttribute("baggage.threadId", threadId);
|
|
63
|
+
}
|
|
64
|
+
if (resourceId) {
|
|
65
|
+
span.setAttribute("resourceId", resourceId);
|
|
66
|
+
span.setAttribute("baggage.resourceId", resourceId);
|
|
67
|
+
}
|
|
68
|
+
if (runId !== void 0) {
|
|
69
|
+
span.setAttribute("runId", String(runId));
|
|
70
|
+
span.setAttribute("baggage.runId", String(runId));
|
|
71
|
+
}
|
|
72
|
+
for (const [key, value] of Object.entries(getHostRuntimeAttributes(hostRuntime))) {
|
|
73
|
+
span.setAttribute(key, value);
|
|
74
|
+
}
|
|
75
|
+
if (componentName) {
|
|
76
|
+
span.setAttribute("componentName", componentName);
|
|
77
|
+
span.setAttribute("baggage.componentName", componentName);
|
|
78
|
+
} else if (inferredComponentName) {
|
|
79
|
+
span.setAttribute("componentName", inferredComponentName);
|
|
80
|
+
}
|
|
81
|
+
if (effectiveRunId !== void 0) {
|
|
82
|
+
span.setAttribute("runId", String(effectiveRunId));
|
|
83
|
+
span.setAttribute("baggage.runId", String(effectiveRunId));
|
|
84
|
+
}
|
|
85
|
+
for (const [key, value] of Object.entries(
|
|
86
|
+
getHostRuntimeAttributes(effectiveHostRuntime)
|
|
87
|
+
)) {
|
|
88
|
+
span.setAttribute(key, value);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
90
91
|
const existingBaggage = propagation.getBaggage(ctx);
|
|
91
92
|
const baggageEntries = {};
|
|
92
93
|
if (existingBaggage) {
|
|
@@ -134,48 +135,51 @@ function withSpan(options) {
|
|
|
134
135
|
if (Object.keys(baggageEntries).length > 0) {
|
|
135
136
|
ctx = propagation.setBaggage(ctx, propagation.createBaggage(baggageEntries));
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
result
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
return tracer.startActiveSpan(spanName, spanOptions, ctx, (span) => {
|
|
139
|
+
applySpanAttributes(span);
|
|
140
|
+
let result;
|
|
141
|
+
try {
|
|
142
|
+
result = originalMethod.apply(this, args);
|
|
143
|
+
if (result instanceof Promise) {
|
|
144
|
+
return result.then((resolvedValue) => {
|
|
145
|
+
span.setAttribute(
|
|
146
|
+
`${spanName}.result`,
|
|
147
|
+
safeStringify(resolvedValue, 8192)
|
|
148
|
+
);
|
|
149
|
+
return resolvedValue;
|
|
150
|
+
}).catch((error) => {
|
|
151
|
+
span.recordException(error);
|
|
152
|
+
span.setStatus({
|
|
153
|
+
code: SpanStatusCode.ERROR,
|
|
154
|
+
message: error?.toString()
|
|
155
|
+
});
|
|
156
|
+
throw error;
|
|
157
|
+
}).finally(() => {
|
|
158
|
+
span.end();
|
|
152
159
|
});
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
160
|
+
}
|
|
161
|
+
span.setAttribute(`${spanName}.result`, safeStringify(result, 8192));
|
|
162
|
+
return result;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
const logger2 = this?.logger;
|
|
165
|
+
logger2?.error(
|
|
166
|
+
`withSpan: Error in method '${methodName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
167
|
+
{ error }
|
|
168
|
+
);
|
|
169
|
+
span.setStatus({
|
|
170
|
+
code: SpanStatusCode.ERROR,
|
|
171
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
156
172
|
});
|
|
173
|
+
if (error instanceof Error) {
|
|
174
|
+
span.recordException(error);
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
} finally {
|
|
178
|
+
if (!(result instanceof Promise)) {
|
|
179
|
+
span.end();
|
|
180
|
+
}
|
|
157
181
|
}
|
|
158
|
-
|
|
159
|
-
return result;
|
|
160
|
-
} catch (error) {
|
|
161
|
-
const logger2 = this?.logger;
|
|
162
|
-
logger2?.error(
|
|
163
|
-
`withSpan: Error in method '${methodName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
164
|
-
{ error }
|
|
165
|
-
);
|
|
166
|
-
span.setStatus({
|
|
167
|
-
code: SpanStatusCode.ERROR,
|
|
168
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
169
|
-
});
|
|
170
|
-
if (error instanceof Error) {
|
|
171
|
-
span.recordException(error);
|
|
172
|
-
}
|
|
173
|
-
throw error;
|
|
174
|
-
} finally {
|
|
175
|
-
if (!(result instanceof Promise)) {
|
|
176
|
-
span.end();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
182
|
+
});
|
|
179
183
|
};
|
|
180
184
|
return descriptor;
|
|
181
185
|
};
|