@introspection-sdk/introspection-node 0.7.1 → 0.8.0
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/.turbo/turbo-build.log +1 -1
- package/README.md +24 -111
- package/dist/converters/claude.js +4 -4
- package/dist/converters/claude.js.map +1 -1
- package/dist/converters/gemini.d.ts +1 -1
- package/dist/converters/gemini.js +6 -6
- package/dist/converters/gemini.js.map +1 -1
- package/dist/converters/openai.js +4 -4
- package/dist/converters/openai.js.map +1 -1
- package/dist/converters/openinference.d.ts.map +1 -1
- package/dist/converters/openinference.js +4 -4
- package/dist/converters/openinference.js.map +1 -1
- package/dist/converters/vercel.js +4 -4
- package/dist/converters/vercel.js.map +1 -1
- package/dist/otel/anthropic.d.ts.map +1 -1
- package/dist/otel/anthropic.js +3 -4
- package/dist/otel/anthropic.js.map +1 -1
- package/dist/otel/claude-hooks.d.ts +2 -2
- package/dist/otel/claude-hooks.d.ts.map +1 -1
- package/dist/otel/claude-hooks.js +12 -10
- package/dist/otel/claude-hooks.js.map +1 -1
- package/dist/otel/gemini.d.ts +1 -1
- package/dist/otel/gemini.d.ts.map +1 -1
- package/dist/otel/gemini.js +1 -2
- package/dist/otel/gemini.js.map +1 -1
- package/dist/otel/langchain-handler.d.ts.map +1 -1
- package/dist/otel/langchain-handler.js +7 -4
- package/dist/otel/langchain-handler.js.map +1 -1
- package/dist/otel/mastra-exporter.d.ts.map +1 -1
- package/dist/otel/mastra-exporter.js +7 -5
- package/dist/otel/mastra-exporter.js.map +1 -1
- package/dist/otel/span-processor.d.ts.map +1 -1
- package/dist/otel/span-processor.js +3 -2
- package/dist/otel/span-processor.js.map +1 -1
- package/dist/otel/tracing-processor.d.ts +1 -1
- package/dist/otel/tracing-processor.d.ts.map +1 -1
- package/dist/otel/tracing-processor.js +13 -7
- package/dist/otel/tracing-processor.js.map +1 -1
- package/package.json +5 -5
- package/src/converters/claude.ts +4 -4
- package/src/converters/gemini.ts +6 -6
- package/src/converters/openai.ts +4 -4
- package/src/converters/openinference.ts +4 -9
- package/src/converters/vercel.ts +4 -4
- package/src/otel/anthropic.ts +4 -5
- package/src/otel/claude-hooks.ts +15 -10
- package/src/otel/gemini.ts +1 -2
- package/src/otel/langchain-handler.ts +11 -4
- package/src/otel/mastra-exporter.ts +7 -5
- package/src/otel/span-processor.ts +3 -2
- package/src/otel/tracing-processor.ts +13 -7
package/src/otel/gemini.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Lightweight Google Gemini (`@google/genai`) instrumentor for Introspection SDK.
|
|
3
3
|
*
|
|
4
4
|
* Captures the full Gemini response including per-part `thoughtSignature`
|
|
5
|
-
* payloads (Gemini 3.x extended thinking) as gen_ai `
|
|
5
|
+
* payloads (Gemini 3.x extended thinking) as gen_ai `reasoning` parts with
|
|
6
6
|
* `signature` set — mirroring how the {@link AnthropicInstrumentor} captures
|
|
7
7
|
* Anthropic thinking blocks.
|
|
8
8
|
*
|
|
@@ -63,7 +63,6 @@ function startSpan(
|
|
|
63
63
|
return tracer.startSpan("chat", {
|
|
64
64
|
kind: SpanKind.CLIENT,
|
|
65
65
|
attributes: {
|
|
66
|
-
"gen_ai.system": GEMINI_PROVIDER_NAME,
|
|
67
66
|
"gen_ai.provider.name": GEMINI_PROVIDER_NAME,
|
|
68
67
|
"gen_ai.operation.name": "chat",
|
|
69
68
|
"gen_ai.request.model": model,
|
|
@@ -317,7 +317,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
317
317
|
|
|
318
318
|
const provider = this._extractProvider(llm);
|
|
319
319
|
if (provider) {
|
|
320
|
-
otelSpan.setAttribute("gen_ai.
|
|
320
|
+
otelSpan.setAttribute("gen_ai.provider.name", provider);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
const invocationParams = extraParams?.["invocation_params"] as
|
|
@@ -571,15 +571,22 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
571
571
|
const toolName =
|
|
572
572
|
runName || tool?.name || tool?.id?.[tool.id.length - 1] || "tool";
|
|
573
573
|
|
|
574
|
-
const otelSpan = this._createChildSpan(
|
|
574
|
+
const otelSpan = this._createChildSpan(
|
|
575
|
+
`execute_tool ${toolName}`,
|
|
576
|
+
runId,
|
|
577
|
+
parentRunId,
|
|
578
|
+
);
|
|
575
579
|
this._spans.set(runId, otelSpan);
|
|
576
580
|
|
|
577
581
|
const conversationId = this._getConversationId(metadata);
|
|
578
582
|
this._setRootConversationId(conversationId, runId, parentRunId);
|
|
579
583
|
|
|
584
|
+
otelSpan.setAttribute("gen_ai.operation.name", "execute_tool");
|
|
580
585
|
otelSpan.setAttribute("gen_ai.tool.name", toolName);
|
|
586
|
+
otelSpan.setAttribute("gen_ai.tool.type", "function");
|
|
587
|
+
otelSpan.setAttribute("gen_ai.tool.call.id", runId);
|
|
581
588
|
otelSpan.setAttribute("openinference.span.kind", "TOOL");
|
|
582
|
-
otelSpan.setAttribute("gen_ai.tool.
|
|
589
|
+
otelSpan.setAttribute("gen_ai.tool.call.arguments", input);
|
|
583
590
|
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
584
591
|
}
|
|
585
592
|
|
|
@@ -591,7 +598,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
591
598
|
|
|
592
599
|
if (output != null) {
|
|
593
600
|
otelSpan.setAttribute(
|
|
594
|
-
"gen_ai.tool.
|
|
601
|
+
"gen_ai.tool.call.result",
|
|
595
602
|
typeof output === "string" ? output : JSON.stringify(output),
|
|
596
603
|
);
|
|
597
604
|
}
|
|
@@ -358,7 +358,7 @@ export class IntrospectionMastraExporter extends BaseExporter {
|
|
|
358
358
|
otelSpan.setAttribute("openinference.span.kind", "LLM");
|
|
359
359
|
|
|
360
360
|
if (model) otelSpan.setAttribute("gen_ai.request.model", model);
|
|
361
|
-
if (provider) otelSpan.setAttribute("gen_ai.
|
|
361
|
+
if (provider) otelSpan.setAttribute("gen_ai.provider.name", provider);
|
|
362
362
|
if (responseModel)
|
|
363
363
|
otelSpan.setAttribute("gen_ai.response.model", responseModel);
|
|
364
364
|
if (responseId) otelSpan.setAttribute("gen_ai.response.id", responseId);
|
|
@@ -481,14 +481,16 @@ export class IntrospectionMastraExporter extends BaseExporter {
|
|
|
481
481
|
const conversationId = this._getConversationId(span);
|
|
482
482
|
const toolName = span.entityName || span.name || "tool";
|
|
483
483
|
|
|
484
|
-
const otelSpan = this._createSpan(span, toolName);
|
|
484
|
+
const otelSpan = this._createSpan(span, `execute_tool ${toolName}`);
|
|
485
|
+
otelSpan.setAttribute("gen_ai.operation.name", "execute_tool");
|
|
485
486
|
otelSpan.setAttribute("gen_ai.tool.name", toolName);
|
|
487
|
+
otelSpan.setAttribute("gen_ai.tool.type", "function");
|
|
486
488
|
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
487
489
|
otelSpan.setAttribute("openinference.span.kind", "TOOL");
|
|
488
490
|
|
|
489
491
|
if (span.input != null) {
|
|
490
492
|
otelSpan.setAttribute(
|
|
491
|
-
"gen_ai.tool.
|
|
493
|
+
"gen_ai.tool.call.arguments",
|
|
492
494
|
typeof span.input === "string"
|
|
493
495
|
? span.input
|
|
494
496
|
: JSON.stringify(span.input),
|
|
@@ -496,7 +498,7 @@ export class IntrospectionMastraExporter extends BaseExporter {
|
|
|
496
498
|
}
|
|
497
499
|
if (span.output != null) {
|
|
498
500
|
otelSpan.setAttribute(
|
|
499
|
-
"gen_ai.tool.
|
|
501
|
+
"gen_ai.tool.call.result",
|
|
500
502
|
typeof span.output === "string"
|
|
501
503
|
? span.output
|
|
502
504
|
: JSON.stringify(span.output),
|
|
@@ -600,7 +602,7 @@ export class IntrospectionMastraExporter extends BaseExporter {
|
|
|
600
602
|
if (Array.isArray(out.reasoning)) {
|
|
601
603
|
for (const r of out.reasoning as Record<string, unknown>[]) {
|
|
602
604
|
const text = (r.text || r.content || "") as string;
|
|
603
|
-
if (text) parts.push({ type: "
|
|
605
|
+
if (text) parts.push({ type: "reasoning", content: text });
|
|
604
606
|
}
|
|
605
607
|
}
|
|
606
608
|
|
|
@@ -308,7 +308,7 @@ export class IntrospectionSpanProcessor implements SpanProcessor {
|
|
|
308
308
|
const hasGenAi =
|
|
309
309
|
isOI ||
|
|
310
310
|
isVercel ||
|
|
311
|
-
span.attributes["gen_ai.
|
|
311
|
+
span.attributes["gen_ai.provider.name"] != null ||
|
|
312
312
|
span.attributes["gen_ai.operation.name"] != null ||
|
|
313
313
|
span.attributes["gen_ai.request.model"] != null ||
|
|
314
314
|
span.attributes["gen_ai.input.messages"] != null ||
|
|
@@ -333,7 +333,7 @@ export class IntrospectionSpanProcessor implements SpanProcessor {
|
|
|
333
333
|
if (
|
|
334
334
|
key === "gen_ai.output.messages" &&
|
|
335
335
|
typeof value === "string" &&
|
|
336
|
-
value.includes('"
|
|
336
|
+
value.includes('"reasoning"')
|
|
337
337
|
) {
|
|
338
338
|
attrs[key] = value;
|
|
339
339
|
} else if (attrs[key] === undefined) {
|
|
@@ -351,6 +351,7 @@ export class IntrospectionSpanProcessor implements SpanProcessor {
|
|
|
351
351
|
} else {
|
|
352
352
|
attrs = { ...span.attributes };
|
|
353
353
|
}
|
|
354
|
+
delete attrs["gen_ai.system"];
|
|
354
355
|
|
|
355
356
|
// Read baggage from active context
|
|
356
357
|
const baggage = propagation.getBaggage(otelContext.active());
|
|
@@ -97,7 +97,7 @@ export interface IntrospectionTracingProcessorOptions {
|
|
|
97
97
|
*
|
|
98
98
|
* Extracts OTel Gen AI semantic convention attributes from span data:
|
|
99
99
|
* - Agent spans: `gen_ai.agent.name`, `gen_ai.tool.definitions`, `gen_ai.agent.handoffs`
|
|
100
|
-
* - Function spans: `gen_ai.tool.name`, `gen_ai.tool.
|
|
100
|
+
* - Function spans: `gen_ai.tool.name`, `gen_ai.tool.call.arguments`, `gen_ai.tool.call.result`
|
|
101
101
|
* - Response spans: `gen_ai.input/output.messages`, `gen_ai.usage.*`, `gen_ai.request.model`
|
|
102
102
|
* - Generation spans: `gen_ai.request.model`, `gen_ai.usage.*`
|
|
103
103
|
* - Handoff spans: `gen_ai.handoff.from_agent`, `gen_ai.handoff.to_agent`
|
|
@@ -336,12 +336,15 @@ export class IntrospectionTracingProcessor implements TracingProcessor {
|
|
|
336
336
|
*/
|
|
337
337
|
private _processAgentSpan(otelSpan: OtelSpan, spanData: AgentSpanData): void {
|
|
338
338
|
otelSpan.setAttribute("gen_ai.agent.name", spanData.name);
|
|
339
|
-
otelSpan.setAttribute("gen_ai.
|
|
339
|
+
otelSpan.setAttribute("gen_ai.provider.name", "openai");
|
|
340
340
|
otelSpan.setAttribute("openinference.span.kind", "AGENT");
|
|
341
341
|
|
|
342
342
|
if (spanData.tools) {
|
|
343
343
|
// Wrap tool names as objects for ClickHouse Array(JSON) compatibility
|
|
344
|
-
const toolDefs = spanData.tools.map((t: string) => ({
|
|
344
|
+
const toolDefs = spanData.tools.map((t: string) => ({
|
|
345
|
+
type: "function",
|
|
346
|
+
name: t,
|
|
347
|
+
}));
|
|
345
348
|
otelSpan.setAttribute(
|
|
346
349
|
"gen_ai.tool.definitions",
|
|
347
350
|
JSON.stringify(toolDefs),
|
|
@@ -367,15 +370,18 @@ export class IntrospectionTracingProcessor implements TracingProcessor {
|
|
|
367
370
|
otelSpan: OtelSpan,
|
|
368
371
|
spanData: FunctionSpanData,
|
|
369
372
|
): void {
|
|
373
|
+
otelSpan.updateName(`execute_tool ${spanData.name}`);
|
|
374
|
+
otelSpan.setAttribute("gen_ai.operation.name", "execute_tool");
|
|
370
375
|
otelSpan.setAttribute("gen_ai.tool.name", spanData.name);
|
|
376
|
+
otelSpan.setAttribute("gen_ai.tool.type", "function");
|
|
371
377
|
otelSpan.setAttribute("openinference.span.kind", "TOOL");
|
|
372
378
|
|
|
373
379
|
if (spanData.input) {
|
|
374
|
-
otelSpan.setAttribute("gen_ai.tool.
|
|
380
|
+
otelSpan.setAttribute("gen_ai.tool.call.arguments", spanData.input);
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
if (spanData.output) {
|
|
378
|
-
otelSpan.setAttribute("gen_ai.tool.
|
|
384
|
+
otelSpan.setAttribute("gen_ai.tool.call.result", String(spanData.output));
|
|
379
385
|
}
|
|
380
386
|
}
|
|
381
387
|
|
|
@@ -388,7 +394,7 @@ export class IntrospectionTracingProcessor implements TracingProcessor {
|
|
|
388
394
|
spanData: ResponseSpanData,
|
|
389
395
|
): void {
|
|
390
396
|
otelSpan.setAttribute("gen_ai.operation.name", "chat");
|
|
391
|
-
otelSpan.setAttribute("gen_ai.
|
|
397
|
+
otelSpan.setAttribute("gen_ai.provider.name", "openai");
|
|
392
398
|
otelSpan.setAttribute("openinference.span.kind", "LLM");
|
|
393
399
|
|
|
394
400
|
// Response ID (from span_data directly)
|
|
@@ -494,7 +500,7 @@ export class IntrospectionTracingProcessor implements TracingProcessor {
|
|
|
494
500
|
spanData: GenerationSpanData,
|
|
495
501
|
): void {
|
|
496
502
|
otelSpan.setAttribute("gen_ai.operation.name", "chat");
|
|
497
|
-
otelSpan.setAttribute("gen_ai.
|
|
503
|
+
otelSpan.setAttribute("gen_ai.provider.name", "openai");
|
|
498
504
|
otelSpan.setAttribute("openinference.span.kind", "LLM");
|
|
499
505
|
|
|
500
506
|
if (spanData.model) {
|