@mastra/otel-exporter 0.0.0-extract-tool-ui-inp-playground-ui-20251024041825 → 0.0.0-feat-add-query-option-to-playground-20251209160219
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 +218 -4
- package/README.md +57 -13
- package/dist/gen-ai-messages.d.ts +26 -0
- package/dist/gen-ai-messages.d.ts.map +1 -0
- package/dist/gen-ai-semantics.d.ts +22 -0
- package/dist/gen-ai-semantics.d.ts.map +1 -0
- package/dist/index.cjs +448 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +448 -380
- package/dist/index.js.map +1 -1
- package/dist/span-converter.d.ts +28 -30
- package/dist/span-converter.d.ts.map +1 -1
- package/dist/tracing.d.ts +27 -0
- package/dist/tracing.d.ts.map +1 -0
- package/dist/types.d.ts +4 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -10
- package/dist/ai-tracing.d.ts +0 -28
- package/dist/ai-tracing.d.ts.map +0 -1
- package/dist/mastra-span.d.ts +0 -38
- package/dist/mastra-span.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var observability = require('@mastra/core/observability');
|
|
4
|
+
var observability$1 = require('@mastra/observability');
|
|
5
5
|
var api = require('@opentelemetry/api');
|
|
6
|
-
var resources = require('@opentelemetry/resources');
|
|
7
6
|
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var url = require('url');
|
|
9
|
+
var resources = require('@opentelemetry/resources');
|
|
8
10
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
11
|
+
var incubating = require('@opentelemetry/semantic-conventions/incubating');
|
|
9
12
|
|
|
10
|
-
// src/
|
|
13
|
+
// src/tracing.ts
|
|
11
14
|
|
|
12
15
|
// src/loadExporter.ts
|
|
13
16
|
var OTLPHttpExporter;
|
|
@@ -205,410 +208,487 @@ function resolveCustomConfig(config) {
|
|
|
205
208
|
protocol: config.protocol || "http/json"
|
|
206
209
|
};
|
|
207
210
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.name = aiSpan.name;
|
|
230
|
-
this.kind = kind;
|
|
231
|
-
this.attributes = attributes;
|
|
232
|
-
this.parentSpanId = parentSpanId;
|
|
233
|
-
this.links = [];
|
|
234
|
-
this.events = [];
|
|
235
|
-
this.startTime = this.dateToHrTime(aiSpan.startTime);
|
|
236
|
-
this.endTime = aiSpan.endTime ? this.dateToHrTime(aiSpan.endTime) : this.startTime;
|
|
237
|
-
this.ended = !!aiSpan.endTime;
|
|
238
|
-
if (aiSpan.endTime) {
|
|
239
|
-
const durationMs = aiSpan.endTime.getTime() - aiSpan.startTime.getTime();
|
|
240
|
-
this.duration = [Math.floor(durationMs / 1e3), durationMs % 1e3 * 1e6];
|
|
241
|
-
} else {
|
|
242
|
-
this.duration = [0, 0];
|
|
211
|
+
|
|
212
|
+
// src/gen-ai-messages.ts
|
|
213
|
+
var isMastraMessagePart = (p) => {
|
|
214
|
+
return typeof p === "object" && p != null && "type" in p && (p.type === "text" || p.type === "tool-call" || p.type === "tool-result") && (p.type === "text" && "text" in p || p.type === "tool-call" && "toolCallId" in p && "toolName" in p && "input" in p || p.type === "tool-result" && "toolCallId" in p && "toolName" in p && "output" in p);
|
|
215
|
+
};
|
|
216
|
+
var isMastraMessage = (m) => {
|
|
217
|
+
return typeof m === "object" && m != null && "role" in m && "content" in m && (typeof m.content === "string" || Array.isArray(m.content) && m.content.every(isMastraMessagePart));
|
|
218
|
+
};
|
|
219
|
+
var convertMastraMessagesToGenAIMessages = (inputOutputString) => {
|
|
220
|
+
try {
|
|
221
|
+
const parsedIO = JSON.parse(inputOutputString);
|
|
222
|
+
if (typeof parsedIO !== "object" || parsedIO == null || !("messages" in parsedIO) && !("text" in parsedIO)) {
|
|
223
|
+
return inputOutputString;
|
|
224
|
+
}
|
|
225
|
+
if ("text" in parsedIO) {
|
|
226
|
+
return JSON.stringify([
|
|
227
|
+
{
|
|
228
|
+
role: "assistant",
|
|
229
|
+
parts: [{ type: "text", content: parsedIO.text }]
|
|
230
|
+
}
|
|
231
|
+
]);
|
|
243
232
|
}
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
this.events.push({
|
|
250
|
-
name: "exception",
|
|
251
|
-
attributes: {
|
|
252
|
-
"exception.message": aiSpan.errorInfo.message,
|
|
253
|
-
"exception.type": "Error",
|
|
254
|
-
...aiSpan.errorInfo.details?.stack && {
|
|
255
|
-
"exception.stacktrace": aiSpan.errorInfo.details.stack
|
|
233
|
+
if (Array.isArray(parsedIO.messages)) {
|
|
234
|
+
return JSON.stringify(
|
|
235
|
+
parsedIO.messages.map((m) => {
|
|
236
|
+
if (!isMastraMessage(m)) {
|
|
237
|
+
return m;
|
|
256
238
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
239
|
+
const role = m.role;
|
|
240
|
+
let parts = [];
|
|
241
|
+
if (Array.isArray(m.content)) {
|
|
242
|
+
parts = m.content.map((c) => {
|
|
243
|
+
switch (c.type) {
|
|
244
|
+
case "text":
|
|
245
|
+
return {
|
|
246
|
+
type: "text",
|
|
247
|
+
content: c.text
|
|
248
|
+
};
|
|
249
|
+
case "tool-call":
|
|
250
|
+
return {
|
|
251
|
+
type: "tool_call",
|
|
252
|
+
id: c.toolCallId,
|
|
253
|
+
name: c.toolName,
|
|
254
|
+
arguments: JSON.stringify(c.input)
|
|
255
|
+
};
|
|
256
|
+
case "tool-result":
|
|
257
|
+
return {
|
|
258
|
+
type: "tool_call_response",
|
|
259
|
+
id: c.toolCallId,
|
|
260
|
+
name: c.toolName,
|
|
261
|
+
response: JSON.stringify(c.output.value)
|
|
262
|
+
};
|
|
263
|
+
default:
|
|
264
|
+
return c;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
} else {
|
|
268
|
+
parts = [
|
|
269
|
+
{
|
|
270
|
+
type: "text",
|
|
271
|
+
content: m.content
|
|
272
|
+
}
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
role,
|
|
277
|
+
parts
|
|
278
|
+
};
|
|
279
|
+
})
|
|
280
|
+
);
|
|
287
281
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
version: "1.0.0"
|
|
292
|
-
};
|
|
293
|
-
this.instrumentationScope = this.instrumentationLibrary;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Convert JavaScript Date to hrtime format
|
|
297
|
-
*/
|
|
298
|
-
dateToHrTime(date) {
|
|
299
|
-
const ms = date.getTime();
|
|
300
|
-
const seconds = Math.floor(ms / 1e3);
|
|
301
|
-
const nanoseconds = ms % 1e3 * 1e6;
|
|
302
|
-
return [seconds, nanoseconds];
|
|
282
|
+
return inputOutputString;
|
|
283
|
+
} catch {
|
|
284
|
+
return inputOutputString;
|
|
303
285
|
}
|
|
304
286
|
};
|
|
305
287
|
|
|
306
|
-
// src/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
constructor(resource) {
|
|
321
|
-
this.resource = resource;
|
|
322
|
-
this.instrumentationLibrary = {
|
|
323
|
-
name: "@mastra/otel",
|
|
324
|
-
version: "1.0.0"
|
|
325
|
-
};
|
|
288
|
+
// src/gen-ai-semantics.ts
|
|
289
|
+
function getOperationName(span) {
|
|
290
|
+
switch (span.type) {
|
|
291
|
+
case observability.SpanType.MODEL_GENERATION:
|
|
292
|
+
return "chat";
|
|
293
|
+
case observability.SpanType.TOOL_CALL:
|
|
294
|
+
case observability.SpanType.MCP_TOOL_CALL:
|
|
295
|
+
return "execute_tool";
|
|
296
|
+
case observability.SpanType.AGENT_RUN:
|
|
297
|
+
return "invoke_agent";
|
|
298
|
+
case observability.SpanType.WORKFLOW_RUN:
|
|
299
|
+
return "invoke_workflow";
|
|
300
|
+
default:
|
|
301
|
+
return span.type.toLowerCase();
|
|
326
302
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
303
|
+
}
|
|
304
|
+
function sanitizeSpanName(name) {
|
|
305
|
+
return name.replace(/[^\p{L}\p{N}._ -]/gu, "");
|
|
306
|
+
}
|
|
307
|
+
function getSpanIdentifier(span) {
|
|
308
|
+
switch (span.type) {
|
|
309
|
+
case observability.SpanType.MODEL_GENERATION: {
|
|
310
|
+
const attrs = span.attributes;
|
|
311
|
+
return attrs?.model ?? "unknown";
|
|
312
|
+
}
|
|
313
|
+
case observability.SpanType.TOOL_CALL:
|
|
314
|
+
case observability.SpanType.MCP_TOOL_CALL: {
|
|
315
|
+
const attrs = span.attributes;
|
|
316
|
+
return attrs?.toolId ?? "unknown";
|
|
317
|
+
}
|
|
318
|
+
case observability.SpanType.AGENT_RUN: {
|
|
319
|
+
const attrs = span.attributes;
|
|
320
|
+
return attrs?.agentName ?? attrs?.agentId ?? "unknown";
|
|
321
|
+
}
|
|
322
|
+
case observability.SpanType.WORKFLOW_RUN: {
|
|
323
|
+
const attrs = span.attributes;
|
|
324
|
+
return attrs?.workflowId ?? "unknown";
|
|
325
|
+
}
|
|
326
|
+
default:
|
|
327
|
+
return null;
|
|
345
328
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
329
|
+
}
|
|
330
|
+
function getSpanName(span) {
|
|
331
|
+
const identifier = getSpanIdentifier(span);
|
|
332
|
+
if (identifier) {
|
|
333
|
+
const operation = getOperationName(span);
|
|
334
|
+
return `${operation} ${identifier}`;
|
|
335
|
+
}
|
|
336
|
+
return sanitizeSpanName(span.name);
|
|
337
|
+
}
|
|
338
|
+
function getAttributes(span) {
|
|
339
|
+
const attributes = {};
|
|
340
|
+
const spanType = span.type.toLowerCase();
|
|
341
|
+
attributes[incubating.ATTR_GEN_AI_OPERATION_NAME] = getOperationName(span);
|
|
342
|
+
attributes["mastra.span.type"] = span.type;
|
|
343
|
+
if (span.input !== void 0) {
|
|
344
|
+
const inputStr = typeof span.input === "string" ? span.input : JSON.stringify(span.input);
|
|
345
|
+
if (span.type === observability.SpanType.MODEL_GENERATION) {
|
|
346
|
+
attributes[incubating.ATTR_GEN_AI_INPUT_MESSAGES] = convertMastraMessagesToGenAIMessages(inputStr);
|
|
347
|
+
} else if (span.type === observability.SpanType.TOOL_CALL || span.type === observability.SpanType.MCP_TOOL_CALL) {
|
|
348
|
+
attributes["gen_ai.tool.call.arguments"] = inputStr;
|
|
349
|
+
} else {
|
|
350
|
+
attributes[`mastra.${spanType}.input`] = inputStr;
|
|
354
351
|
}
|
|
355
|
-
return SPAN_KIND_MAPPING[aiSpan.type] || api.SpanKind.INTERNAL;
|
|
356
352
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const model = attrs?.model || "unknown";
|
|
366
|
-
return `${operation} ${model}`;
|
|
367
|
-
}
|
|
368
|
-
case aiTracing.AISpanType.TOOL_CALL:
|
|
369
|
-
case aiTracing.AISpanType.MCP_TOOL_CALL: {
|
|
370
|
-
const toolAttrs = aiSpan.attributes;
|
|
371
|
-
const toolName = toolAttrs?.toolId || "unknown";
|
|
372
|
-
return `tool.execute ${toolName}`;
|
|
373
|
-
}
|
|
374
|
-
case aiTracing.AISpanType.AGENT_RUN: {
|
|
375
|
-
const agentAttrs = aiSpan.attributes;
|
|
376
|
-
const agentId = agentAttrs?.agentId || "unknown";
|
|
377
|
-
return `agent.${agentId}`;
|
|
378
|
-
}
|
|
379
|
-
case aiTracing.AISpanType.WORKFLOW_RUN: {
|
|
380
|
-
const workflowAttrs = aiSpan.attributes;
|
|
381
|
-
const workflowId = workflowAttrs?.workflowId || "unknown";
|
|
382
|
-
return `workflow.${workflowId}`;
|
|
383
|
-
}
|
|
384
|
-
case aiTracing.AISpanType.WORKFLOW_STEP:
|
|
385
|
-
return aiSpan.name;
|
|
386
|
-
default:
|
|
387
|
-
return aiSpan.name;
|
|
353
|
+
if (span.output !== void 0) {
|
|
354
|
+
const outputStr = typeof span.output === "string" ? span.output : JSON.stringify(span.output);
|
|
355
|
+
if (span.type === observability.SpanType.MODEL_GENERATION) {
|
|
356
|
+
attributes[incubating.ATTR_GEN_AI_OUTPUT_MESSAGES] = convertMastraMessagesToGenAIMessages(outputStr);
|
|
357
|
+
} else if (span.type === observability.SpanType.TOOL_CALL || span.type === observability.SpanType.MCP_TOOL_CALL) {
|
|
358
|
+
attributes["gen_ai.tool.call.result"] = outputStr;
|
|
359
|
+
} else {
|
|
360
|
+
attributes[`mastra.${spanType}.output`] = outputStr;
|
|
388
361
|
}
|
|
389
362
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
buildAttributes(aiSpan) {
|
|
395
|
-
const attributes = {};
|
|
396
|
-
attributes["gen_ai.operation.name"] = this.getOperationName(aiSpan);
|
|
397
|
-
attributes["span.kind"] = this.getSpanKindString(aiSpan);
|
|
398
|
-
attributes["mastra.span.type"] = aiSpan.type;
|
|
399
|
-
attributes["mastra.trace_id"] = aiSpan.traceId;
|
|
400
|
-
attributes["mastra.span_id"] = aiSpan.id;
|
|
401
|
-
if (aiSpan.parentSpanId) {
|
|
402
|
-
attributes["mastra.parent_span_id"] = aiSpan.parentSpanId;
|
|
403
|
-
}
|
|
404
|
-
if (aiSpan.input !== void 0) {
|
|
405
|
-
const inputStr = typeof aiSpan.input === "string" ? aiSpan.input : JSON.stringify(aiSpan.input);
|
|
406
|
-
attributes["input"] = inputStr;
|
|
407
|
-
if (aiSpan.type === aiTracing.AISpanType.MODEL_GENERATION) {
|
|
408
|
-
attributes["gen_ai.prompt"] = inputStr;
|
|
409
|
-
} else if (aiSpan.type === aiTracing.AISpanType.TOOL_CALL || aiSpan.type === aiTracing.AISpanType.MCP_TOOL_CALL) {
|
|
410
|
-
attributes["gen_ai.tool.input"] = inputStr;
|
|
411
|
-
}
|
|
363
|
+
if (span.type === observability.SpanType.MODEL_GENERATION && span.attributes) {
|
|
364
|
+
const modelAttrs = span.attributes;
|
|
365
|
+
if (modelAttrs.model) {
|
|
366
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_MODEL] = modelAttrs.model;
|
|
412
367
|
}
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
attributes["output"] = outputStr;
|
|
416
|
-
if (aiSpan.type === aiTracing.AISpanType.MODEL_GENERATION) {
|
|
417
|
-
attributes["gen_ai.completion"] = outputStr;
|
|
418
|
-
} else if (aiSpan.type === aiTracing.AISpanType.TOOL_CALL || aiSpan.type === aiTracing.AISpanType.MCP_TOOL_CALL) {
|
|
419
|
-
attributes["gen_ai.tool.output"] = outputStr;
|
|
420
|
-
}
|
|
368
|
+
if (modelAttrs.provider) {
|
|
369
|
+
attributes[incubating.ATTR_GEN_AI_PROVIDER_NAME] = normalizeProvider(modelAttrs.provider);
|
|
421
370
|
}
|
|
422
|
-
if (
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
371
|
+
if (modelAttrs.agentId) {
|
|
372
|
+
attributes[incubating.ATTR_GEN_AI_AGENT_ID] = modelAttrs.agentId;
|
|
373
|
+
}
|
|
374
|
+
if (modelAttrs.agentName) {
|
|
375
|
+
attributes[incubating.ATTR_GEN_AI_AGENT_NAME] = modelAttrs.agentName;
|
|
376
|
+
}
|
|
377
|
+
if (modelAttrs.usage) {
|
|
378
|
+
const inputTokens = modelAttrs.usage.inputTokens ?? modelAttrs.usage.promptTokens;
|
|
379
|
+
const outputTokens = modelAttrs.usage.outputTokens ?? modelAttrs.usage.completionTokens;
|
|
380
|
+
if (inputTokens !== void 0) {
|
|
381
|
+
attributes[incubating.ATTR_GEN_AI_USAGE_INPUT_TOKENS] = inputTokens;
|
|
426
382
|
}
|
|
427
|
-
if (
|
|
428
|
-
attributes[
|
|
383
|
+
if (outputTokens !== void 0) {
|
|
384
|
+
attributes[incubating.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS] = outputTokens;
|
|
429
385
|
}
|
|
430
|
-
if (modelAttrs.usage) {
|
|
431
|
-
|
|
432
|
-
const outputTokens = modelAttrs.usage.outputTokens ?? modelAttrs.usage.completionTokens;
|
|
433
|
-
if (inputTokens !== void 0) {
|
|
434
|
-
attributes["gen_ai.usage.input_tokens"] = inputTokens;
|
|
435
|
-
}
|
|
436
|
-
if (outputTokens !== void 0) {
|
|
437
|
-
attributes["gen_ai.usage.output_tokens"] = outputTokens;
|
|
438
|
-
}
|
|
439
|
-
if (modelAttrs.usage.totalTokens !== void 0) {
|
|
440
|
-
attributes["gen_ai.usage.total_tokens"] = modelAttrs.usage.totalTokens;
|
|
441
|
-
}
|
|
442
|
-
if (modelAttrs.usage.reasoningTokens !== void 0) {
|
|
443
|
-
attributes["gen_ai.usage.reasoning_tokens"] = modelAttrs.usage.reasoningTokens;
|
|
444
|
-
}
|
|
445
|
-
if (modelAttrs.usage.cachedInputTokens !== void 0) {
|
|
446
|
-
attributes["gen_ai.usage.cached_input_tokens"] = modelAttrs.usage.cachedInputTokens;
|
|
447
|
-
}
|
|
386
|
+
if (modelAttrs.usage.reasoningTokens !== void 0) {
|
|
387
|
+
attributes["gen_ai.usage.reasoning_tokens"] = modelAttrs.usage.reasoningTokens;
|
|
448
388
|
}
|
|
449
|
-
if (modelAttrs.
|
|
450
|
-
|
|
451
|
-
attributes["gen_ai.request.temperature"] = modelAttrs.parameters.temperature;
|
|
452
|
-
}
|
|
453
|
-
if (modelAttrs.parameters.maxOutputTokens !== void 0) {
|
|
454
|
-
attributes["gen_ai.request.max_tokens"] = modelAttrs.parameters.maxOutputTokens;
|
|
455
|
-
}
|
|
456
|
-
if (modelAttrs.parameters.topP !== void 0) {
|
|
457
|
-
attributes["gen_ai.request.top_p"] = modelAttrs.parameters.topP;
|
|
458
|
-
}
|
|
459
|
-
if (modelAttrs.parameters.topK !== void 0) {
|
|
460
|
-
attributes["gen_ai.request.top_k"] = modelAttrs.parameters.topK;
|
|
461
|
-
}
|
|
462
|
-
if (modelAttrs.parameters.presencePenalty !== void 0) {
|
|
463
|
-
attributes["gen_ai.request.presence_penalty"] = modelAttrs.parameters.presencePenalty;
|
|
464
|
-
}
|
|
465
|
-
if (modelAttrs.parameters.frequencyPenalty !== void 0) {
|
|
466
|
-
attributes["gen_ai.request.frequency_penalty"] = modelAttrs.parameters.frequencyPenalty;
|
|
467
|
-
}
|
|
468
|
-
if (modelAttrs.parameters.stopSequences) {
|
|
469
|
-
attributes["gen_ai.request.stop_sequences"] = JSON.stringify(modelAttrs.parameters.stopSequences);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
if (modelAttrs.finishReason) {
|
|
473
|
-
attributes["gen_ai.response.finish_reasons"] = modelAttrs.finishReason;
|
|
389
|
+
if (modelAttrs.usage.cachedInputTokens !== void 0) {
|
|
390
|
+
attributes["gen_ai.usage.cached_input_tokens"] = modelAttrs.usage.cachedInputTokens;
|
|
474
391
|
}
|
|
475
392
|
}
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
attributes["gen_ai.tool.name"] = toolAttrs.toolId;
|
|
393
|
+
if (modelAttrs.parameters) {
|
|
394
|
+
if (modelAttrs.parameters.temperature !== void 0) {
|
|
395
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_TEMPERATURE] = modelAttrs.parameters.temperature;
|
|
480
396
|
}
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
if (mcpAttrs.mcpServer) {
|
|
484
|
-
attributes["mcp.server"] = mcpAttrs.mcpServer;
|
|
485
|
-
}
|
|
486
|
-
if (mcpAttrs.serverVersion) {
|
|
487
|
-
attributes["mcp.server.version"] = mcpAttrs.serverVersion;
|
|
488
|
-
}
|
|
489
|
-
} else {
|
|
490
|
-
if (toolAttrs.toolDescription) {
|
|
491
|
-
attributes["gen_ai.tool.description"] = toolAttrs.toolDescription;
|
|
492
|
-
}
|
|
397
|
+
if (modelAttrs.parameters.maxOutputTokens !== void 0) {
|
|
398
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_MAX_TOKENS] = modelAttrs.parameters.maxOutputTokens;
|
|
493
399
|
}
|
|
494
|
-
if (
|
|
495
|
-
attributes[
|
|
400
|
+
if (modelAttrs.parameters.topP !== void 0) {
|
|
401
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_TOP_P] = modelAttrs.parameters.topP;
|
|
496
402
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const agentAttrs = aiSpan.attributes;
|
|
500
|
-
if (agentAttrs.agentId) {
|
|
501
|
-
attributes["agent.id"] = agentAttrs.agentId;
|
|
502
|
-
attributes["gen_ai.agent.id"] = agentAttrs.agentId;
|
|
403
|
+
if (modelAttrs.parameters.topK !== void 0) {
|
|
404
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_TOP_K] = modelAttrs.parameters.topK;
|
|
503
405
|
}
|
|
504
|
-
if (
|
|
505
|
-
attributes[
|
|
406
|
+
if (modelAttrs.parameters.presencePenalty !== void 0) {
|
|
407
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_PRESENCE_PENALTY] = modelAttrs.parameters.presencePenalty;
|
|
506
408
|
}
|
|
507
|
-
if (
|
|
508
|
-
attributes[
|
|
409
|
+
if (modelAttrs.parameters.frequencyPenalty !== void 0) {
|
|
410
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_FREQUENCY_PENALTY] = modelAttrs.parameters.frequencyPenalty;
|
|
509
411
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const workflowAttrs = aiSpan.attributes;
|
|
513
|
-
if (workflowAttrs.workflowId) {
|
|
514
|
-
attributes["workflow.id"] = workflowAttrs.workflowId;
|
|
412
|
+
if (modelAttrs.parameters.stopSequences) {
|
|
413
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] = JSON.stringify(modelAttrs.parameters.stopSequences);
|
|
515
414
|
}
|
|
516
|
-
if (
|
|
517
|
-
attributes[
|
|
415
|
+
if (modelAttrs.parameters.seed) {
|
|
416
|
+
attributes[incubating.ATTR_GEN_AI_REQUEST_SEED] = modelAttrs.parameters.seed;
|
|
518
417
|
}
|
|
519
418
|
}
|
|
520
|
-
if (
|
|
521
|
-
attributes[
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
419
|
+
if (modelAttrs.finishReason) {
|
|
420
|
+
attributes[incubating.ATTR_GEN_AI_RESPONSE_FINISH_REASONS] = JSON.stringify([modelAttrs.finishReason]);
|
|
421
|
+
}
|
|
422
|
+
if (modelAttrs.responseModel) {
|
|
423
|
+
attributes[incubating.ATTR_GEN_AI_RESPONSE_MODEL] = modelAttrs.responseModel;
|
|
424
|
+
}
|
|
425
|
+
if (modelAttrs.responseId) {
|
|
426
|
+
attributes[incubating.ATTR_GEN_AI_RESPONSE_ID] = modelAttrs.responseId;
|
|
427
|
+
}
|
|
428
|
+
if (modelAttrs.serverAddress) {
|
|
429
|
+
attributes[incubating.ATTR_SERVER_ADDRESS] = modelAttrs.serverAddress;
|
|
430
|
+
}
|
|
431
|
+
if (modelAttrs.serverPort !== void 0) {
|
|
432
|
+
attributes[incubating.ATTR_SERVER_PORT] = modelAttrs.serverPort;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if ((span.type === observability.SpanType.TOOL_CALL || span.type === observability.SpanType.MCP_TOOL_CALL) && span.attributes) {
|
|
436
|
+
const toolAttrs = span.attributes;
|
|
437
|
+
if (toolAttrs.toolId) {
|
|
438
|
+
attributes[incubating.ATTR_GEN_AI_TOOL_NAME] = toolAttrs.toolId;
|
|
439
|
+
}
|
|
440
|
+
if (span.type === observability.SpanType.MCP_TOOL_CALL) {
|
|
441
|
+
const mcpAttrs = toolAttrs;
|
|
442
|
+
if (mcpAttrs.mcpServer) {
|
|
443
|
+
attributes[incubating.ATTR_SERVER_ADDRESS] = mcpAttrs.mcpServer;
|
|
526
444
|
}
|
|
527
|
-
|
|
528
|
-
|
|
445
|
+
} else {
|
|
446
|
+
if (toolAttrs.toolDescription) {
|
|
447
|
+
attributes[incubating.ATTR_GEN_AI_TOOL_DESCRIPTION] = toolAttrs.toolDescription;
|
|
529
448
|
}
|
|
530
449
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
450
|
+
}
|
|
451
|
+
if (span.type === observability.SpanType.AGENT_RUN && span.attributes) {
|
|
452
|
+
const agentAttrs = span.attributes;
|
|
453
|
+
if (agentAttrs.agentId) {
|
|
454
|
+
attributes[incubating.ATTR_GEN_AI_AGENT_ID] = agentAttrs.agentId;
|
|
455
|
+
}
|
|
456
|
+
if (agentAttrs.agentName) {
|
|
457
|
+
attributes[incubating.ATTR_GEN_AI_AGENT_NAME] = agentAttrs.agentName;
|
|
458
|
+
}
|
|
459
|
+
if (agentAttrs.conversationId) {
|
|
460
|
+
attributes[incubating.ATTR_GEN_AI_CONVERSATION_ID] = agentAttrs.conversationId;
|
|
461
|
+
}
|
|
462
|
+
if (agentAttrs.maxSteps) {
|
|
463
|
+
attributes[`mastra.${spanType}.max_steps`] = agentAttrs.maxSteps;
|
|
464
|
+
}
|
|
465
|
+
if (agentAttrs.availableTools) {
|
|
466
|
+
attributes[`gen_ai.tool.definitions`] = JSON.stringify(agentAttrs.availableTools);
|
|
467
|
+
}
|
|
468
|
+
attributes[incubating.ATTR_GEN_AI_SYSTEM_INSTRUCTIONS] = agentAttrs.instructions;
|
|
469
|
+
}
|
|
470
|
+
if (span.errorInfo) {
|
|
471
|
+
attributes[incubating.ATTR_ERROR_TYPE] = span.errorInfo.id || "unknown";
|
|
472
|
+
attributes[incubating.ATTR_ERROR_MESSAGE] = span.errorInfo.message;
|
|
473
|
+
if (span.errorInfo.domain) {
|
|
474
|
+
attributes["error.domain"] = span.errorInfo.domain;
|
|
544
475
|
}
|
|
545
|
-
if (
|
|
546
|
-
attributes["
|
|
476
|
+
if (span.errorInfo.category) {
|
|
477
|
+
attributes["error.category"] = span.errorInfo.category;
|
|
547
478
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
479
|
+
}
|
|
480
|
+
return attributes;
|
|
481
|
+
}
|
|
482
|
+
var PROVIDER_ALIASES = {
|
|
483
|
+
anthropic: ["anthropic", "claude"],
|
|
484
|
+
"aws.bedrock": ["awsbedrock", "bedrock", "amazonbedrock"],
|
|
485
|
+
"azure.ai.inference": ["azureaiinference", "azureinference"],
|
|
486
|
+
"azure.ai.openai": ["azureaiopenai", "azureopenai", "msopenai", "microsoftopenai"],
|
|
487
|
+
cohere: ["cohere"],
|
|
488
|
+
deepseek: ["deepseek"],
|
|
489
|
+
"gcp.gemini": ["gcpgemini", "gemini"],
|
|
490
|
+
"gcp.gen_ai": ["gcpgenai", "googlegenai", "googleai"],
|
|
491
|
+
"gcp.vertex_ai": ["gcpvertexai", "vertexai"],
|
|
492
|
+
groq: ["groq"],
|
|
493
|
+
"ibm.watsonx.ai": ["ibmwatsonxai", "watsonx", "watsonxai"],
|
|
494
|
+
mistral_ai: ["mistral", "mistralai"],
|
|
495
|
+
openai: ["openai", "oai"],
|
|
496
|
+
perplexity: ["perplexity", "pplx"],
|
|
497
|
+
x_ai: ["xai", "x-ai", "x_ai", "x.com ai"]
|
|
498
|
+
};
|
|
499
|
+
function normalizeProviderString(input) {
|
|
500
|
+
return input.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
501
|
+
}
|
|
502
|
+
function normalizeProvider(providerName) {
|
|
503
|
+
const normalized = normalizeProviderString(providerName);
|
|
504
|
+
for (const [canonical, aliases] of Object.entries(PROVIDER_ALIASES)) {
|
|
505
|
+
for (const alias of aliases) {
|
|
506
|
+
if (normalized === alias) {
|
|
507
|
+
return canonical;
|
|
508
|
+
}
|
|
552
509
|
}
|
|
553
|
-
return attributes;
|
|
554
510
|
}
|
|
511
|
+
return providerName.toLowerCase();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/span-converter.ts
|
|
515
|
+
var SpanConverter = class {
|
|
516
|
+
constructor(params) {
|
|
517
|
+
this.params = params;
|
|
518
|
+
this.format = params.format;
|
|
519
|
+
}
|
|
520
|
+
resource;
|
|
521
|
+
scope;
|
|
522
|
+
initPromise;
|
|
523
|
+
format;
|
|
555
524
|
/**
|
|
556
|
-
*
|
|
525
|
+
* Lazily initialize resource & scope on first use.
|
|
526
|
+
* Subsequent calls reuse the same promise (no races).
|
|
557
527
|
*/
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
528
|
+
async initIfNeeded() {
|
|
529
|
+
if (this.initPromise) {
|
|
530
|
+
return this.initPromise;
|
|
531
|
+
}
|
|
532
|
+
this.initPromise = (async () => {
|
|
533
|
+
const packageVersion = await getPackageVersion(this.params.packageName) ?? "unknown";
|
|
534
|
+
const serviceVersion = await getPackageVersion("@mastra/core") ?? "unknown";
|
|
535
|
+
let resource = resources.resourceFromAttributes({
|
|
536
|
+
[semanticConventions.ATTR_SERVICE_NAME]: this.params.serviceName || "mastra-service",
|
|
537
|
+
[semanticConventions.ATTR_SERVICE_VERSION]: serviceVersion,
|
|
538
|
+
[semanticConventions.ATTR_TELEMETRY_SDK_NAME]: this.params.packageName,
|
|
539
|
+
[semanticConventions.ATTR_TELEMETRY_SDK_VERSION]: packageVersion,
|
|
540
|
+
[semanticConventions.ATTR_TELEMETRY_SDK_LANGUAGE]: "nodejs"
|
|
541
|
+
});
|
|
542
|
+
if (this.params.config?.resourceAttributes) {
|
|
543
|
+
resource = resource.merge(
|
|
544
|
+
// Duplicate attributes from config will override defaults above
|
|
545
|
+
resources.resourceFromAttributes(this.params.config.resourceAttributes)
|
|
546
|
+
);
|
|
563
547
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
default:
|
|
572
|
-
return aiSpan.type.replace(/_/g, ".");
|
|
573
|
-
}
|
|
548
|
+
this.resource = resource;
|
|
549
|
+
this.scope = {
|
|
550
|
+
name: this.params.packageName,
|
|
551
|
+
version: packageVersion
|
|
552
|
+
};
|
|
553
|
+
})();
|
|
554
|
+
return this.initPromise;
|
|
574
555
|
}
|
|
575
556
|
/**
|
|
576
|
-
*
|
|
557
|
+
* Convert a Mastra Span to an OpenTelemetry ReadableSpan
|
|
577
558
|
*/
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
559
|
+
async convertSpan(span) {
|
|
560
|
+
await this.initIfNeeded();
|
|
561
|
+
if (!this.resource || !this.scope) {
|
|
562
|
+
throw new Error("SpanConverter not initialized correctly");
|
|
563
|
+
}
|
|
564
|
+
const name = getSpanName(span);
|
|
565
|
+
const kind = getSpanKind(span.type);
|
|
566
|
+
const attributes = getAttributes(span);
|
|
567
|
+
if (span.metadata) {
|
|
568
|
+
for (const [k, v] of Object.entries(span.metadata)) {
|
|
569
|
+
if (v === null || v === void 0) {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
attributes[`mastra.metadata.${k}`] = typeof v === "object" ? JSON.stringify(v) : v;
|
|
573
|
+
}
|
|
593
574
|
}
|
|
575
|
+
if (span.isRootSpan && span.tags?.length) {
|
|
576
|
+
attributes["mastra.tags"] = JSON.stringify(span.tags);
|
|
577
|
+
}
|
|
578
|
+
const startTime = dateToHrTime(span.startTime);
|
|
579
|
+
const endTime = span.endTime ? dateToHrTime(span.endTime) : startTime;
|
|
580
|
+
const duration = computeDuration(span.startTime, span.endTime);
|
|
581
|
+
const { status, events } = buildStatusAndEvents(span, startTime);
|
|
582
|
+
const spanContext = {
|
|
583
|
+
traceId: span.traceId,
|
|
584
|
+
spanId: span.id,
|
|
585
|
+
traceFlags: api.TraceFlags.SAMPLED,
|
|
586
|
+
isRemote: false
|
|
587
|
+
};
|
|
588
|
+
const parentSpanContext = span.parentSpanId ? {
|
|
589
|
+
traceId: span.traceId,
|
|
590
|
+
spanId: span.parentSpanId,
|
|
591
|
+
traceFlags: api.TraceFlags.SAMPLED,
|
|
592
|
+
isRemote: false
|
|
593
|
+
} : void 0;
|
|
594
|
+
const links = [];
|
|
595
|
+
const readable = {
|
|
596
|
+
name,
|
|
597
|
+
kind,
|
|
598
|
+
spanContext: () => spanContext,
|
|
599
|
+
parentSpanContext,
|
|
600
|
+
startTime,
|
|
601
|
+
endTime,
|
|
602
|
+
status,
|
|
603
|
+
attributes,
|
|
604
|
+
links,
|
|
605
|
+
events,
|
|
606
|
+
duration,
|
|
607
|
+
ended: !!span.endTime,
|
|
608
|
+
resource: this.resource,
|
|
609
|
+
instrumentationScope: this.scope,
|
|
610
|
+
droppedAttributesCount: 0,
|
|
611
|
+
droppedEventsCount: 0,
|
|
612
|
+
droppedLinksCount: 0
|
|
613
|
+
};
|
|
614
|
+
return readable;
|
|
594
615
|
}
|
|
595
616
|
};
|
|
617
|
+
async function getPackageVersion(pkgName) {
|
|
618
|
+
try {
|
|
619
|
+
const manifestUrl = new URL(await undefined(`${pkgName}/package.json`));
|
|
620
|
+
const path = url.fileURLToPath(manifestUrl);
|
|
621
|
+
const pkgJson = JSON.parse(fs.readFileSync(path, "utf8"));
|
|
622
|
+
return pkgJson.version;
|
|
623
|
+
} catch {
|
|
624
|
+
return void 0;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function getSpanKind(type) {
|
|
628
|
+
switch (type) {
|
|
629
|
+
case observability.SpanType.MODEL_GENERATION:
|
|
630
|
+
case observability.SpanType.MCP_TOOL_CALL:
|
|
631
|
+
return api.SpanKind.CLIENT;
|
|
632
|
+
default:
|
|
633
|
+
return api.SpanKind.INTERNAL;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function dateToHrTime(date) {
|
|
637
|
+
const ms = date.getTime();
|
|
638
|
+
const seconds = Math.floor(ms / 1e3);
|
|
639
|
+
const nanoseconds = ms % 1e3 * 1e6;
|
|
640
|
+
return [seconds, nanoseconds];
|
|
641
|
+
}
|
|
642
|
+
function computeDuration(start, end) {
|
|
643
|
+
if (!end) return [0, 0];
|
|
644
|
+
const diffMs = end.getTime() - start.getTime();
|
|
645
|
+
return [Math.floor(diffMs / 1e3), diffMs % 1e3 * 1e6];
|
|
646
|
+
}
|
|
647
|
+
function buildStatusAndEvents(span, defaultTime) {
|
|
648
|
+
const events = [];
|
|
649
|
+
if (span.errorInfo) {
|
|
650
|
+
const status = {
|
|
651
|
+
code: api.SpanStatusCode.ERROR,
|
|
652
|
+
message: span.errorInfo.message
|
|
653
|
+
};
|
|
654
|
+
events.push({
|
|
655
|
+
name: "exception",
|
|
656
|
+
attributes: {
|
|
657
|
+
"exception.message": span.errorInfo.message,
|
|
658
|
+
"exception.type": "Error",
|
|
659
|
+
...span.errorInfo.details?.stack && {
|
|
660
|
+
"exception.stacktrace": span.errorInfo.details.stack
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
time: defaultTime,
|
|
664
|
+
droppedAttributesCount: 0
|
|
665
|
+
});
|
|
666
|
+
return { status, events };
|
|
667
|
+
}
|
|
668
|
+
if (span.endTime) {
|
|
669
|
+
return {
|
|
670
|
+
status: { code: api.SpanStatusCode.OK },
|
|
671
|
+
events
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
return {
|
|
675
|
+
status: { code: api.SpanStatusCode.UNSET },
|
|
676
|
+
events
|
|
677
|
+
};
|
|
678
|
+
}
|
|
596
679
|
|
|
597
|
-
// src/
|
|
598
|
-
var OtelExporter = class {
|
|
680
|
+
// src/tracing.ts
|
|
681
|
+
var OtelExporter = class extends observability$1.BaseExporter {
|
|
599
682
|
config;
|
|
600
|
-
|
|
683
|
+
observabilityConfig;
|
|
601
684
|
spanConverter;
|
|
602
685
|
processor;
|
|
603
686
|
exporter;
|
|
604
687
|
isSetup = false;
|
|
605
|
-
isDisabled = false;
|
|
606
|
-
logger;
|
|
607
688
|
name = "opentelemetry";
|
|
608
689
|
constructor(config) {
|
|
690
|
+
super(config);
|
|
609
691
|
this.config = config;
|
|
610
|
-
this.spanConverter = new SpanConverter();
|
|
611
|
-
this.logger = new logger.ConsoleLogger({ level: config.logLevel ?? "warn" });
|
|
612
692
|
if (config.logLevel === "debug") {
|
|
613
693
|
api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.DEBUG);
|
|
614
694
|
}
|
|
@@ -616,8 +696,8 @@ var OtelExporter = class {
|
|
|
616
696
|
/**
|
|
617
697
|
* Initialize with tracing configuration
|
|
618
698
|
*/
|
|
619
|
-
init(
|
|
620
|
-
this.
|
|
699
|
+
init(options) {
|
|
700
|
+
this.observabilityConfig = options.config;
|
|
621
701
|
}
|
|
622
702
|
async setupExporter() {
|
|
623
703
|
if (this.isSetup || this.exporter) return;
|
|
@@ -695,21 +775,12 @@ var OtelExporter = class {
|
|
|
695
775
|
}
|
|
696
776
|
async setupProcessor() {
|
|
697
777
|
if (this.processor || this.isSetup) return;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
[semanticConventions.ATTR_TELEMETRY_SDK_VERSION]: "1.0.0",
|
|
704
|
-
[semanticConventions.ATTR_TELEMETRY_SDK_LANGUAGE]: "nodejs"
|
|
778
|
+
this.spanConverter = new SpanConverter({
|
|
779
|
+
packageName: "@mastra/otel-exporter",
|
|
780
|
+
serviceName: this.observabilityConfig?.serviceName,
|
|
781
|
+
config: this.config,
|
|
782
|
+
format: "GenAI_v1_38_0"
|
|
705
783
|
});
|
|
706
|
-
if (this.config.resourceAttributes) {
|
|
707
|
-
resource = resource.merge(
|
|
708
|
-
// Duplicate attributes from config will override defaults above
|
|
709
|
-
resources.resourceFromAttributes(this.config.resourceAttributes)
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
this.spanConverter = new SpanConverter(resource);
|
|
713
784
|
this.processor = new sdkTraceBase.BatchSpanProcessor(this.exporter, {
|
|
714
785
|
maxExportBatchSize: this.config.batchSize || 512,
|
|
715
786
|
// Default batch size
|
|
@@ -730,11 +801,8 @@ var OtelExporter = class {
|
|
|
730
801
|
await this.setupProcessor();
|
|
731
802
|
this.isSetup = true;
|
|
732
803
|
}
|
|
733
|
-
async
|
|
734
|
-
if (
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
if (event.type !== aiTracing.AITracingEventType.SPAN_ENDED) {
|
|
804
|
+
async _exportTracingEvent(event) {
|
|
805
|
+
if (event.type !== observability.TracingEventType.SPAN_ENDED) {
|
|
738
806
|
return;
|
|
739
807
|
}
|
|
740
808
|
const span = event.exportedSpan;
|
|
@@ -748,9 +816,9 @@ var OtelExporter = class {
|
|
|
748
816
|
return;
|
|
749
817
|
}
|
|
750
818
|
try {
|
|
751
|
-
const
|
|
819
|
+
const otelSpan = await this.spanConverter.convertSpan(span);
|
|
752
820
|
await new Promise((resolve) => {
|
|
753
|
-
this.processor.onEnd(
|
|
821
|
+
this.processor.onEnd(otelSpan);
|
|
754
822
|
resolve();
|
|
755
823
|
});
|
|
756
824
|
this.logger.debug(
|
|
@@ -768,5 +836,7 @@ var OtelExporter = class {
|
|
|
768
836
|
};
|
|
769
837
|
|
|
770
838
|
exports.OtelExporter = OtelExporter;
|
|
839
|
+
exports.SpanConverter = SpanConverter;
|
|
840
|
+
exports.getSpanKind = getSpanKind;
|
|
771
841
|
//# sourceMappingURL=index.cjs.map
|
|
772
842
|
//# sourceMappingURL=index.cjs.map
|