@respan/instrumentation-pydantic-ai 0.1.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/README.md +58 -0
- package/dist/_constants.d.ts +68 -0
- package/dist/_constants.js +145 -0
- package/dist/_constants.js.map +1 -0
- package/dist/_processor.d.ts +20 -0
- package/dist/_processor.js +815 -0
- package/dist/_processor.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @respan/instrumentation-pydantic-ai
|
|
2
|
+
|
|
3
|
+
Respan instrumentation for Pydantic AI-compatible TypeScript OpenTelemetry spans.
|
|
4
|
+
|
|
5
|
+
The repository does not currently document a stable TypeScript Pydantic AI SDK API
|
|
6
|
+
to patch. This package therefore installs a conservative span processor instead:
|
|
7
|
+
it normalizes Pydantic AI native OTel spans and Pydantic AI-scoped
|
|
8
|
+
OpenInference spans into the canonical Respan span contract before export.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @respan/respan @respan/instrumentation-pydantic-ai
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { Respan } from "@respan/respan";
|
|
20
|
+
import { PydanticAIInstrumentor } from "@respan/instrumentation-pydantic-ai";
|
|
21
|
+
|
|
22
|
+
const respan = new Respan({
|
|
23
|
+
apiKey: process.env.RESPAN_API_KEY,
|
|
24
|
+
baseURL: process.env.RESPAN_BASE_URL,
|
|
25
|
+
appName: "pydantic-ai-typescript",
|
|
26
|
+
instrumentations: [new PydanticAIInstrumentor()],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
await respan.initialize();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The instrumentor expects spans to already be emitted by a Pydantic AI-compatible
|
|
33
|
+
runtime or OpenInference bridge. It does not invent or monkey-patch unknown SDK
|
|
34
|
+
entrypoints.
|
|
35
|
+
|
|
36
|
+
## Mapped Span Shapes
|
|
37
|
+
|
|
38
|
+
- Native Pydantic AI-style GenAI spans such as `gen_ai.operation.name`,
|
|
39
|
+
`gen_ai.input.messages`, `gen_ai.output.messages`,
|
|
40
|
+
`model_request_parameters`, `gen_ai.tool.definitions`, and tool call attrs.
|
|
41
|
+
- Pydantic AI-scoped OpenInference spans with `openinference.span.kind` and
|
|
42
|
+
indexed `llm.input_messages.*` / `llm.output_messages.*` attrs.
|
|
43
|
+
|
|
44
|
+
The package emits canonical Respan fields including:
|
|
45
|
+
|
|
46
|
+
- `respan.entity.log_type`
|
|
47
|
+
- `traceloop.entity.name`
|
|
48
|
+
- `traceloop.entity.path`
|
|
49
|
+
- `traceloop.entity.input`
|
|
50
|
+
- `traceloop.entity.output`
|
|
51
|
+
- `llm.request.type`
|
|
52
|
+
- `llm.request.functions`
|
|
53
|
+
- `gen_ai.prompt.*`
|
|
54
|
+
- `gen_ai.completion.*`
|
|
55
|
+
- `gen_ai.usage.*`
|
|
56
|
+
|
|
57
|
+
Raw Pydantic AI/OpenInference attrs and off-contract aliases are stripped before
|
|
58
|
+
delegating to the active Respan span processor.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { RespanSpanAttributes } from "@respan/respan-sdk";
|
|
2
|
+
export declare const TRACELOOP_ENTITY_NAME: string;
|
|
3
|
+
export declare const TRACELOOP_ENTITY_PATH: string;
|
|
4
|
+
export declare const TRACELOOP_ENTITY_INPUT: string;
|
|
5
|
+
export declare const TRACELOOP_ENTITY_OUTPUT: string;
|
|
6
|
+
export declare const TRACELOOP_WORKFLOW_NAME: string;
|
|
7
|
+
export declare const TRACELOOP_SPAN_KIND: string;
|
|
8
|
+
export declare const LLM_REQUEST_TYPE: string;
|
|
9
|
+
export declare const LLM_REQUEST_FUNCTIONS: string;
|
|
10
|
+
export declare const LLM_USAGE_TOTAL_TOKENS: string;
|
|
11
|
+
export declare const LLM_USAGE_CACHE_READ_INPUT_TOKENS = "llm.usage.cache_read_input_tokens";
|
|
12
|
+
export declare const GEN_AI_SYSTEM: "gen_ai.system";
|
|
13
|
+
export declare const GEN_AI_REQUEST_MODEL: "gen_ai.request.model";
|
|
14
|
+
export declare const GEN_AI_PROMPT_PREFIX: string;
|
|
15
|
+
export declare const GEN_AI_COMPLETION_PREFIX: string;
|
|
16
|
+
export declare const GEN_AI_USAGE_PROMPT_TOKENS: string;
|
|
17
|
+
export declare const GEN_AI_USAGE_COMPLETION_TOKENS: string;
|
|
18
|
+
export declare const GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens";
|
|
19
|
+
export declare const GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens";
|
|
20
|
+
export declare const GEN_AI_PROVIDER_NAME: "gen_ai.provider.name";
|
|
21
|
+
export declare const RESPAN_LOG_TYPE = RespanSpanAttributes.RESPAN_LOG_TYPE;
|
|
22
|
+
export declare const RESPAN_LOG_METHOD = RespanSpanAttributes.RESPAN_LOG_METHOD;
|
|
23
|
+
export declare const OI_SPAN_KIND: "openinference.span.kind";
|
|
24
|
+
export declare const OI_INPUT_VALUE: "input.value";
|
|
25
|
+
export declare const OI_OUTPUT_VALUE: "output.value";
|
|
26
|
+
export declare const OI_LLM_MODEL_NAME: "llm.model_name";
|
|
27
|
+
export declare const OI_LLM_PROVIDER: "llm.provider";
|
|
28
|
+
export declare const OI_LLM_SYSTEM: "llm.system";
|
|
29
|
+
export declare const OI_LLM_INVOCATION_PARAMETERS: "llm.invocation_parameters";
|
|
30
|
+
export declare const OI_LLM_TOKEN_COUNT_PROMPT: "llm.token_count.prompt";
|
|
31
|
+
export declare const OI_LLM_TOKEN_COUNT_COMPLETION: "llm.token_count.completion";
|
|
32
|
+
export declare const OI_LLM_TOKEN_COUNT_TOTAL: "llm.token_count.total";
|
|
33
|
+
export declare const OI_LLM_TOKEN_COUNT_CACHE_READ: "llm.token_count.prompt_details.cache_read";
|
|
34
|
+
export declare const OI_LLM_TOOLS: "llm.tools";
|
|
35
|
+
export declare const OI_AGENT_NAME: "agent.name";
|
|
36
|
+
export declare const PYDANTIC_AI_REQUEST_PARAMETERS = "model_request_parameters";
|
|
37
|
+
export declare const PYDANTIC_AI_TOOL_DEFINITIONS: "gen_ai.tool.definitions";
|
|
38
|
+
export declare const PYDANTIC_AI_INPUT_MESSAGES: "gen_ai.input.messages";
|
|
39
|
+
export declare const PYDANTIC_AI_OUTPUT_MESSAGES: "gen_ai.output.messages";
|
|
40
|
+
export declare const PYDANTIC_AI_AGENT_NAME: "gen_ai.agent.name";
|
|
41
|
+
export declare const PYDANTIC_AI_TOOL_NAME: "gen_ai.tool.name";
|
|
42
|
+
export declare const PYDANTIC_AI_TOOL_CALL_ID: "gen_ai.tool.call.id";
|
|
43
|
+
export declare const PYDANTIC_AI_TOOL_CALL_ARGUMENTS: "gen_ai.tool.call.arguments";
|
|
44
|
+
export declare const PYDANTIC_AI_TOOL_CALL_RESULT: "gen_ai.tool.call.result";
|
|
45
|
+
export declare const PYDANTIC_AI_OPERATION_NAME: "gen_ai.operation.name";
|
|
46
|
+
export declare const PYDANTIC_AI_RESPONSE_ID: "gen_ai.response.id";
|
|
47
|
+
export declare const PYDANTIC_AI_RESPONSE_FINISH_REASONS: "gen_ai.response.finish_reasons";
|
|
48
|
+
export declare const PYDANTIC_AI_OPENAI_API_BASE = "gen_ai.openai.api_base";
|
|
49
|
+
export declare const PYDANTIC_AI_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens";
|
|
50
|
+
export declare const PYDANTIC_AI_USAGE_DETAILS_INPUT_TOKENS = "gen_ai.usage.details.input_tokens";
|
|
51
|
+
export declare const PYDANTIC_AI_USAGE_DETAILS_OUTPUT_TOKENS = "gen_ai.usage.details.output_tokens";
|
|
52
|
+
export declare const PYDANTIC_AI_OPERATION_COST = "operation.cost";
|
|
53
|
+
export declare const PYDANTIC_AI_LEGACY_AGENT_NAME = "agent_name";
|
|
54
|
+
export declare const PYDANTIC_AI_LEGACY_TOOL_ARGUMENTS = "tool_arguments";
|
|
55
|
+
export declare const PYDANTIC_AI_LEGACY_TOOL_RESULT = "tool_response";
|
|
56
|
+
export declare const PYDANTIC_AI_TOOLS = "tools";
|
|
57
|
+
export declare const PYDANTIC_AI_LOGFIRE_MESSAGE = "logfire.msg";
|
|
58
|
+
export declare const PYDANTIC_AI_MODEL_NAME = "model_name";
|
|
59
|
+
export declare const PYDANTIC_AI_FINAL_RESULT = "final_result";
|
|
60
|
+
export declare const PYDANTIC_AI_ALL_MESSAGES = "pydantic_ai.all_messages";
|
|
61
|
+
export declare const PYDANTIC_AI_RUNNING_TOOLS_SPAN_NAME = "running tools";
|
|
62
|
+
export declare const PYDANTIC_AI_SCOPE_MARKERS: string[];
|
|
63
|
+
export declare const PYDANTIC_AI_RAW_EXACT_ATTRS: Set<string>;
|
|
64
|
+
export declare const OI_RAW_EXACT_ATTRS: Set<string>;
|
|
65
|
+
export declare const OI_RAW_PREFIXES: string[];
|
|
66
|
+
export declare const OTEL_NOISE_EXACT_ATTRS: Set<string>;
|
|
67
|
+
export declare const OTEL_NOISE_PREFIXES: string[];
|
|
68
|
+
export declare const OFF_CONTRACT_ALIAS_ATTRS: Set<string>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { ATTR_GEN_AI_AGENT_NAME, ATTR_GEN_AI_INPUT_MESSAGES, ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_OUTPUT_MESSAGES, ATTR_GEN_AI_PROVIDER_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_FINISH_REASONS, ATTR_GEN_AI_RESPONSE_ID, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ARGUMENTS, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_CALL_RESULT, ATTR_GEN_AI_TOOL_DEFINITIONS, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, } from "@opentelemetry/semantic-conventions/incubating";
|
|
2
|
+
import { AGENT_NAME, INPUT_VALUE, LLM_INVOCATION_PARAMETERS, LLM_MODEL_NAME, LLM_PROVIDER, LLM_SYSTEM, LLM_TOKEN_COUNT_COMPLETION, LLM_TOKEN_COUNT_PROMPT, LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_READ, LLM_TOKEN_COUNT_TOTAL, LLM_TOOLS, OUTPUT_VALUE, SemanticConventions as OpenInferenceSemanticConventions, } from "@arizeai/openinference-semantic-conventions";
|
|
3
|
+
import { RespanSpanAttributes } from "@respan/respan-sdk";
|
|
4
|
+
import { SpanAttributes as TraceloopSpanAttributes } from "@traceloop/ai-semantic-conventions";
|
|
5
|
+
// Traceloop / GenAI semantic convention keys.
|
|
6
|
+
export const TRACELOOP_ENTITY_NAME = TraceloopSpanAttributes.TRACELOOP_ENTITY_NAME;
|
|
7
|
+
export const TRACELOOP_ENTITY_PATH = TraceloopSpanAttributes.TRACELOOP_ENTITY_PATH;
|
|
8
|
+
export const TRACELOOP_ENTITY_INPUT = TraceloopSpanAttributes.TRACELOOP_ENTITY_INPUT;
|
|
9
|
+
export const TRACELOOP_ENTITY_OUTPUT = TraceloopSpanAttributes.TRACELOOP_ENTITY_OUTPUT;
|
|
10
|
+
export const TRACELOOP_WORKFLOW_NAME = TraceloopSpanAttributes.TRACELOOP_WORKFLOW_NAME;
|
|
11
|
+
export const TRACELOOP_SPAN_KIND = TraceloopSpanAttributes.TRACELOOP_SPAN_KIND;
|
|
12
|
+
export const LLM_REQUEST_TYPE = TraceloopSpanAttributes.LLM_REQUEST_TYPE;
|
|
13
|
+
export const LLM_REQUEST_FUNCTIONS = TraceloopSpanAttributes.LLM_REQUEST_FUNCTIONS;
|
|
14
|
+
export const LLM_USAGE_TOTAL_TOKENS = TraceloopSpanAttributes.LLM_USAGE_TOTAL_TOKENS;
|
|
15
|
+
export const LLM_USAGE_CACHE_READ_INPUT_TOKENS = "llm.usage.cache_read_input_tokens";
|
|
16
|
+
export const GEN_AI_SYSTEM = ATTR_GEN_AI_SYSTEM;
|
|
17
|
+
export const GEN_AI_REQUEST_MODEL = ATTR_GEN_AI_REQUEST_MODEL;
|
|
18
|
+
export const GEN_AI_PROMPT_PREFIX = TraceloopSpanAttributes.LLM_PROMPTS;
|
|
19
|
+
export const GEN_AI_COMPLETION_PREFIX = TraceloopSpanAttributes.LLM_COMPLETIONS;
|
|
20
|
+
export const GEN_AI_USAGE_PROMPT_TOKENS = TraceloopSpanAttributes.LLM_USAGE_PROMPT_TOKENS;
|
|
21
|
+
export const GEN_AI_USAGE_COMPLETION_TOKENS = TraceloopSpanAttributes.LLM_USAGE_COMPLETION_TOKENS;
|
|
22
|
+
export const GEN_AI_USAGE_INPUT_TOKENS = ATTR_GEN_AI_USAGE_INPUT_TOKENS;
|
|
23
|
+
export const GEN_AI_USAGE_OUTPUT_TOKENS = ATTR_GEN_AI_USAGE_OUTPUT_TOKENS;
|
|
24
|
+
export const GEN_AI_PROVIDER_NAME = ATTR_GEN_AI_PROVIDER_NAME;
|
|
25
|
+
// Respan-owned keys.
|
|
26
|
+
export const RESPAN_LOG_TYPE = RespanSpanAttributes.RESPAN_LOG_TYPE;
|
|
27
|
+
export const RESPAN_LOG_METHOD = RespanSpanAttributes.RESPAN_LOG_METHOD;
|
|
28
|
+
// OpenInference semantic convention keys.
|
|
29
|
+
export const OI_SPAN_KIND = OpenInferenceSemanticConventions.OPENINFERENCE_SPAN_KIND;
|
|
30
|
+
export const OI_INPUT_VALUE = INPUT_VALUE;
|
|
31
|
+
export const OI_OUTPUT_VALUE = OUTPUT_VALUE;
|
|
32
|
+
export const OI_LLM_MODEL_NAME = LLM_MODEL_NAME;
|
|
33
|
+
export const OI_LLM_PROVIDER = LLM_PROVIDER;
|
|
34
|
+
export const OI_LLM_SYSTEM = LLM_SYSTEM;
|
|
35
|
+
export const OI_LLM_INVOCATION_PARAMETERS = LLM_INVOCATION_PARAMETERS;
|
|
36
|
+
export const OI_LLM_TOKEN_COUNT_PROMPT = LLM_TOKEN_COUNT_PROMPT;
|
|
37
|
+
export const OI_LLM_TOKEN_COUNT_COMPLETION = LLM_TOKEN_COUNT_COMPLETION;
|
|
38
|
+
export const OI_LLM_TOKEN_COUNT_TOTAL = LLM_TOKEN_COUNT_TOTAL;
|
|
39
|
+
export const OI_LLM_TOKEN_COUNT_CACHE_READ = LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_READ;
|
|
40
|
+
export const OI_LLM_TOOLS = LLM_TOOLS;
|
|
41
|
+
export const OI_AGENT_NAME = AGENT_NAME;
|
|
42
|
+
// Pydantic AI native / SDK-specific raw attributes.
|
|
43
|
+
export const PYDANTIC_AI_REQUEST_PARAMETERS = "model_request_parameters";
|
|
44
|
+
export const PYDANTIC_AI_TOOL_DEFINITIONS = ATTR_GEN_AI_TOOL_DEFINITIONS;
|
|
45
|
+
export const PYDANTIC_AI_INPUT_MESSAGES = ATTR_GEN_AI_INPUT_MESSAGES;
|
|
46
|
+
export const PYDANTIC_AI_OUTPUT_MESSAGES = ATTR_GEN_AI_OUTPUT_MESSAGES;
|
|
47
|
+
export const PYDANTIC_AI_AGENT_NAME = ATTR_GEN_AI_AGENT_NAME;
|
|
48
|
+
export const PYDANTIC_AI_TOOL_NAME = ATTR_GEN_AI_TOOL_NAME;
|
|
49
|
+
export const PYDANTIC_AI_TOOL_CALL_ID = ATTR_GEN_AI_TOOL_CALL_ID;
|
|
50
|
+
export const PYDANTIC_AI_TOOL_CALL_ARGUMENTS = ATTR_GEN_AI_TOOL_CALL_ARGUMENTS;
|
|
51
|
+
export const PYDANTIC_AI_TOOL_CALL_RESULT = ATTR_GEN_AI_TOOL_CALL_RESULT;
|
|
52
|
+
export const PYDANTIC_AI_OPERATION_NAME = ATTR_GEN_AI_OPERATION_NAME;
|
|
53
|
+
export const PYDANTIC_AI_RESPONSE_ID = ATTR_GEN_AI_RESPONSE_ID;
|
|
54
|
+
export const PYDANTIC_AI_RESPONSE_FINISH_REASONS = ATTR_GEN_AI_RESPONSE_FINISH_REASONS;
|
|
55
|
+
export const PYDANTIC_AI_OPENAI_API_BASE = "gen_ai.openai.api_base";
|
|
56
|
+
export const PYDANTIC_AI_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens";
|
|
57
|
+
export const PYDANTIC_AI_USAGE_DETAILS_INPUT_TOKENS = "gen_ai.usage.details.input_tokens";
|
|
58
|
+
export const PYDANTIC_AI_USAGE_DETAILS_OUTPUT_TOKENS = "gen_ai.usage.details.output_tokens";
|
|
59
|
+
export const PYDANTIC_AI_OPERATION_COST = "operation.cost";
|
|
60
|
+
export const PYDANTIC_AI_LEGACY_AGENT_NAME = "agent_name";
|
|
61
|
+
export const PYDANTIC_AI_LEGACY_TOOL_ARGUMENTS = "tool_arguments";
|
|
62
|
+
export const PYDANTIC_AI_LEGACY_TOOL_RESULT = "tool_response";
|
|
63
|
+
export const PYDANTIC_AI_TOOLS = "tools";
|
|
64
|
+
export const PYDANTIC_AI_LOGFIRE_MESSAGE = "logfire.msg";
|
|
65
|
+
export const PYDANTIC_AI_MODEL_NAME = "model_name";
|
|
66
|
+
export const PYDANTIC_AI_FINAL_RESULT = "final_result";
|
|
67
|
+
export const PYDANTIC_AI_ALL_MESSAGES = "pydantic_ai.all_messages";
|
|
68
|
+
export const PYDANTIC_AI_RUNNING_TOOLS_SPAN_NAME = "running tools";
|
|
69
|
+
export const PYDANTIC_AI_SCOPE_MARKERS = [
|
|
70
|
+
"pydantic-ai",
|
|
71
|
+
"pydantic_ai",
|
|
72
|
+
"pydantic.ai",
|
|
73
|
+
];
|
|
74
|
+
export const PYDANTIC_AI_RAW_EXACT_ATTRS = new Set([
|
|
75
|
+
PYDANTIC_AI_REQUEST_PARAMETERS,
|
|
76
|
+
PYDANTIC_AI_TOOL_DEFINITIONS,
|
|
77
|
+
PYDANTIC_AI_INPUT_MESSAGES,
|
|
78
|
+
PYDANTIC_AI_OUTPUT_MESSAGES,
|
|
79
|
+
PYDANTIC_AI_AGENT_NAME,
|
|
80
|
+
PYDANTIC_AI_TOOL_NAME,
|
|
81
|
+
PYDANTIC_AI_TOOL_CALL_ID,
|
|
82
|
+
PYDANTIC_AI_TOOL_CALL_ARGUMENTS,
|
|
83
|
+
PYDANTIC_AI_TOOL_CALL_RESULT,
|
|
84
|
+
PYDANTIC_AI_OPERATION_NAME,
|
|
85
|
+
PYDANTIC_AI_RESPONSE_ID,
|
|
86
|
+
PYDANTIC_AI_RESPONSE_FINISH_REASONS,
|
|
87
|
+
PYDANTIC_AI_OPENAI_API_BASE,
|
|
88
|
+
PYDANTIC_AI_USAGE_DETAILS_INPUT_TOKENS,
|
|
89
|
+
PYDANTIC_AI_USAGE_DETAILS_OUTPUT_TOKENS,
|
|
90
|
+
PYDANTIC_AI_OPERATION_COST,
|
|
91
|
+
PYDANTIC_AI_LEGACY_AGENT_NAME,
|
|
92
|
+
PYDANTIC_AI_LEGACY_TOOL_ARGUMENTS,
|
|
93
|
+
PYDANTIC_AI_LEGACY_TOOL_RESULT,
|
|
94
|
+
PYDANTIC_AI_TOOLS,
|
|
95
|
+
PYDANTIC_AI_LOGFIRE_MESSAGE,
|
|
96
|
+
PYDANTIC_AI_MODEL_NAME,
|
|
97
|
+
PYDANTIC_AI_FINAL_RESULT,
|
|
98
|
+
PYDANTIC_AI_ALL_MESSAGES,
|
|
99
|
+
]);
|
|
100
|
+
export const OI_RAW_EXACT_ATTRS = new Set([
|
|
101
|
+
OI_SPAN_KIND,
|
|
102
|
+
OI_INPUT_VALUE,
|
|
103
|
+
"input.mime_type",
|
|
104
|
+
OI_OUTPUT_VALUE,
|
|
105
|
+
"output.mime_type",
|
|
106
|
+
OI_LLM_MODEL_NAME,
|
|
107
|
+
OI_LLM_PROVIDER,
|
|
108
|
+
OI_LLM_SYSTEM,
|
|
109
|
+
OI_LLM_INVOCATION_PARAMETERS,
|
|
110
|
+
OI_LLM_TOKEN_COUNT_PROMPT,
|
|
111
|
+
OI_LLM_TOKEN_COUNT_COMPLETION,
|
|
112
|
+
OI_LLM_TOKEN_COUNT_TOTAL,
|
|
113
|
+
OI_LLM_TOKEN_COUNT_CACHE_READ,
|
|
114
|
+
OI_LLM_TOOLS,
|
|
115
|
+
OI_AGENT_NAME,
|
|
116
|
+
]);
|
|
117
|
+
export const OI_RAW_PREFIXES = [
|
|
118
|
+
"llm.input_messages.",
|
|
119
|
+
"llm.output_messages.",
|
|
120
|
+
"llm.token_count.",
|
|
121
|
+
];
|
|
122
|
+
export const OTEL_NOISE_EXACT_ATTRS = new Set([
|
|
123
|
+
"otel.scope.name",
|
|
124
|
+
"otel.scope.version",
|
|
125
|
+
]);
|
|
126
|
+
export const OTEL_NOISE_PREFIXES = [
|
|
127
|
+
"host.",
|
|
128
|
+
"process.",
|
|
129
|
+
"telemetry.sdk.",
|
|
130
|
+
];
|
|
131
|
+
export const OFF_CONTRACT_ALIAS_ATTRS = new Set([
|
|
132
|
+
"model",
|
|
133
|
+
"prompt_tokens",
|
|
134
|
+
"completion_tokens",
|
|
135
|
+
"total_request_tokens",
|
|
136
|
+
"span_tools",
|
|
137
|
+
"tool_calls",
|
|
138
|
+
"tools",
|
|
139
|
+
"has_tool_calls",
|
|
140
|
+
"parallel_tool_calls",
|
|
141
|
+
RespanSpanAttributes.RESPAN_SPAN_TOOLS,
|
|
142
|
+
RespanSpanAttributes.RESPAN_SPAN_TOOL_CALLS,
|
|
143
|
+
RespanSpanAttributes.RESPAN_SPAN_HANDOFFS,
|
|
144
|
+
]);
|
|
145
|
+
//# sourceMappingURL=_constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_constants.js","sourceRoot":"","sources":["../src/_constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3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ACjB,oBAAoB;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO;IACP,UAAU;IACV,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IAC9C,OAAO;IACP,eAAe;IACf,mBAAmB;IACnB,sBAAsB;IACtB,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB,CAAC,iBAAiB;IACtC,oBAAoB,CAAC,sBAAsB;IAC3C,oBAAoB,CAAC,oBAAoB;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Context } from "@opentelemetry/api";
|
|
2
|
+
import type { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
type SpanAttributesRecord = Record<string, any>;
|
|
4
|
+
export interface PydanticAISpanProcessorOptions {
|
|
5
|
+
includeNativeSpans?: boolean;
|
|
6
|
+
includeOpenInferenceSpans?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class PydanticAISpanProcessor implements SpanProcessor {
|
|
9
|
+
private readonly _options;
|
|
10
|
+
constructor(options?: PydanticAISpanProcessorOptions);
|
|
11
|
+
onStart(_span: Span, _parentContext: Context): void;
|
|
12
|
+
onEnd(span: ReadableSpan): void;
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function enrichPydanticAISpan(span: ReadableSpan, options?: PydanticAISpanProcessorOptions): void;
|
|
17
|
+
export declare function isPydanticAISpan(span: ReadableSpan): boolean;
|
|
18
|
+
export declare function isPydanticAINativeSpan(span: ReadableSpan, attrs: SpanAttributesRecord, scopeName?: string): boolean;
|
|
19
|
+
export declare function isPydanticAIOpenInferenceSpan(span: ReadableSpan, attrs: SpanAttributesRecord, scopeName?: string): boolean;
|
|
20
|
+
export {};
|