Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

feat: Align JS sdk with the Python (#1096)

Aman Agarwal82663bec0232
diff --git a/.cursor/rules/js-sdk-genai-framework-instrumentation.mdc b/.cursor/rules/js-sdk-genai-framework-instrumentation.mdc
new file mode 100644
index 00000000..9d57f814
--- /dev/null
+++ b/.cursor/rules/js-sdk-genai-framework-instrumentation.mdc
@@ -0,0 +1,476 @@
+---
+description: Guide for implementing JS SDK GenAI AI agent framework instrumentations (LangChain, LangGraph, OpenAI Agents, Mastra, Claude Agents SDK, Google ADK, Strands Agents, LlamaIndex). Use when creating or modifying framework instrumentations in sdk/typescript/src/instrumentation/.
+globs: sdk/typescript/src/instrumentation/**/*.ts
+alwaysApply: false
+---
+
+# JS SDK GenAI Framework Instrumentation Guide
+
+This guide defines how every AI agent **framework** instrumentation in the JS SDK must be implemented. This is a companion to the **provider** instrumentation guide (`js-sdk-genai-instrumentation.mdc`). The Python SDK (`sdk/python/`) is the reference. Both SDKs must emit identical telemetry.
+
+## CRITICAL: No Backwards Compatibility
+
+The JS SDK has **zero backwards compatibility constraints**. You MUST:
+- Rewrite existing instrumentations (LangChain, LlamaIndex) from scratch if needed
+- Freely change APIs, span names, attribute keys, file structure, or behavior
+- Remove old code entirely and replace with new implementations
+- The **only alignment targets** are: (1) Python SDK behavior, (2) OTel GenAI semantic conventions
+- Do NOT preserve any legacy JS SDK patterns or behavior
+
+## CRITICAL: Zero Provider/Framework Dependencies
+
+The `openlit` npm package must **never** list provider or framework packages (e.g. `@langchain/core`, `@openai/agents`, `@google/adk`) in `dependencies`. They belong in `devDependencies` only.
+
+- All `index.ts` files must type `moduleExports` as `any` -- no static imports of framework packages.
+- `wrapper.ts` / `processor.ts` must never import framework types. Duck-type everything.
+- OTel's `InstrumentationNodeModuleDefinition` hooks modules by **string name** at runtime. If the user hasn't installed the framework, the instrumentation is a silent no-op.
+
+---
+
+## OTel Spec References
+
+- Agent Spans: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-agent-spans.md
+- GenAI Spans: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-spans.md
+- GenAI Events: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-events.md
+- GenAI Metrics: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md
+
+---
+
+## 1. Agent Span Types (OTel Semantic Conventions)
+
+Framework instrumentations emit these span types per the OTel agent semantic conventions:
+
+### 1a. `create_agent` Span
+- **When**: Agent is constructed/registered (e.g., `new Agent()`, `LlmAgent.__init__`, `Crew.__init__`)
+- **Span name**: `create_agent {gen_ai.agent.name}`
+- **SpanKind**: `CLIENT`
+- **Operation**: `SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT` (`"create_agent"`)
+- **Key attributes**: `gen_ai.agent.name`, `gen_ai.agent.id`, `gen_ai.agent.description`, `gen_ai.request.model`, `gen_ai.tool.definitions`, `gen_ai.system_instructions`
+- **Store span context**: Save `span.spanContext()` in a registry keyed by agent name, for later Links from `invoke_agent` spans
+
+### 1b. `invoke_agent` Span
+- **When**: Agent is invoked/executed (e.g., `Runner.run()`, node execution, agent callback)
+- **Span name**: `invoke_agent {gen_ai.agent.name}`
+- **SpanKind**: `CLIENT` (remote agents) or `INTERNAL` (in-process agents like LangChain, LangGraph nodes)
+- **Operation**: `SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT` (`"invoke_agent"`)
+- **Key attributes**: `gen_ai.agent.name`, `gen_ai.agent.id`, `gen_ai.conversation.id`, `gen_ai.request.model`
+- **Links**: Link back to `create_agent` span context from registry when available
+
+### 1c. `invoke_workflow` Span
+- **When**: Coordinated multi-agent or multi-step workflow (e.g., graph invoke, crew kickoff, trace root)
+- **Span name**: `invoke_workflow {gen_ai.workflow.name}`
+- **SpanKind**: `INTERNAL`
+- **Operation**: `SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK` (`"invoke_workflow"`)
+- **Key attributes**: `gen_ai.workflow.name`, `gen_ai.workflow.type`, `gen_ai.execution.mode`
+
+### 1d. `execute_tool` Span
+- **When**: Tool/function is executed (e.g., LangChain tool run, MCP tool call)
+- **Span name**: `execute_tool {gen_ai.tool.name}`
+- **SpanKind**: `INTERNAL`
+- **Operation**: `SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS` (`"execute_tool"`)
+- **Key attributes**: `gen_ai.tool.name`, `gen_ai.tool.type`, `gen_ai.tool.description`, `gen_ai.tool.call.arguments`, `gen_ai.tool.call.result`
+
+### 1e. `chat` Span (LLM calls within frameworks)
+- **When**: Framework intercepts an LLM call (e.g., LangChain `handleChatModelStart`)
+- **Span name**: `chat {gen_ai.request.model}`
+- **SpanKind**: `CLIENT`
+- **Operation**: `SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT` (`"chat"`)
+- Follows all provider span rules from `js-sdk-genai-instrumentation.mdc`
+- MUST set `frameworkLlmActive` flag to suppress duplicate provider spans
+
+---
+
+## 2. Span Creation Attributes
+
+For agent/workflow spans, these attributes MUST be set at `tracer.startSpan()` time:
+
+```typescript
+{
+ [SemanticConvention.GEN_AI_OPERATION]: operationName, // "invoke_agent", "create_agent", etc.
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: aiSystem, // framework system name
+}
+```
+
+For `create_agent` and `invoke_agent` that have a model, also include:
+```typescript
+{
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel, // if known
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress, // if known
+ [SemanticConvention.SERVER_PORT]: serverPort, // if known
+}
+```
+
+---
+
+## 3. Framework LLM Span Suppression (CRITICAL)
+
+When a framework (e.g., LangChain) calls an underlying provider SDK (e.g., OpenAI), both the framework and provider instrumentations would create duplicate LLM spans. This MUST be prevented.
+
+### Python SDK Pattern (reference)
+```python
+# In __helpers.py
+_framework_llm_span_active: ContextVar[bool] = ContextVar("openlit_framework_llm_span_active", default=False)
+
+def set_framework_llm_active():
+ return _framework_llm_span_active.set(True)
+
+def is_framework_llm_active() -> bool:
+ return _framework_llm_span_active.get()
+
+# In LangChain callback (handleChatModelStart):
+token = set_framework_llm_active() # suppress provider spans
+
+# In LangChain callback (handleLLMEnd/handleLLMError):
+reset_framework_llm_active(token) # re-enable provider spans
+
+# In OpenAI wrapper:
+if is_framework_llm_active():
+ return wrapped(*args, **kwargs) # skip instrumentation
+```
+
+### JS SDK Implementation
+
+In `sdk/typescript/src/helpers.ts`, add:
+```typescript
+const _frameworkLlmActive = new AsyncLocalStorage<boolean>();
+
+export function isFrameworkLlmActive(): boolean {
+ return _frameworkLlmActive.getStore() === true;
+}
+
+export function runWithFrameworkLlm<T>(fn: () => T | Promise<T>): T | Promise<T> {
+ return _frameworkLlmActive.run(true, fn);
+}
+```
+
+### Provider Wrappers MUST Check
+
+Every provider wrapper (OpenAI, Anthropic, Cohere, Groq, Mistral, Google AI, Together, Ollama, Bedrock, Azure AI Inference) MUST add at the top of each patched method:
+```typescript
+if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+```
+
+### When Frameworks Set the Flag
+
+- **LangChain**: Around LLM calls in callback handler (`handleChatModelStart` through `handleLLMEnd`)
+- **Strands**: On `chat` spans in SpanProcessor `on_start` / `on_end`
+- **Any framework creating its own `chat` spans**: MUST set this flag while calling the underlying LLM SDK
+
+---
+
+## 4. Additional Suppression Flags
+
+### LangGraph Wrapper Active
+Prevents LangChain callback from creating duplicate `invoke_workflow` spans when LangGraph is controlling the execution.
+
+```typescript
+const _langGraphActive = new AsyncLocalStorage<boolean>();
+
+export function isLangGraphActive(): boolean {
+ return _langGraphActive.getStore() === true;
+}
+
+export function runWithLangGraph<T>(fn: () => T | Promise<T>): T | Promise<T> {
+ return _langGraphActive.run(true, fn);
+}
+```
+
+LangChain's callback handler checks `isLangGraphActive()` and skips its `invoke_workflow` span if true.
+
+### Create Agent Active
+Prevents duplicate `create_agent` spans when LangGraph `compile()` and LangChain `create_agent()` both fire.
+
+```typescript
+const _createAgentActive = new AsyncLocalStorage<boolean>();
+
+export function isCreateAgentActive(): boolean {
+ return _createAgentActive.getStore() === true;
+}
+```
+
+---
+
+## 5. Framework System Identifiers
+
+Each framework has a system identifier used as `gen_ai.provider.name` on framework-level spans:
+
+| Framework | `gen_ai.provider.name` | Constant Name | npm Package |
+|-----------|----------------------|---------------|-------------|
+| LangChain | `langchain` | `GEN_AI_SYSTEM_LANGCHAIN` | `@langchain/core` |
+| LangGraph | `langgraph` | `GEN_AI_SYSTEM_LANGGRAPH` | `@langchain/langgraph` |
+| OpenAI Agents | `openai` | `GEN_AI_SYSTEM_OPENAI` | `@openai/agents` |
+| Mastra | `mastra` | `GEN_AI_SYSTEM_MASTRA` | `@mastra/core` |
+| Claude Agents SDK | `claude_agent_sdk` | `GEN_AI_SYSTEM_CLAUDE_AGENT_SDK` | `@anthropic-ai/claude-agent-sdk` |
+| Google ADK | `google_adk` | `GEN_AI_SYSTEM_GOOGLE_ADK` | `@google/adk` |
+| Strands Agents | `strands_agents` | `GEN_AI_SYSTEM_STRANDS` | `@strands-agents/sdk` |
+| LlamaIndex | `llama_index` | `GEN_AI_SYSTEM_LLAMAINDEX` | `llamaindex` |
+
+**IMPORTANT**: OpenAI Agents uses `openai` (not `openai_agents`) as `gen_ai.provider.name` on processor spans, matching Python. The `openai_agents` value is used for the framework system identifier in constants but the processor spans use `openai` since it's the underlying provider.
+
+---
+
+## 6. Instrumentation Mechanisms
+
+Frameworks are instrumented using one of three patterns, depending on what the framework exposes:
+
+### 6a. Callback/Handler Injection (LangChain)
+- Inject an OpenLIT callback handler into the framework's callback system
+- Handler receives lifecycle events (chain start/end, LLM start/end, tool start/end)
+- Create OTel spans in response to these events
+- **Python reference**: `sdk/python/src/openlit/instrumentation/langchain/__init__.py` uses `_BaseCallbackManagerInitWrapper`
+
+### 6b. Monkey-Patching (LangGraph, Claude Agents SDK, Google ADK, LlamaIndex)
+- Wrap framework methods using `require-in-the-middle` or `InstrumentationNodeModuleDefinition`
+- Create spans around method calls
+- **Python reference**: Uses `wrapt.wrap_function_wrapper`
+
+### 6c. SpanProcessor / TracingProcessor (Strands, OpenAI Agents, Mastra)
+- For frameworks with built-in OTel or custom tracing, add a processor that enriches/normalizes spans
+- **SpanProcessor** (OTel SDK): Added to TracerProvider for frameworks with native OTel (Strands, Mastra)
+- **TracingProcessor** (Framework-specific): Registered with framework's tracing API (OpenAI Agents)
+- **Python references**:
+ - Strands: `sdk/python/src/openlit/instrumentation/strands/processor.py` -- `StrandsSpanProcessor(SpanProcessor)` added via `provider.add_span_processor()`
+ - OpenAI Agents: `sdk/python/src/openlit/instrumentation/openai_agents/processor.py` -- `OpenLITTracingProcessor(TracingProcessor)` registered via `set_trace_processors()`
+
+### PassthroughTracer Pattern (Google ADK)
+When a framework has its own OTel tracer that creates duplicate top-level spans:
+```typescript
+class PassthroughTracer {
+ startAsCurrentSpan(name, fn) {
+ // Instead of creating a new span, yield the current active span
+ return fn(trace.getActiveSpan());
+ }
+}
+// Replace framework's tracer module attribute
+adkModule.tracer = new PassthroughTracer(adkModule.tracer);
+```
+**Python reference**: `sdk/python/src/openlit/instrumentation/google_adk/utils.py` -- `_PassthroughTracer(wrapt.ObjectProxy)`
+
+---
+
+## 7. Common Framework Span Attributes
+
+All framework spans (agent, workflow, tool) MUST set these attributes:
+
+```typescript
+span.setAttribute('telemetry.sdk.name', 'openlit');
+span.setAttribute('deployment.environment', OpenlitConfig.environment);
+span.setAttribute('service.name', OpenlitConfig.applicationName);
+span.setAttribute('gen_ai.sdk.version', SDK_VERSION);
+span.setAttribute('gen_ai.operation.name', operationName);
+span.setAttribute('gen_ai.provider.name', frameworkSystem);
+```
+
+Plus `applyCustomSpanAttributes(span)` MUST be called on EVERY framework span (not just LLM spans).
+
+---
+
+## 8. Agent Creation Registry
+
+Used to provide span Links from `invoke_agent` back to `create_agent`:
+
+```typescript
+class AgentCreationRegistry {
+ private contexts = new Map<string, SpanContext>();
+
+ register(agentName: string, spanContext: SpanContext): void {
+ this.contexts.set(agentName, spanContext);
+ }
+
+ get(agentName: string): SpanContext | undefined {
+ return this.contexts.get(agentName);
+ }
+}
+```
+
+Python reference: `_AgentCreationRegistry` in `sdk/python/src/openlit/instrumentation/openai_agents/__init__.py`
+
+---
+
+## 9. Events in Framework Instrumentations
+
+### LLM Chat Events
+When a framework handles LLM chat calls (e.g., LangChain `handleLLMEnd`), emit inference events the same way provider instrumentations do:
+
+```typescript
+OpenLitHelper.emitInferenceEvent(span, {
+ [SemanticConvention.GEN_AI_OPERATION]: 'chat',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ // ... all standard inference event attributes
+});
+```
+
+### Non-LLM Spans
+Framework spans (`invoke_agent`, `invoke_workflow`, `execute_tool`) typically do NOT emit inference events (matching Python behavior). Only `chat`-type spans within the framework emit events.
+
+---
+
+## 10. Metrics in Framework Instrumentations
+
+### LLM Chat Metrics
+When a framework handles LLM chat calls, record metrics via `BaseWrapper.recordMetrics()` the same way provider instrumentations do. This includes token usage, duration, cost, TTFT/TBT for streaming.
+
+### Framework Operation Metrics
+For non-LLM framework spans (workflow, agent, tool), record operation duration via the same metrics pattern but with framework-appropriate attributes.
+
+---
+
+## 11. Custom Attributes in Framework Instrumentations
+
+Custom attributes MUST be applied to ALL framework spans (not just LLM spans), matching Python SDK behavior:
+
+- `applyCustomSpanAttributes(span)` MUST be called on every `create_agent`, `invoke_agent`, `invoke_workflow`, `execute_tool`, and `chat` span
+- Events emitted from framework instrumentations MUST include merged custom attributes via `getMergedCustomAttributes()`
+- Metrics are NOT tagged with custom attributes (same as provider instrumentations)
+
+---
+
+## 12. Framework-Specific Handling When Framework Has Native Telemetry
+
+When a framework already has OTel (Strands, Mastra) or custom tracing (OpenAI Agents):
+
+### Skip LLM Span Types (OpenAI Agents)
+The processor MUST skip SDK span types that correspond to LLM calls (e.g., `response`, `generation`), letting the provider instrumentation (OpenAI) handle those:
+```typescript
+const LLM_SPAN_TYPES = new Set(['response', 'generation']);
+if (LLM_SPAN_TYPES.has(spanType)) return; // skip, let provider handle
+```
+
+### Enrich Existing Spans (Strands, Mastra)
+The SpanProcessor enriches framework-created spans with OpenLIT attributes:
+- `on_start`: Set OpenLIT metadata (sdk.name, environment, service.name), apply custom attributes
+- `on_end`: Normalize attributes, extract content from span events, emit inference events, record metrics
+
+### Detect Framework Spans
+For SpanProcessor-based instrumentations, detect relevant spans by:
+- Instrumentation scope name (e.g., `strands.telemetry.tracer`)
+- `gen_ai.system` or `gen_ai.provider.name` attribute value
+- Span name patterns (e.g., starts with `agent.`)
+
+---
+
+## 13. File Structure
+
+Each framework instrumentation follows this structure:
+
+```
+sdk/typescript/src/instrumentation/{framework-name}/
+ index.ts # InstrumentationNodeModuleDefinition, patch/unpatch
+ wrapper.ts # Span creation, attribute setting, event/metric emission
+```
+
+For SpanProcessor-based instrumentations:
+```
+sdk/typescript/src/instrumentation/{framework-name}/
+ index.ts # Registers processor with TracerProvider
+ processor.ts # SpanProcessor or TracingProcessor implementation
+ utils.ts # Span name generation, attribute helpers
+```
+
+---
+
+## 14. Registration
+
+Each new framework instrumentation MUST be registered in:
+
+1. **`sdk/typescript/src/types.ts`**: Add to `InstrumentationType` union
+2. **`sdk/typescript/src/instrumentation/index.ts`**: Import and add to `availableInstrumentations`
+3. **`sdk/typescript/src/semantic-convention.ts`**: Add system constants and any new attribute constants
+
+---
+
+## 15. Semantic Convention Constants to Add
+
+These constants MUST exist in `sdk/typescript/src/semantic-convention.ts` (matching Python `semcov/__init__.py`):
+
+```typescript
+// System identifiers
+static GEN_AI_SYSTEM_LANGGRAPH = 'langgraph';
+static GEN_AI_SYSTEM_OPENAI_AGENTS = 'openai_agents';
+static GEN_AI_SYSTEM_MASTRA = 'mastra';
+static GEN_AI_SYSTEM_CLAUDE_AGENT_SDK = 'claude_agent_sdk';
+static GEN_AI_SYSTEM_GOOGLE_ADK = 'google_adk';
+static GEN_AI_SYSTEM_STRANDS = 'strands_agents';
+
+// Operation types
+static GEN_AI_OPERATION_TYPE_CREATE_AGENT = 'create_agent';
+// GEN_AI_OPERATION_TYPE_AGENT = 'invoke_agent' -- already exists
+// GEN_AI_OPERATION_TYPE_FRAMEWORK = 'invoke_workflow' -- already exists
+// GEN_AI_OPERATION_TYPE_TOOLS = 'execute_tool' -- already exists
+
+// Agent attributes (OTel spec)
+// GEN_AI_AGENT_NAME = 'gen_ai.agent.name' -- already exists
+// GEN_AI_AGENT_ID = 'gen_ai.agent.id' -- already exists
+// GEN_AI_AGENT_DESCRIPTION = 'gen_ai.agent.description' -- already exists
+// GEN_AI_AGENT_VERSION = 'gen_ai.agent.version' -- already exists
+
+// Workflow attributes
+// GEN_AI_WORKFLOW_NAME = 'gen_ai.workflow.name' -- already exists
+
+// Graph attributes
+static GEN_AI_GRAPH_NODES = 'gen_ai.graph.nodes';
+static GEN_AI_GRAPH_NODE_COUNT = 'gen_ai.graph.node_count';
+static GEN_AI_GRAPH_EDGES = 'gen_ai.graph.edges';
+static GEN_AI_GRAPH_EDGE_COUNT = 'gen_ai.graph.edge_count';
+static GEN_AI_GRAPH_EXECUTED_NODES = 'gen_ai.graph.executed_nodes';
+static GEN_AI_GRAPH_STATUS = 'gen_ai.graph.status';
+static GEN_AI_GRAPH_MESSAGE_COUNT = 'gen_ai.graph.message_count';
+static GEN_AI_GRAPH_TOTAL_CHUNKS = 'gen_ai.graph.total_chunks';
+
+// Execution attributes
+static GEN_AI_EXECUTION_MODE = 'gen_ai.execution.mode';
+static GEN_AI_CHECKPOINT_ID = 'gen_ai.checkpoint.id';
+static GEN_AI_CONVERSATION_ID = 'gen_ai.conversation.id';
+```
+
+---
+
+## 16. Frameworks Reference Table
+
+| Framework | JS Package | Python Reference | Mechanism | Built-in Telemetry | Key Pattern |
+|-----------|-----------|-----------------|-----------|-------------------|-------------|
+| LangChain | `@langchain/core` | `sdk/python/src/openlit/instrumentation/langchain/` | Callback injection | LangSmith (not OTel) | Inject handler via `_configureSync` |
+| LangGraph | `@langchain/langgraph` | `sdk/python/src/openlit/instrumentation/langgraph/` | Monkey-patch | LangSmith (not OTel) | Wrap `Pregel.invoke/stream`, `StateGraph.compile/add_node` |
+| OpenAI Agents | `@openai/agents` | `sdk/python/src/openlit/instrumentation/openai_agents/` | TracingProcessor | Custom (not OTel) | Register via `addTraceProcessor()`, skip `response`/`generation` |
+| Mastra | `@mastra/core` | N/A (JS only) | SpanProcessor | Yes (native OTel) | Enrich/normalize Mastra spans |
+| Claude Agents SDK | `@anthropic-ai/claude-agent-sdk` | `sdk/python/src/openlit/instrumentation/claude_agent_sdk/` | Monkey-patch + hooks | No | Wrap `query()`, client methods |
+| Google ADK | `@google/adk` | `sdk/python/src/openlit/instrumentation/google_adk/` | Monkey-patch + PassthroughTracer | Cloud Trace (OTel) | Replace ADK tracers, enrich LLM/tool spans |
+| Strands Agents | `@strands-agents/sdk` | `sdk/python/src/openlit/instrumentation/strands/` | SpanProcessor | Yes (native OTel) | Detect by scope `strands.telemetry.tracer` |
+| LlamaIndex | `llamaindex` | `sdk/python/src/openlit/instrumentation/llamaindex/` | Monkey-patch | Yes (workflow-otel) | Wrap engines, LLM, agent classes |
+
+---
+
+## 17. Implementation Steps for Each Framework
+
+When implementing a framework instrumentation, follow these steps IN ORDER:
+
+1. **Study the framework's JS SDK**: Understand the API surface, how it makes LLM calls, whether it has built-in telemetry
+2. **Study the Python instrumentation**: Read every file in `sdk/python/src/openlit/instrumentation/{framework}/` to understand what spans, attributes, events, and metrics Python emits
+3. **Study how Python handles duplicate spans**: Understand what suppression flags, active checks, or span type skipping is used
+4. **Choose the mechanism**: Callback, monkey-patch, SpanProcessor, or TracingProcessor based on what the framework provides
+5. **Implement**: Create `index.ts`, `wrapper.ts` (or `processor.ts` + `utils.ts`)
+6. **Register**: Add to `types.ts`, `instrumentation/index.ts`, `semantic-convention.ts`
+7. **Verify**: Ensure telemetry matches Python SDK output exactly
+
+---
+
+## 18. Checklist for Framework Instrumentation Alignment
+
+- [ ] `create_agent` spans emitted on agent construction with correct attributes
+- [ ] `invoke_agent` spans emitted on agent invocation with Links to `create_agent`
+- [ ] `invoke_workflow` spans emitted on workflow/graph execution
+- [ ] `execute_tool` spans emitted on tool execution
+- [ ] `chat` spans (if framework handles LLM) follow full provider span rules
+- [ ] Framework LLM suppression: `isFrameworkLlmActive()` set during framework LLM calls
+- [ ] LangGraph suppression: LangChain skips workflow spans when `isLangGraphActive()`
+- [ ] Custom attributes applied on ALL span types via `applyCustomSpanAttributes(span)`
+- [ ] Events emitted on LLM chat paths via `emitInferenceEvent()`
+- [ ] Events include merged custom attributes
+- [ ] Metrics recorded on LLM chat paths via `BaseWrapper.recordMetrics()`
+- [ ] No duplicate spans between framework and provider instrumentations
+- [ ] Span names match Python SDK exactly
+- [ ] Attribute values match Python SDK exactly
+- [ ] System identifier matches Python SDK
+- [ ] Registered in `types.ts`, `index.ts`, `semantic-convention.ts`
+- [ ] No backwards compatibility concerns -- freely rewrite as needed
diff --git a/.cursor/rules/js-sdk-genai-instrumentation.mdc b/.cursor/rules/js-sdk-genai-instrumentation.mdc
new file mode 100644
index 00000000..cb344b80
--- /dev/null
+++ b/.cursor/rules/js-sdk-genai-instrumentation.mdc
@@ -0,0 +1,456 @@
+---
+description: Guide for aligning JS SDK GenAI provider instrumentations with OTel semantic conventions and the Python SDK reference implementation. Use when modifying or creating provider wrappers in sdk/typescript/src/instrumentation/.
+globs: sdk/typescript/src/instrumentation/**/*.ts
+alwaysApply: false
+---
+
+# JS SDK GenAI Instrumentation Guide
+
+This guide defines how every GenAI provider instrumentation in the JS SDK must be implemented. The Python SDK (`sdk/python/`) is the reference. Both SDKs must emit identical telemetry.
+
+## OTel Spec References
+
+- Spans: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-spans.md
+- Events: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-events.md
+- Metrics: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md
+- OpenAI-specific: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/openai.md
+- Anthropic-specific: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/anthropic.md
+- aws-bedrock-specific: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/aws-bedrock.md
+- Azure-specific: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/azure-ai-inference.md
+
+---
+
+## CRITICAL: Zero Provider Dependencies
+
+The `openlit` npm package must **never** list LLM provider or AI framework packages in `dependencies`. Only `@opentelemetry/*` and `js-tiktoken` belong there. Provider packages go in `devDependencies` only (for compilation/tests).
+
+### Why
+`npm install openlit` must not pull in 20+ provider trees. The OTel `InstrumentationNodeModuleDefinition` hooks modules by **string name** at runtime -- no static import needed.
+
+### Rules
+- **No static imports** of provider packages in `index.ts` or `wrapper.ts`. Use `moduleExports: any`.
+- **Duck-type everything**: access `args[0]?.model`, `response.choices`, etc. -- never import provider types.
+- Files under `src/llm/` and `src/evals/llm/` that instantiate provider clients must use **dynamic `import()`** with try/catch and a clear "install it with npm install ..." error message.
+
+```typescript
+// BAD
+import OpenAI from 'openai';
+protected _patch(moduleExports: typeof OpenAI) { ... }
+
+// GOOD
+protected _patch(moduleExports: any) { ... }
+```
+
+---
+
+## 1. Span Structure
+
+### Span Name
+`{gen_ai.operation.name} {gen_ai.request.model}` (e.g. `chat gpt-4o-mini`, `embeddings text-embedding-3-small`).
+
+### Span Kind
+Always `SpanKind.CLIENT`.
+
+### Span Creation Attributes (set at creation time for sampling)
+These 5 attributes MUST be set at `tracer.startSpan()` time via the `attributes` option:
+
+```typescript
+{
+ [SemanticConvention.GEN_AI_OPERATION]: operationName, // "chat", "embeddings", etc.
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: aiSystem, // "openai", "anthropic", etc.
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+}
+```
+
+### Context Propagation
+Wrap the original method call inside `context.with(trace.setSpan(context.active(), span), ...)` so child spans (HTTP, undici) are properly parented.
+
+---
+
+## 2. Span Attributes (complete list, in order)
+
+### 2a. Required (OTel)
+| Attribute | Value | Notes |
+|-----------|-------|-------|
+| `gen_ai.operation.name` | `"chat"`, `"embeddings"`, `"text_completion"` | Set at span creation |
+| `gen_ai.provider.name` | `"openai"`, `"anthropic"`, `"cohere"`, etc. | Set at span creation |
+
+### 2b. Conditionally Required (OTel)
+| Attribute | Condition | Notes |
+|-----------|-----------|-------|
+| `error.type` | Only on error | `e.constructor.name \|\| '_OTHER'` |
+| `gen_ai.request.model` | If available | Set at span creation |
+| `gen_ai.request.seed` | Only if request includes a seed (`seed != null`) | Type: `int`. Do NOT default to 0 |
+| `gen_ai.request.choice.count` | Only if `n != 1` | |
+| `gen_ai.output.type` | If response format is known | `"text"` or `"json"` |
+| `server.address` / `server.port` | If available | Set at span creation |
+
+### 2c. Recommended (OTel)
+| Attribute | Condition | Notes |
+|-----------|-----------|-------|
+| `gen_ai.request.temperature` | Always | Default 1 if not set |
+| `gen_ai.request.top_p` | Always | Default 1 if not set |
+| `gen_ai.request.max_tokens` | Only if explicitly set (`!= null`) | Do NOT use -1 sentinel |
+| `gen_ai.request.frequency_penalty` | Only if non-zero | Do NOT include when 0 |
+| `gen_ai.request.presence_penalty` | Only if non-zero | Do NOT include when 0 |
+| `gen_ai.request.stop_sequences` | Only if set | Array of strings |
+| `gen_ai.request.is_stream` | Always | `true`/`false` |
+| `gen_ai.response.id` | After response | |
+| `gen_ai.response.model` | After response | |
+| `gen_ai.response.finish_reasons` | After response | Array: `["stop"]` |
+| `gen_ai.usage.input_tokens` | After response | |
+| `gen_ai.usage.output_tokens` | After response | |
+
+### 2d. OpenLIT Extension Attributes
+| Attribute | Notes |
+|-----------|-------|
+| `telemetry.sdk.name` | Always `"openlit"` |
+| `deployment.environment` | From `OpenlitConfig.environment` |
+| `service.name` | From `OpenlitConfig.applicationName` |
+| `gen_ai.sdk.version` | Package version |
+| `gen_ai.usage.cost` | Computed from pricing info |
+
+### 2e. Provider-Specific Attributes (example: OpenAI)
+| Attribute | Condition | Notes |
+|-----------|-----------|-------|
+| `openai.api.type` | Always | `"chat_completions"` or `"responses"` |
+| `openai.response.system_fingerprint` | If present | |
+| `openai.response.service_tier` | If present | |
+| `openai.request.service_tier` | Only if set and != `"auto"` | |
+
+### 2f. Opt-In (gated by `captureMessageContent`)
+| Attribute | Notes |
+|-----------|-------|
+| `gen_ai.input.messages` | JSON string, OTel message schema |
+| `gen_ai.output.messages` | JSON string, OTel message schema |
+| `gen_ai.system_instructions` | If system message present |
+
+### Key Rule: No Sentinel Values
+- Do NOT set attributes to sentinel values (`0`, `-1`, `""`, `null`).
+- Only set an attribute when the user explicitly provided the value or the API returned it.
+
+---
+
+## 3. Message Format (OTel Schema)
+
+### Input Messages
+```json
+[
+ {"role": "user", "parts": [{"type": "text", "content": "Hello"}]},
+ {"role": "assistant", "parts": [{"type": "tool_call", "id": "call_abc", "name": "fn", "arguments": {}}]},
+ {"role": "tool", "parts": [{"type": "tool_call_response", "id": "call_abc", "result": "..."}]}
+]
+```
+
+### Output Messages
+```json
+[{"role": "assistant", "parts": [{"type": "text", "content": "Hi"}], "finish_reason": "stop"}]
+```
+
+Use `OpenLitHelper.buildInputMessages()` and `OpenLitHelper.buildOutputMessages()`.
+
+---
+
+## 4. Events
+
+Events are OTel Log Records emitted via `LoggerProvider`, NOT span events.
+
+### Event Name
+`gen_ai.client.inference.operation.details`
+
+### Emission Pattern
+```typescript
+OpenLitHelper.emitInferenceEvent(span, {
+ [SemanticConvention.GEN_AI_OPERATION]: 'chat',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: responseId,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ // Only when captureMessageContent:
+ [SemanticConvention.GEN_AI_INPUT_MESSAGES]: inputMessagesJson,
+ [SemanticConvention.GEN_AI_OUTPUT_MESSAGES]: outputMessagesJson,
+});
+```
+
+### Key Rules
+- Events are emitted INDEPENDENTLY of `captureMessageContent` (the event itself is always emitted; only the message content attributes within it are gated)
+- Context propagation: `emitInferenceEvent` passes `trace.setSpan(otelContext.active(), span)` to correlate the log record with its parent span
+
+---
+
+## 5. Error Handling
+
+### On the Span
+```typescript
+OpenLitHelper.handleException(span, e);
+// This sets: span.recordException(e), span.setStatus(ERROR), span.setAttribute('error.type', ...)
+```
+
+### On Metrics
+```typescript
+BaseWrapper.recordMetrics(span, {
+ ...metricParams,
+ errorType: e?.constructor?.name || '_OTHER',
+});
+```
+
+### Pattern
+```typescript
+.catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: ProviderWrapper.aiSystem,
+ serverAddress: ProviderWrapper.serverAddress,
+ serverPort: ProviderWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+});
+```
+
+---
+
+## 6. Metrics
+
+### Instruments (8 histograms)
+
+| Metric Name | Unit | Buckets | When Recorded |
+|-------------|------|---------|---------------|
+| `gen_ai.client.token.usage` | `{token}` | [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864] | Always (with `gen_ai.token.type`: `input`/`output`) |
+| `gen_ai.client.operation.duration` | `s` | [0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, 20.48, 40.96, 81.92] | Always |
+| `gen_ai.server.time_to_first_token` | `s` | [0.001, 0.005, 0.01, 0.02, 0.04, 0.06, 0.08, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0] | Streaming only, if ttft > 0 |
+| `gen_ai.server.time_per_output_token` | `s` | [0.01, 0.025, 0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 2.5] | Streaming only, if tbt > 0 |
+| `gen_ai.client.operation.time_to_first_chunk` | `s` | Same as operation.duration | Streaming only, if ttft > 0 |
+| `gen_ai.client.operation.time_per_output_chunk` | `s` | Same as operation.duration | Streaming only, if tbt > 0 |
+| `gen_ai.server.request.duration` | `s` | Same as operation.duration | Streaming only, computed from ttft + tbt |
+| `gen_ai.usage.cost` | `USD` | No explicit boundaries | Always (OpenLIT extension) |
+
+### Metric Attributes
+```typescript
+{
+ 'telemetry.sdk.name': 'openlit',
+ 'service.name': applicationName,
+ 'deployment.environment': environment,
+ 'gen_ai.provider.name': aiSystem,
+ 'gen_ai.request.model': model,
+ 'gen_ai.operation.name': operationName, // if available
+ 'gen_ai.response.model': responseModel, // if available
+ 'server.address': serverAddress, // if available
+ 'server.port': serverPort, // if available
+ 'error.type': errorType, // only on error
+ 'gen_ai.token.type': 'input'|'output', // only on token.usage
+}
+```
+
+All metrics go through `BaseWrapper.recordMetrics()`.
+
+---
+
+## 7. Wrapper Code Structure Template
+
+Every provider wrapper MUST follow this structure (see OpenAI wrapper as reference):
+
+```typescript
+class ProviderWrapper {
+ static aiSystem = 'provider_name'; // OTel well-known value
+ static serverAddress = 'api.provider.com';
+ static serverPort = 443;
+
+ static _patchChatCompletionCreate(tracer: Tracer): any {
+ const genAIEndpoint = 'provider.chat_completions';
+ return (originalMethod) => {
+ return async function(...args) {
+ const requestModel = args[0]?.model || 'default-model';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(operationName, requestModel),
+ });
+ return context.with(trace.setSpan(context.active(), span), async () => {
+ return originalMethod.apply(this, args);
+ })
+ .then((response) => {
+ // 1. Set base attributes (via setBaseSpanAttributes)
+ // 2. Set request param attributes (conditionally)
+ // 3. Set response attributes
+ // 4. Set content attributes (gated by captureMessageContent)
+ // 5. Emit inference event (always)
+ // 6. Return metricParams for finally block
+ })
+ .catch((e) => {
+ // handleException + recordMetrics with errorType + span.end() + rethrow
+ });
+ };
+ };
+ }
+}
+```
+
+---
+
+## 8. Custom Span Attributes
+
+Custom attributes can be applied to all auto-instrumented spans and events at two levels, matching the Python SDK exactly. Metrics are **not** tagged with custom attributes (matches Python).
+
+### 8a. Global Custom Attributes (init-time)
+Set via `customSpanAttributes` in `openlit.init()`. Applied to every span and event (not metrics).
+
+```typescript
+openlit.init({
+ customSpanAttributes: { "team": "ml", "project": "chatbot" },
+});
+```
+
+Python equivalent:
+```python
+openlit.init(custom_span_attributes={"team": "ml", "project": "chatbot"})
+```
+
+### 8b. Context-Scoped Custom Attributes (per-call)
+Set via `usingAttributes()` or `injectAdditionalAttributes()`. Applied to spans and events created within the callback scope (not metrics). Context attributes override global attributes on key conflict.
+
+```typescript
+import openlit, { usingAttributes, injectAdditionalAttributes } from 'openlit';
+
+// Option 1: usingAttributes (like Python's context manager)
+await usingAttributes({"user.id": "u1", "experiment": "v2"}, async () => {
+ await client.chat.completions.create(...);
+});
+
+// Option 2: injectAdditionalAttributes (like Python's inject helper)
+const response = await injectAdditionalAttributes(
+ () => client.chat.completions.create(...),
+ {"user.id": "u123", "experiment": "v2"},
+);
+```
+
+Python equivalents:
+```python
+with openlit.using_attributes({"user.id": "u1"}):
+ client.chat.completions.create(...)
+
+response = openlit.inject_additional_attributes(
+ lambda: client.chat.completions.create(...),
+ {"user.id": "u123"},
+)
+```
+
+### Implementation Details
+- `applyCustomSpanAttributes(span)` is called inside `BaseWrapper.setBaseSpanAttributes()` — applies to every instrumented span automatically
+- `getMergedCustomAttributes()` is called inside `emitInferenceEvent()` — applies to every event automatically
+- Global attrs applied first, then context attrs (context overrides global on conflict)
+- Uses Node.js `AsyncLocalStorage` (equivalent of Python's `ContextVar`)
+- Both functions are exported from the main `openlit` module and as named exports
+
+---
+
+## 9. Pricing
+
+- Pricing JSON is fetched ONCE during `init()` and cached in `OpenlitConfig.pricingInfo`
+- Wrappers access it via `OpenlitConfig.pricingInfo || {}`
+- NEVER call `fetchPricingInfo` from within a wrapper
+
+---
+
+## 10. Configuration Parameters (must match Python SDK)
+
+| JS (camelCase) | Python (snake_case) | Default | Notes |
+|----------------|---------------------|---------|-------|
+| `environment` | `environment` | `"default"` | |
+| `applicationName` | `application_name` | `"default"` | |
+| `otlpEndpoint` | `otlp_endpoint` | `undefined` | |
+| `otlpHeaders` | `otlp_headers` | `undefined` | |
+| `disableBatch` | `disable_batch` | `false` | |
+| `captureMessageContent` | `capture_message_content` | `true` | |
+| `disabledInstrumentors` | `disabled_instrumentors` | `undefined` | |
+| `disableMetrics` | `disable_metrics` | `false` | |
+| `disableEvents` | `disable_events` | `false` | |
+| `pricingJson` | `pricing_json` | `undefined` | |
+| `maxContentLength` | `max_content_length` | `null` | |
+| `customSpanAttributes` | `custom_span_attributes` | `null` | |
+
+| JS API | Python API | Description |
+|--------|-----------|-------------|
+| `openlit.usingAttributes(attrs, fn)` | `openlit.using_attributes(attrs)` (context manager) | Context-scoped custom attrs |
+| `openlit.injectAdditionalAttributes(fn, attrs)` | `openlit.inject_additional_attributes(fn, attrs)` | Per-call custom attrs |
+
+---
+
+## 11. OTel Provider Setup (must match Python SDK)
+
+1. Check if an existing SDK provider is already registered globally
+2. If yes, reuse it
+3. If no (only NoopProvider found), create a new one with OpenLIT's resource and exporters
+4. Exporter selection: env var driven (`OTEL_TRACES_EXPORTER`, `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER`). Default: OTLP if endpoint configured, else Console
+5. Each provider (Tracer, Meter, Logger) has a `*_SET` flag to prevent re-initialization
+
+---
+
+## 12. Streaming Pattern
+
+1. Start span before calling the original method
+2. Wrap response in async generator that yields each chunk
+3. Track timestamps per chunk for TTFT/TBT calculation
+4. Merge tool call deltas across chunks
+5. Build aggregate `result` object from chunks
+6. After iteration completes: set attributes, emit event, record metrics
+7. TTFT = `(firstChunkTimestamp - startTime) / 1000` (seconds)
+8. TBT = average of inter-chunk durations (seconds)
+
+---
+
+## 13. Providers That Need Alignment (UPDATE existing)
+
+These JS SDK instrumentations already exist but need updating to match the OpenAI reference wrapper and the Python SDK:
+
+| Provider | JS Wrapper Path | Python Reference Path | OTel Spec |
+|----------|-----------------|----------------------|-----------|
+| Anthropic | `sdk/typescript/src/instrumentation/anthropic/` | `sdk/python/src/openlit/instrumentation/anthropic/` | [anthropic.md](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/anthropic.md) |
+| AWS Bedrock | `sdk/typescript/src/instrumentation/bedrock/` | `sdk/python/src/openlit/instrumentation/bedrock/` | [aws-bedrock.md](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/aws-bedrock.md) |
+| Cohere | `sdk/typescript/src/instrumentation/cohere/` | `sdk/python/src/openlit/instrumentation/cohere/` | Generic GenAI spans/events/metrics |
+| Mistral | `sdk/typescript/src/instrumentation/mistral/` | `sdk/python/src/openlit/instrumentation/mistral/` | Generic GenAI spans/events/metrics |
+| Ollama | `sdk/typescript/src/instrumentation/ollama/` | `sdk/python/src/openlit/instrumentation/ollama/` | Generic GenAI spans/events/metrics |
+| Vercel AI | `sdk/typescript/src/instrumentation/vercel-ai/` | N/A (JS-only) | Generic GenAI spans/events/metrics |
+| Google AI | `sdk/typescript/src/instrumentation/google-ai/` | `sdk/python/src/openlit/instrumentation/google_ai_studio/` | Generic GenAI spans/events/metrics |
+| Groq | `sdk/typescript/src/instrumentation/groq/` | `sdk/python/src/openlit/instrumentation/groq/` | Generic GenAI spans/events/metrics |
+| HuggingFace | `sdk/typescript/src/instrumentation/huggingface/` | N/A | Generic GenAI spans/events/metrics |
+| Together | `sdk/typescript/src/instrumentation/together/` | `sdk/python/src/openlit/instrumentation/together/` | Generic GenAI spans/events/metrics |
+| Replicate | `sdk/typescript/src/instrumentation/replicate/` | N/A | Generic GenAI spans/events/metrics |
+
+## 14. New Provider Instrumentation (CREATE from scratch)
+
+| Provider | JS Wrapper Path (to create) | Python Reference Path | OTel Spec |
+|----------|---------------------------|----------------------|-----------|
+| Azure AI Inference | `sdk/typescript/src/instrumentation/azure-ai-inference/` | `sdk/python/src/openlit/instrumentation/azure_ai_inference/` | [azure-ai-inference.md](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/azure-ai-inference.md) |
+
+---
+
+## 15. Checklist for Provider Alignment
+
+- [ ] Span name: `{operation} {model}`
+- [ ] Span kind: `CLIENT`
+- [ ] 5 attributes at span creation time
+- [ ] No sentinel values (no `0` for seed, no `-1` for max_tokens, no `0` for penalties)
+- [ ] `error.type` on error spans
+- [ ] Events emitted via LoggerProvider with span context correlation
+- [ ] Events emitted independently of `captureMessageContent`
+- [ ] Content attributes gated by `captureMessageContent`
+- [ ] All 8 metric histograms recorded via `BaseWrapper.recordMetrics()`
+- [ ] Metric `error.type` on error path
+- [ ] Pricing from `OpenlitConfig.pricingInfo` (no per-call fetch)
+- [ ] OTel message format for input/output messages
+- [ ] Tool calls captured (name, id, args)
+- [ ] Streaming: TTFT/TBT computed and recorded
+- [ ] Provider-specific attributes documented and implemented
+- [ ] Custom span attributes applied (global + context-scoped via `applyCustomSpanAttributes`)
+- [ ] Tests updated (no `gen_ai.client.token.usage` on span, use `OpenlitConfig.pricingInfo` mock not `updatePricingJson`)
diff --git a/.github/workflows/typescript-tests.yml b/.github/workflows/typescript-tests.yml
index c6b29761..7b1c84bb 100644
--- a/.github/workflows/typescript-tests.yml
+++ b/.github/workflows/typescript-tests.yml
@@ -1,31 +1,47 @@
-name: TypeScript SDK Tests
+name: TypeScript Tests
on:
push:
- branches: ["main"]
+ branches: [ "main" ]
paths:
- 'sdk/typescript/**'
pull_request:
- branches: ["main"]
+ branches: [ "main" ]
paths:
- 'sdk/typescript/**'
+ workflow_dispatch:
+
+permissions:
+ contents: read
jobs:
- test-typescript-sdk:
+ build:
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ node-version: ["20"]
defaults:
run:
working-directory: sdk/typescript
+
steps:
- - name: Checkout repository
- uses: actions/checkout@v6
- - name: Set up Node.js
- uses: actions/setup-node@v6
- with:
- node-version: '20'
- - name: Install dependencies
- run: npm ci
- - name: Build TypeScript
- run: npm run build
- - name: Run tests
- run: npm test
+ - name: Checkout base code
+ uses: actions/checkout@v6
+
+ - name: Set up Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v6
+ with:
+ node-version: ${{ matrix.node-version }}
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Lint
+ run: npm run lint
+
+ - name: Build TypeScript
+ run: npm run build
+
+ - name: Jest
+ run: npm test
diff --git a/.gitignore b/.gitignore
index 3d69b3e1..449fef74 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,5 @@ logs/
.cursorrules
**.pem
**certs/index.txt
-**.csr
\ No newline at end of file
+**.csr
+sdk/typescript-test/
\ No newline at end of file
diff --git a/README.md b/README.md
index 303a4c6f..6a823890 100644
--- a/README.md
+++ b/README.md
@@ -201,14 +201,14 @@ OpenLIT auto-instruments **50+ LLM providers, AI frameworks, and vector database
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/bedrock"><b>AWS Bedrock</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/azure-ai-inference"><b>Azure AI Inference</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/azure-ai-inference"><b>Azure AI Inference</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/vertexai"><b>Vertex AI</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/vllm"><b>vLLM</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/reka"><b>Reka</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/litellm"><b>LiteLLM</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/huggingface"><b>Hugging Face</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/huggingface"><b>Hugging Face</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/ai21"><b>AI21</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
</tr>
<tr>
@@ -219,6 +219,7 @@ OpenLIT auto-instruments **50+ LLM providers, AI frameworks, and vector database
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/multion"><b>MultiOn</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/replicate"><b>Replicate</b></a><br/><img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
</tr>
</table>
@@ -245,18 +246,19 @@ OpenLIT auto-instruments **50+ LLM providers, AI frameworks, and vector database
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/dynamiq"><b>Dynamiq</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/openai-agents"><b>OpenAI Agents</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/openai-agents"><b>OpenAI Agents</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/firecrawl"><b>Firecrawl</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/google-adk"><b>Google ADK</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/google-adk"><b>Google ADK</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
</tr>
<tr>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/langgraph"><b>LangGraph</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/langgraph"><b>LangGraph</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/smolagents"><b>Smolagents</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/strands"><b>Strands Agents</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/claude-agent-sdk"><b>Claude Agent SDK</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/strands"><b>Strands Agents</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/claude-agent-sdk"><b>Claude Agent SDK</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/agent-framework"><b>MS Agent Framework</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/vercel-ai"><b>Vercel AI</b></a><br/><img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
</tr>
</table>
@@ -265,9 +267,9 @@ OpenLIT auto-instruments **50+ LLM providers, AI frameworks, and vector database
<table>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/pinecone"><b>Pinecone</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/chromadb"><b>ChromaDB</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/qdrant"><b>Qdrant</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
-<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/milvus"><b>Milvus</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/chromadb"><b>ChromaDB</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/qdrant"><b>Qdrant</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
+<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/milvus"><b>Milvus</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white&style=flat-square" height="18"></td>
</tr>
<tr>
<td align="center" width="160"><a href="https://docs.openlit.io/latest/sdk/integrations/astradb"><b>Astra DB</b></a><br/><img src="https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white&style=flat-square" height="18"></td>
diff --git a/docs/docs.json b/docs/docs.json
index c7ef8b8f..46a40a65 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -253,7 +253,8 @@
"latest/sdk/integrations/krutrim",
"latest/sdk/integrations/titan-ml",
"latest/sdk/integrations/sarvam",
- "latest/sdk/integrations/premai"
+ "latest/sdk/integrations/premai",
+ "latest/sdk/integrations/replicate"
]
},
{
@@ -291,7 +292,12 @@
"latest/sdk/integrations/firecrawl",
"latest/sdk/integrations/dynamiq",
"latest/sdk/integrations/controlflow",
- "latest/sdk/integrations/swarmzero"
+ "latest/sdk/integrations/swarmzero",
+ "latest/sdk/integrations/langgraph",
+ "latest/sdk/integrations/strands",
+ "latest/sdk/integrations/google-adk",
+ "latest/sdk/integrations/claude-agent-sdk",
+ "latest/sdk/integrations/vercel-ai"
]
},
{
diff --git a/docs/latest/sdk/integrations/azure-ai-inference.mdx b/docs/latest/sdk/integrations/azure-ai-inference.mdx
index 4154b96a..09dd56ae 100644
--- a/docs/latest/sdk/integrations/azure-ai-inference.mdx
+++ b/docs/latest/sdk/integrations/azure-ai-inference.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- azure-ai-inference Python SDK client `>=1.0.0b4`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/bedrock.mdx b/docs/latest/sdk/integrations/bedrock.mdx
index 4b2ab31b..7312ee80 100644
--- a/docs/latest/sdk/integrations/bedrock.mdx
+++ b/docs/latest/sdk/integrations/bedrock.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- Boto3 Python SDK client `>= 1.34.138`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/chromadb.mdx b/docs/latest/sdk/integrations/chromadb.mdx
index a0e1a5c9..c49c15ec 100644
--- a/docs/latest/sdk/integrations/chromadb.mdx
+++ b/docs/latest/sdk/integrations/chromadb.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- ChromaDB Python SDK client `>= 0.4.0`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/claude-agent-sdk.mdx b/docs/latest/sdk/integrations/claude-agent-sdk.mdx
new file mode 100644
index 00000000..372504a3
--- /dev/null
+++ b/docs/latest/sdk/integrations/claude-agent-sdk.mdx
@@ -0,0 +1,58 @@
+---
+title: 'Monitor Claude Agent SDK using OpenTelemetry'
+sidebarTitle: 'Claude Agent SDK'
+---
+
+import IntegrationMethods from '/snippets/integration-methods.mdx';
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI agents built using the Claude Agent SDK (Anthropic). This includes tracking agent runs, tool calls, LLM interactions, and how users interact with the application.
+
+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+
+The integration is compatible with
+- Claude Agent SDK Python client >= 0.0.1
+- OpenLIT Typescript SDK >= 1.0.0
+
+## Get started
+
+<Steps>
+ <Step title="Install OpenLIT">
+ Open your command line or terminal and run:
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
+ </Step>
+ <IntegrationMethods />
+</Steps>
+
+---
+
+<CardGroup cols={3}>
+ <Card title="Quickstart: LLM Observability" href="/latest/sdk/quickstart-ai-observability" icon='bolt'>
+ Production-ready AI monitoring setup in 2 simple steps with zero code changes
+ </Card>
+ <Card title="Configuration" href="/latest/sdk/configuration" icon='bolt'>
+ Configure the OpenLIT SDK according to you requirements.
+ </Card>
+ <Card title="Destinations" href="/latest/sdk/destinations/overview" icon='link'>
+ Send telemetry to Datadog, Grafana, New Relic, and other observability stacks
+ </Card>
+</CardGroup>
+<Card
+ title="Running in Kubernetes? Try the OpenLIT Operator"
+ icon={<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <title>Kubernetes</title>
+ <path fill="#FFA500" d="M10.204 14.35l.007.01-.999 2.413a5.171 5.171 0 0 1-2.075-2.597l2.578-.437.004.005a.44.44 0 0 1 .484.606zm-.833-2.129a.44.44 0 0 0 .173-.756l.002-.011L7.585 9.7a5.143 5.143 0 0 0-.73 3.255l2.514-.725.002-.009zm1.145-1.98a.44.44 0 0 0 .699-.337l.01-.005.15-2.62a5.144 5.144 0 0 0-3.01 1.442l2.147 1.523.004-.002zm.76 2.75l.723.349.722-.347.18-.78-.5-.623h-.804l-.5.623.179.779zm1.5-3.095a.44.44 0 0 0 .7.336l.008.003 2.134-1.513a5.188 5.188 0 0 0-2.992-1.442l.148 2.615.002.001zm10.876 5.97l-5.773 7.181a1.6 1.6 0 0 1-1.248.594l-9.261.003a1.6 1.6 0 0 1-1.247-.596l-5.776-7.18a1.583 1.583 0 0 1-.307-1.34L2.1 5.573c.108-.47.425-.864.863-1.073L11.305.513a1.606 1.606 0 0 1 1.385 0l8.345 3.985c.438.209.755.604.863 1.073l2.062 8.955c.108.47-.005.963-.308 1.34zm-3.289-2.057c-.042-.01-.103-.026-.145-.034-.174-.033-.315-.025-.479-.038-.35-.037-.638-.067-.895-.148-.105-.04-.18-.165-.216-.216l-.201-.059a6.45 6.45 0 0 0-.105-2.332 6.465 6.465 0 0 0-.936-2.163c.052-.047.15-.133.177-.159.008-.09.001-.183.094-.282.197-.185.444-.338.743-.522.142-.084.273-.137.415-.242.032-.024.076-.062.11-.089.24-.191.295-.52.123-.736-.172-.216-.506-.236-.745-.045-.034.027-.08.062-.111.088-.134.116-.217.23-.33.35-.246.25-.45.458-.673.609-.097.056-.239.037-.303.033l-.19.135a6.545 6.545 0 0 0-4.146-2.003l-.012-.223c-.065-.062-.143-.115-.163-.25-.022-.268.015-.557.057-.905.023-.163.061-.298.068-.475.001-.04-.001-.099-.001-.142 0-.306-.224-.555-.5-.555-.275 0-.499.249-.499.555l.001.014c0 .041-.002.092 0 .128.006.177.044.312.067.475.042.348.078.637.056.906a.545.545 0 0 1-.162.258l-.012.211a6.424 6.424 0 0 0-4.166 2.003 8.373 8.373 0 0 1-.18-.128c-.09.012-.18.04-.297-.029-.223-.15-.427-.358-.673-.608-.113-.12-.195-.234-.329-.349-.03-.026-.077-.062-.111-.088a.594.594 0 0 0-.348-.132.481.481 0 0 0-.398.176c-.172.216-.117.546.123.737l.007.005.104.083c.142.105.272.159.414.242.299.185.546.338.743.522.076.082.09.226.1.288l.16.143a6.462 6.462 0 0 0-1.02 4.506l-.208.06c-.055.072-.133.184-.215.217-.257.081-.546.11-.895.147-.164.014-.305.006-.48.039-.037.007-.09.02-.133.03l-.004.002-.007.002c-.295.071-.484.342-.423.608.061.267.349.429.645.365l.007-.001.01-.003.129-.029c.17-.046.294-.113.448-.172.33-.118.604-.217.87-.256.112-.009.23.069.288.101l.217-.037a6.5 6.5 0 0 0 2.88 3.596l-.09.218c.033.084.069.199.044.282-.097.252-.263.517-.452.813-.091.136-.185.242-.268.399-.02.037-.045.095-.064.134-.128.275-.034.591.213.71.248.12.556-.007.69-.282v-.002c.02-.039.046-.09.062-.127.07-.162.094-.301.144-.458.132-.332.205-.68.387-.897.05-.06.13-.082.215-.105l.113-.205a6.453 6.453 0 0 0 4.609.012l.106.192c.086.028.18.042.256.155.136.232.229.507.342.84.05.156.074.295.145.457.016.037.043.09.062.129.133.276.442.402.69.282.247-.118.341-.435.213-.71-.02-.039-.045-.096-.065-.134-.083-.156-.177-.261-.268-.398-.19-.296-.346-.541-.443-.793-.04-.13.007-.21.038-.294-.018-.022-.059-.144-.083-.202a6.499 6.499 0 0 0 2.88-3.622c.064.01.176.03.213.038.075-.05.144-.114.28-.104.266.039.54.138.87.256.154.06.277.128.448.173.036.01.088.019.13.028l.009.003.007.001c.297.064.584-.098.645-.365.06-.266-.128-.537-.423-.608zM16.4 9.701l-1.95 1.746v.005a.44.44 0 0 0 .173.757l.003.01 2.526.728a5.199 5.199 0 0 0-.108-1.674A5.208 5.208 0 0 0 16.4 9.7zm-4.013 5.325a.437.437 0 0 0-.404-.232.44.44 0 0 0-.372.233h-.002l-1.268 2.292a5.164 5.164 0 0 0 3.326.003l-1.27-2.296h-.01zm1.888-1.293a.44.44 0 0 0-.27.036.44.44 0 0 0-.214.572l-.003.004 1.01 2.438a5.15 5.15 0 0 0 2.081-2.615l-2.6-.44-.004.005z"/></svg>}
+ href="/latest/operator/overview"
+ >
+ Automatically inject instrumentation into existing workloads without modifying pod specs, container images, or application code.
+ </Card>
diff --git a/docs/latest/sdk/integrations/google-adk.mdx b/docs/latest/sdk/integrations/google-adk.mdx
new file mode 100644
index 00000000..4e1208af
--- /dev/null
+++ b/docs/latest/sdk/integrations/google-adk.mdx
@@ -0,0 +1,58 @@
+---
+title: 'Monitor Google ADK using OpenTelemetry'
+sidebarTitle: 'Google ADK'
+---
+
+import IntegrationMethods from '/snippets/integration-methods.mdx';
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI agents built using Google Agent Development Kit (ADK). This includes tracking agent execution, tool calls, LLM interactions, and how users interact with the application.
+
+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+
+The integration is compatible with
+- Google ADK Python SDK >= 0.1.0
+- OpenLIT Typescript SDK >= 1.0.0
+
+## Get started
+
+<Steps>
+ <Step title="Install OpenLIT">
+ Open your command line or terminal and run:
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
+ </Step>
+ <IntegrationMethods />
+</Steps>
+
+---
+
+<CardGroup cols={3}>
+ <Card title="Quickstart: LLM Observability" href="/latest/sdk/quickstart-ai-observability" icon='bolt'>
+ Production-ready AI monitoring setup in 2 simple steps with zero code changes
+ </Card>
+ <Card title="Configuration" href="/latest/sdk/configuration" icon='bolt'>
+ Configure the OpenLIT SDK according to you requirements.
+ </Card>
+ <Card title="Destinations" href="/latest/sdk/destinations/overview" icon='link'>
+ Send telemetry to Datadog, Grafana, New Relic, and other observability stacks
+ </Card>
+</CardGroup>
+<Card
+ title="Running in Kubernetes? Try the OpenLIT Operator"
+ icon={<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <title>Kubernetes</title>
+ <path fill="#FFA500" d="M10.204 14.35l.007.01-.999 2.413a5.171 5.171 0 0 1-2.075-2.597l2.578-.437.004.005a.44.44 0 0 1 .484.606zm-.833-2.129a.44.44 0 0 0 .173-.756l.002-.011L7.585 9.7a5.143 5.143 0 0 0-.73 3.255l2.514-.725.002-.009zm1.145-1.98a.44.44 0 0 0 .699-.337l.01-.005.15-2.62a5.144 5.144 0 0 0-3.01 1.442l2.147 1.523.004-.002zm.76 2.75l.723.349.722-.347.18-.78-.5-.623h-.804l-.5.623.179.779zm1.5-3.095a.44.44 0 0 0 .7.336l.008.003 2.134-1.513a5.188 5.188 0 0 0-2.992-1.442l.148 2.615.002.001zm10.876 5.97l-5.773 7.181a1.6 1.6 0 0 1-1.248.594l-9.261.003a1.6 1.6 0 0 1-1.247-.596l-5.776-7.18a1.583 1.583 0 0 1-.307-1.34L2.1 5.573c.108-.47.425-.864.863-1.073L11.305.513a1.606 1.606 0 0 1 1.385 0l8.345 3.985c.438.209.755.604.863 1.073l2.062 8.955c.108.47-.005.963-.308 1.34zm-3.289-2.057c-.042-.01-.103-.026-.145-.034-.174-.033-.315-.025-.479-.038-.35-.037-.638-.067-.895-.148-.105-.04-.18-.165-.216-.216l-.201-.059a6.45 6.45 0 0 0-.105-2.332 6.465 6.465 0 0 0-.936-2.163c.052-.047.15-.133.177-.159.008-.09.001-.183.094-.282.197-.185.444-.338.743-.522.142-.084.273-.137.415-.242.032-.024.076-.062.11-.089.24-.191.295-.52.123-.736-.172-.216-.506-.236-.745-.045-.034.027-.08.062-.111.088-.134.116-.217.23-.33.35-.246.25-.45.458-.673.609-.097.056-.239.037-.303.033l-.19.135a6.545 6.545 0 0 0-4.146-2.003l-.012-.223c-.065-.062-.143-.115-.163-.25-.022-.268.015-.557.057-.905.023-.163.061-.298.068-.475.001-.04-.001-.099-.001-.142 0-.306-.224-.555-.5-.555-.275 0-.499.249-.499.555l.001.014c0 .041-.002.092 0 .128.006.177.044.312.067.475.042.348.078.637.056.906a.545.545 0 0 1-.162.258l-.012.211a6.424 6.424 0 0 0-4.166 2.003 8.373 8.373 0 0 1-.18-.128c-.09.012-.18.04-.297-.029-.223-.15-.427-.358-.673-.608-.113-.12-.195-.234-.329-.349-.03-.026-.077-.062-.111-.088a.594.594 0 0 0-.348-.132.481.481 0 0 0-.398.176c-.172.216-.117.546.123.737l.007.005.104.083c.142.105.272.159.414.242.299.185.546.338.743.522.076.082.09.226.1.288l.16.143a6.462 6.462 0 0 0-1.02 4.506l-.208.06c-.055.072-.133.184-.215.217-.257.081-.546.11-.895.147-.164.014-.305.006-.48.039-.037.007-.09.02-.133.03l-.004.002-.007.002c-.295.071-.484.342-.423.608.061.267.349.429.645.365l.007-.001.01-.003.129-.029c.17-.046.294-.113.448-.172.33-.118.604-.217.87-.256.112-.009.23.069.288.101l.217-.037a6.5 6.5 0 0 0 2.88 3.596l-.09.218c.033.084.069.199.044.282-.097.252-.263.517-.452.813-.091.136-.185.242-.268.399-.02.037-.045.095-.064.134-.128.275-.034.591.213.71.248.12.556-.007.69-.282v-.002c.02-.039.046-.09.062-.127.07-.162.094-.301.144-.458.132-.332.205-.68.387-.897.05-.06.13-.082.215-.105l.113-.205a6.453 6.453 0 0 0 4.609.012l.106.192c.086.028.18.042.256.155.136.232.229.507.342.84.05.156.074.295.145.457.016.037.043.09.062.129.133.276.442.402.69.282.247-.118.341-.435.213-.71-.02-.039-.045-.096-.065-.134-.083-.156-.177-.261-.268-.398-.19-.296-.346-.541-.443-.793-.04-.13.007-.21.038-.294-.018-.022-.059-.144-.083-.202a6.499 6.499 0 0 0 2.88-3.622c.064.01.176.03.213.038.075-.05.144-.114.28-.104.266.039.54.138.87.256.154.06.277.128.448.173.036.01.088.019.13.028l.009.003.007.001c.297.064.584-.098.645-.365.06-.266-.128-.537-.423-.608zM16.4 9.701l-1.95 1.746v.005a.44.44 0 0 0 .173.757l.003.01 2.526.728a5.199 5.199 0 0 0-.108-1.674A5.208 5.208 0 0 0 16.4 9.7zm-4.013 5.325a.437.437 0 0 0-.404-.232.44.44 0 0 0-.372.233h-.002l-1.268 2.292a5.164 5.164 0 0 0 3.326.003l-1.27-2.296h-.01zm1.888-1.293a.44.44 0 0 0-.27.036.44.44 0 0 0-.214.572l-.003.004 1.01 2.438a5.15 5.15 0 0 0 2.081-2.615l-2.6-.44-.004.005z"/></svg>}
+ href="/latest/operator/overview"
+ >
+ Automatically inject instrumentation into existing workloads without modifying pod specs, container images, or application code.
+ </Card>
diff --git a/docs/latest/sdk/integrations/huggingface.mdx b/docs/latest/sdk/integrations/huggingface.mdx
index cf8d173c..9377497c 100644
--- a/docs/latest/sdk/integrations/huggingface.mdx
+++ b/docs/latest/sdk/integrations/huggingface.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- HuggingFace Trasnformers Python SDK client `>= 4.48.0`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/langchain.mdx b/docs/latest/sdk/integrations/langchain.mdx
index e9dedfe9..911dcb4f 100644
--- a/docs/latest/sdk/integrations/langchain.mdx
+++ b/docs/latest/sdk/integrations/langchain.mdx
@@ -21,15 +21,25 @@ Common installation patterns:
- LangChain applications: `pip install langchain`
- LangChain Core only: `pip install langchain-core`
- LangGraph applications: `pip install langgraph`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<Step title="Install LangChain or LangChain Core">
Install the framework package your application uses:
diff --git a/docs/latest/sdk/integrations/langgraph.mdx b/docs/latest/sdk/integrations/langgraph.mdx
new file mode 100644
index 00000000..a59aa1b5
--- /dev/null
+++ b/docs/latest/sdk/integrations/langgraph.mdx
@@ -0,0 +1,58 @@
+---
+title: 'Monitor LangGraph using OpenTelemetry'
+sidebarTitle: 'LangGraph'
+---
+
+import IntegrationMethods from '/snippets/integration-methods.mdx';
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI applications built using LangGraph. This includes tracking agent workflows, tool usage, graph execution, and how users interact with the application.
+
+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+
+The integration is compatible with
+- LangGraph Python SDK client >= 0.2.0
+- OpenLIT Typescript SDK >= 1.0.0
+
+## Get started
+
+<Steps>
+ <Step title="Install OpenLIT">
+ Open your command line or terminal and run:
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
+ </Step>
+ <IntegrationMethods />
+</Steps>
+
+---
+
+<CardGroup cols={3}>
+ <Card title="Quickstart: LLM Observability" href="/latest/sdk/quickstart-ai-observability" icon='bolt'>
+ Production-ready AI monitoring setup in 2 simple steps with zero code changes
+ </Card>
+ <Card title="Configuration" href="/latest/sdk/configuration" icon='bolt'>
+ Configure the OpenLIT SDK according to you requirements.
+ </Card>
+ <Card title="Destinations" href="/latest/sdk/destinations/overview" icon='link'>
+ Send telemetry to Datadog, Grafana, New Relic, and other observability stacks
+ </Card>
+</CardGroup>
+<Card
+ title="Running in Kubernetes? Try the OpenLIT Operator"
+ icon={<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <title>Kubernetes</title>
+ <path fill="#FFA500" d="M10.204 14.35l.007.01-.999 2.413a5.171 5.171 0 0 1-2.075-2.597l2.578-.437.004.005a.44.44 0 0 1 .484.606zm-.833-2.129a.44.44 0 0 0 .173-.756l.002-.011L7.585 9.7a5.143 5.143 0 0 0-.73 3.255l2.514-.725.002-.009zm1.145-1.98a.44.44 0 0 0 .699-.337l.01-.005.15-2.62a5.144 5.144 0 0 0-3.01 1.442l2.147 1.523.004-.002zm.76 2.75l.723.349.722-.347.18-.78-.5-.623h-.804l-.5.623.179.779zm1.5-3.095a.44.44 0 0 0 .7.336l.008.003 2.134-1.513a5.188 5.188 0 0 0-2.992-1.442l.148 2.615.002.001zm10.876 5.97l-5.773 7.181a1.6 1.6 0 0 1-1.248.594l-9.261.003a1.6 1.6 0 0 1-1.247-.596l-5.776-7.18a1.583 1.583 0 0 1-.307-1.34L2.1 5.573c.108-.47.425-.864.863-1.073L11.305.513a1.606 1.606 0 0 1 1.385 0l8.345 3.985c.438.209.755.604.863 1.073l2.062 8.955c.108.47-.005.963-.308 1.34zm-3.289-2.057c-.042-.01-.103-.026-.145-.034-.174-.033-.315-.025-.479-.038-.35-.037-.638-.067-.895-.148-.105-.04-.18-.165-.216-.216l-.201-.059a6.45 6.45 0 0 0-.105-2.332 6.465 6.465 0 0 0-.936-2.163c.052-.047.15-.133.177-.159.008-.09.001-.183.094-.282.197-.185.444-.338.743-.522.142-.084.273-.137.415-.242.032-.024.076-.062.11-.089.24-.191.295-.52.123-.736-.172-.216-.506-.236-.745-.045-.034.027-.08.062-.111.088-.134.116-.217.23-.33.35-.246.25-.45.458-.673.609-.097.056-.239.037-.303.033l-.19.135a6.545 6.545 0 0 0-4.146-2.003l-.012-.223c-.065-.062-.143-.115-.163-.25-.022-.268.015-.557.057-.905.023-.163.061-.298.068-.475.001-.04-.001-.099-.001-.142 0-.306-.224-.555-.5-.555-.275 0-.499.249-.499.555l.001.014c0 .041-.002.092 0 .128.006.177.044.312.067.475.042.348.078.637.056.906a.545.545 0 0 1-.162.258l-.012.211a6.424 6.424 0 0 0-4.166 2.003 8.373 8.373 0 0 1-.18-.128c-.09.012-.18.04-.297-.029-.223-.15-.427-.358-.673-.608-.113-.12-.195-.234-.329-.349-.03-.026-.077-.062-.111-.088a.594.594 0 0 0-.348-.132.481.481 0 0 0-.398.176c-.172.216-.117.546.123.737l.007.005.104.083c.142.105.272.159.414.242.299.185.546.338.743.522.076.082.09.226.1.288l.16.143a6.462 6.462 0 0 0-1.02 4.506l-.208.06c-.055.072-.133.184-.215.217-.257.081-.546.11-.895.147-.164.014-.305.006-.48.039-.037.007-.09.02-.133.03l-.004.002-.007.002c-.295.071-.484.342-.423.608.061.267.349.429.645.365l.007-.001.01-.003.129-.029c.17-.046.294-.113.448-.172.33-.118.604-.217.87-.256.112-.009.23.069.288.101l.217-.037a6.5 6.5 0 0 0 2.88 3.596l-.09.218c.033.084.069.199.044.282-.097.252-.263.517-.452.813-.091.136-.185.242-.268.399-.02.037-.045.095-.064.134-.128.275-.034.591.213.71.248.12.556-.007.69-.282v-.002c.02-.039.046-.09.062-.127.07-.162.094-.301.144-.458.132-.332.205-.68.387-.897.05-.06.13-.082.215-.105l.113-.205a6.453 6.453 0 0 0 4.609.012l.106.192c.086.028.18.042.256.155.136.232.229.507.342.84.05.156.074.295.145.457.016.037.043.09.062.129.133.276.442.402.69.282.247-.118.341-.435.213-.71-.02-.039-.045-.096-.065-.134-.083-.156-.177-.261-.268-.398-.19-.296-.346-.541-.443-.793-.04-.13.007-.21.038-.294-.018-.022-.059-.144-.083-.202a6.499 6.499 0 0 0 2.88-3.622c.064.01.176.03.213.038.075-.05.144-.114.28-.104.266.039.54.138.87.256.154.06.277.128.448.173.036.01.088.019.13.028l.009.003.007.001c.297.064.584-.098.645-.365.06-.266-.128-.537-.423-.608zM16.4 9.701l-1.95 1.746v.005a.44.44 0 0 0 .173.757l.003.01 2.526.728a5.199 5.199 0 0 0-.108-1.674A5.208 5.208 0 0 0 16.4 9.7zm-4.013 5.325a.437.437 0 0 0-.404-.232.44.44 0 0 0-.372.233h-.002l-1.268 2.292a5.164 5.164 0 0 0 3.326.003l-1.27-2.296h-.01zm1.888-1.293a.44.44 0 0 0-.27.036.44.44 0 0 0-.214.572l-.003.004 1.01 2.438a5.15 5.15 0 0 0 2.081-2.615l-2.6-.44-.004.005z"/></svg>}
+ href="/latest/operator/overview"
+ >
+ Automatically inject instrumentation into existing workloads without modifying pod specs, container images, or application code.
+ </Card>
diff --git a/docs/latest/sdk/integrations/llama-index.mdx b/docs/latest/sdk/integrations/llama-index.mdx
index d76e155d..0abcc8a0 100644
--- a/docs/latest/sdk/integrations/llama-index.mdx
+++ b/docs/latest/sdk/integrations/llama-index.mdx
@@ -9,14 +9,26 @@ OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applicat
Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+The integration is compatible with
+- OpenLIT Typescript SDK `>= 1.0.0`
+
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/milvus.mdx b/docs/latest/sdk/integrations/milvus.mdx
index 2f231008..f03ed3cf 100644
--- a/docs/latest/sdk/integrations/milvus.mdx
+++ b/docs/latest/sdk/integrations/milvus.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- Milvus Python SDK client `>= 2.4.3`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/openai-agents.mdx b/docs/latest/sdk/integrations/openai-agents.mdx
index 24979291..251962c4 100644
--- a/docs/latest/sdk/integrations/openai-agents.mdx
+++ b/docs/latest/sdk/integrations/openai-agents.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- OpenAI Agents Python SDK client `>= 0.0.3`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/pinecone.mdx b/docs/latest/sdk/integrations/pinecone.mdx
index 66d92e9f..f1b8251c 100644
--- a/docs/latest/sdk/integrations/pinecone.mdx
+++ b/docs/latest/sdk/integrations/pinecone.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- PineCone Python SDK client `>=2.2.0`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/qdrant.mdx b/docs/latest/sdk/integrations/qdrant.mdx
index 18045b44..f17a908a 100644
--- a/docs/latest/sdk/integrations/qdrant.mdx
+++ b/docs/latest/sdk/integrations/qdrant.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- Qdrant Python SDK client `>= 1.9.0`
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- pip install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/docs/latest/sdk/integrations/strands.mdx b/docs/latest/sdk/integrations/strands.mdx
new file mode 100644
index 00000000..48e28dd1
--- /dev/null
+++ b/docs/latest/sdk/integrations/strands.mdx
@@ -0,0 +1,58 @@
+---
+title: 'Monitor Strands Agents using OpenTelemetry'
+sidebarTitle: 'Strands Agents'
+---
+
+import IntegrationMethods from '/snippets/integration-methods.mdx';
+
+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor AI agents built using Strands Agents SDK. This includes tracking agent invocations, tool calls, chat completions, and how users interact with the application.
+
+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
+
+The integration is compatible with
+- Strands Agents Python SDK >= 0.1.0
+- @strands-agents/sdk Typescript SDK >= 0.1.0
+
+## Get started
+
+<Steps>
+ <Step title="Install OpenLIT">
+ Open your command line or terminal and run:
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
+ </Step>
+ <IntegrationMethods />
+</Steps>
+
+---
+
+<CardGroup cols={3}>
+ <Card title="Quickstart: LLM Observability" href="/latest/sdk/quickstart-ai-observability" icon='bolt'>
+ Production-ready AI monitoring setup in 2 simple steps with zero code changes
+ </Card>
+ <Card title="Configuration" href="/latest/sdk/configuration" icon='bolt'>
+ Configure the OpenLIT SDK according to you requirements.
+ </Card>
+ <Card title="Destinations" href="/latest/sdk/destinations/overview" icon='link'>
+ Send telemetry to Datadog, Grafana, New Relic, and other observability stacks
+ </Card>
+</CardGroup>
+<Card
+ title="Running in Kubernetes? Try the OpenLIT Operator"
+ icon={<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <title>Kubernetes</title>
+ <path fill="#FFA500" d="M10.204 14.35l.007.01-.999 2.413a5.171 5.171 0 0 1-2.075-2.597l2.578-.437.004.005a.44.44 0 0 1 .484.606zm-.833-2.129a.44.44 0 0 0 .173-.756l.002-.011L7.585 9.7a5.143 5.143 0 0 0-.73 3.255l2.514-.725.002-.009zm1.145-1.98a.44.44 0 0 0 .699-.337l.01-.005.15-2.62a5.144 5.144 0 0 0-3.01 1.442l2.147 1.523.004-.002zm.76 2.75l.723.349.722-.347.18-.78-.5-.623h-.804l-.5.623.179.779zm1.5-3.095a.44.44 0 0 0 .7.336l.008.003 2.134-1.513a5.188 5.188 0 0 0-2.992-1.442l.148 2.615.002.001zm10.876 5.97l-5.773 7.181a1.6 1.6 0 0 1-1.248.594l-9.261.003a1.6 1.6 0 0 1-1.247-.596l-5.776-7.18a1.583 1.583 0 0 1-.307-1.34L2.1 5.573c.108-.47.425-.864.863-1.073L11.305.513a1.606 1.606 0 0 1 1.385 0l8.345 3.985c.438.209.755.604.863 1.073l2.062 8.955c.108.47-.005.963-.308 1.34zm-3.289-2.057c-.042-.01-.103-.026-.145-.034-.174-.033-.315-.025-.479-.038-.35-.037-.638-.067-.895-.148-.105-.04-.18-.165-.216-.216l-.201-.059a6.45 6.45 0 0 0-.105-2.332 6.465 6.465 0 0 0-.936-2.163c.052-.047.15-.133.177-.159.008-.09.001-.183.094-.282.197-.185.444-.338.743-.522.142-.084.273-.137.415-.242.032-.024.076-.062.11-.089.24-.191.295-.52.123-.736-.172-.216-.506-.236-.745-.045-.034.027-.08.062-.111.088-.134.116-.217.23-.33.35-.246.25-.45.458-.673.609-.097.056-.239.037-.303.033l-.19.135a6.545 6.545 0 0 0-4.146-2.003l-.012-.223c-.065-.062-.143-.115-.163-.25-.022-.268.015-.557.057-.905.023-.163.061-.298.068-.475.001-.04-.001-.099-.001-.142 0-.306-.224-.555-.5-.555-.275 0-.499.249-.499.555l.001.014c0 .041-.002.092 0 .128.006.177.044.312.067.475.042.348.078.637.056.906a.545.545 0 0 1-.162.258l-.012.211a6.424 6.424 0 0 0-4.166 2.003 8.373 8.373 0 0 1-.18-.128c-.09.012-.18.04-.297-.029-.223-.15-.427-.358-.673-.608-.113-.12-.195-.234-.329-.349-.03-.026-.077-.062-.111-.088a.594.594 0 0 0-.348-.132.481.481 0 0 0-.398.176c-.172.216-.117.546.123.737l.007.005.104.083c.142.105.272.159.414.242.299.185.546.338.743.522.076.082.09.226.1.288l.16.143a6.462 6.462 0 0 0-1.02 4.506l-.208.06c-.055.072-.133.184-.215.217-.257.081-.546.11-.895.147-.164.014-.305.006-.48.039-.037.007-.09.02-.133.03l-.004.002-.007.002c-.295.071-.484.342-.423.608.061.267.349.429.645.365l.007-.001.01-.003.129-.029c.17-.046.294-.113.448-.172.33-.118.604-.217.87-.256.112-.009.23.069.288.101l.217-.037a6.5 6.5 0 0 0 2.88 3.596l-.09.218c.033.084.069.199.044.282-.097.252-.263.517-.452.813-.091.136-.185.242-.268.399-.02.037-.045.095-.064.134-.128.275-.034.591.213.71.248.12.556-.007.69-.282v-.002c.02-.039.046-.09.062-.127.07-.162.094-.301.144-.458.132-.332.205-.68.387-.897.05-.06.13-.082.215-.105l.113-.205a6.453 6.453 0 0 0 4.609.012l.106.192c.086.028.18.042.256.155.136.232.229.507.342.84.05.156.074.295.145.457.016.037.043.09.062.129.133.276.442.402.69.282.247-.118.341-.435.213-.71-.02-.039-.045-.096-.065-.134-.083-.156-.177-.261-.268-.398-.19-.296-.346-.541-.443-.793-.04-.13.007-.21.038-.294-.018-.022-.059-.144-.083-.202a6.499 6.499 0 0 0 2.88-3.622c.064.01.176.03.213.038.075-.05.144-.114.28-.104.266.039.54.138.87.256.154.06.277.128.448.173.036.01.088.019.13.028l.009.003.007.001c.297.064.584-.098.645-.365.06-.266-.128-.537-.423-.608zM16.4 9.701l-1.95 1.746v.005a.44.44 0 0 0 .173.757l.003.01 2.526.728a5.199 5.199 0 0 0-.108-1.674A5.208 5.208 0 0 0 16.4 9.7zm-4.013 5.325a.437.437 0 0 0-.404-.232.44.44 0 0 0-.372.233h-.002l-1.268 2.292a5.164 5.164 0 0 0 3.326.003l-1.27-2.296h-.01zm1.888-1.293a.44.44 0 0 0-.27.036.44.44 0 0 0-.214.572l-.003.004 1.01 2.438a5.15 5.15 0 0 0 2.081-2.615l-2.6-.44-.004.005z"/></svg>}
+ href="/latest/operator/overview"
+ >
+ Automatically inject instrumentation into existing workloads without modifying pod specs, container images, or application code.
+ </Card>
diff --git a/docs/latest/sdk/integrations/vercel-ai.mdx b/docs/latest/sdk/integrations/vercel-ai.mdx
index 5631c909..2c9af712 100644
--- a/docs/latest/sdk/integrations/vercel-ai.mdx
+++ b/docs/latest/sdk/integrations/vercel-ai.mdx
@@ -11,15 +11,25 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff
The integration is compatible with
- Vercel AI SDK (`ai` package)
+- OpenLIT Typescript SDK `>= 1.0.0`
## Get started
<Steps>
<Step title="Install OpenLIT">
Open your command line or terminal and run:
- ```shell
- npm install openlit
- ```
+ <Tabs>
+ <Tab title="Python">
+ ```shell
+ pip install openlit
+ ```
+ </Tab>
+ <Tab title="Typescript">
+ ```shell
+ npm install openlit
+ ```
+ </Tab>
+ </Tabs>
</Step>
<IntegrationMethods />
</Steps>
diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.py
index aaa7496e..1bab9fd0 100644
--- a/sdk/python/src/openlit/semcov/__init__.py
+++ b/sdk/python/src/openlit/semcov/__init__.py
@@ -296,8 +296,8 @@ class SemanticConvention:
# GenAI System Names (OTel Semconv)
GEN_AI_SYSTEM_ANTHROPIC = "anthropic"
GEN_AI_SYSTEM_AWS_BEDROCK = "aws.bedrock"
- GEN_AI_SYSTEM_AZURE_AI_INFERENCE = "az.ai.inference"
- GEN_AI_SYSTEM_AZURE_OPENAI = "az.ai.openai"
+ GEN_AI_SYSTEM_AZURE_AI_INFERENCE = "azure.ai.inference"
+ GEN_AI_SYSTEM_AZURE_OPENAI = "azure.ai.openai"
GEN_AI_SYSTEM_COHERE = "cohere"
GEN_AI_SYSTEM_DEEPSEEK = "deepseek"
GEN_AI_SYSTEM_GEMINI = "gemini"
@@ -331,7 +331,7 @@ class SemanticConvention:
GEN_AI_SYSTEM_GPT4ALL = "gpt4all"
GEN_AI_SYSTEM_ELEVENLABS = "elevenlabs"
GEN_AI_SYSTEM_VLLM = "vLLM"
- GEN_AI_SYSTEM_GOOGLE_AI_STUDIO = "google.ai.studio"
+ GEN_AI_SYSTEM_GOOGLE_AI_STUDIO = "gcp.gemini"
GEN_AI_SYSTEM_REKAAI = "rekaai"
GEN_AI_SYSTEM_PREMAI = "premai"
GEN_AI_SYSTEM_LANGCHAIN = "langchain"
diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md
index 0f6d5d22..d074106d 100644
--- a/sdk/typescript/README.md
+++ b/sdk/typescript/README.md
@@ -202,7 +202,7 @@ Below is a detailed overview of the configuration options available, allowing yo
| `traceContent` | Enables tracing of content for deeper insights. | `true` | No |
| `disabledInstrumentations` | List of instrumentations to disable. | `undefined` | No |
| `instrumentations` | Object of instrumentation modules for manual patching | `undefined` | No |
-| `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
+| `pricingJson` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
### OpenLIT Prompt Hub - `Openlit.getPrompt()`
diff --git a/sdk/typescript/eslint.config.mjs b/sdk/typescript/eslint.config.mjs
index 67c6a340..1932708f 100644
--- a/sdk/typescript/eslint.config.mjs
+++ b/sdk/typescript/eslint.config.mjs
@@ -4,7 +4,18 @@ import tseslint from "typescript-eslint";
export default [
- {languageOptions: { globals: globals.browser }},
+ {languageOptions: { globals: {...globals.browser, ...globals.node} }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
+ {
+ rules: {
+ "@typescript-eslint/no-explicit-any": "off",
+ "@typescript-eslint/no-var-requires": "off",
+ "@typescript-eslint/no-require-imports": "off",
+ "@typescript-eslint/no-unused-vars": ["error", {
+ argsIgnorePattern: "^_",
+ varsIgnorePattern: "^_",
+ }],
+ },
+ },
];
\ No newline at end of file
diff --git a/sdk/typescript/package-lock.json b/sdk/typescript/package-lock.json
index fe08f6c5..72589fd2 100644
--- a/sdk/typescript/package-lock.json
+++ b/sdk/typescript/package-lock.json
@@ -1,28 +1,27 @@
{
"name": "openlit",
- "version": "1.11.0",
+ "version": "1.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openlit",
- "version": "1.11.0",
+ "version": "1.12.0",
"license": "ISC",
"dependencies": {
- "@anthropic-ai/sdk": "^0.25.0",
"@opentelemetry/api": "^1.9.0",
- "@opentelemetry/auto-instrumentations-node": "^0.62.0",
- "@opentelemetry/exporter-jaeger": "^2.0.1",
+ "@opentelemetry/api-logs": "^0.214.0",
+ "@opentelemetry/exporter-logs-otlp-http": "^0.214.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.203.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
"@opentelemetry/instrumentation": "^0.203.0",
"@opentelemetry/resources": "^2.0.1",
- "@opentelemetry/sdk-trace-base": "^2.0.1",
+ "@opentelemetry/sdk-logs": "^0.214.0",
+ "@opentelemetry/sdk-metrics": "^2.6.1",
+ "@opentelemetry/sdk-trace-base": "^2.6.1",
"@opentelemetry/sdk-trace-node": "^2.0.1",
"@opentelemetry/semantic-conventions": "^1.36.0",
- "cohere-ai": "^7.13.0",
- "js-tiktoken": "^1.0.12",
- "openai": "^4.47.1",
- "tiktoken": "^1.0.15"
+ "js-tiktoken": "^1.0.12"
},
"devDependencies": {
"@eslint/js": "^9.2.0",
@@ -37,4113 +36,1692 @@
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"typescript-eslint": "^7.8.0"
- }
- },
- "../../../opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-openai": {
- "name": "@opentelemetry/instrumentation-openai",
- "version": "0.1.0",
- "extraneous": true,
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.52.0",
- "openai": "^4.47.1"
- },
- "devDependencies": {
- "@opentelemetry/api": "^1.3.0",
- "@types/node": "18.6.5",
- "typescript": "^5.5.4"
- },
- "engines": {
- "node": ">=14"
},
"peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
+ "@opentelemetry/instrumentation-express": ">=0.40.0",
+ "@opentelemetry/instrumentation-fastify": ">=0.38.0",
+ "@opentelemetry/instrumentation-hapi": ">=0.40.0",
+ "@opentelemetry/instrumentation-http": ">=0.50.0",
+ "@opentelemetry/instrumentation-koa": ">=0.42.0",
+ "@opentelemetry/instrumentation-nestjs-core": ">=0.39.0",
+ "@opentelemetry/instrumentation-undici": ">=0.1.0"
+ },
+ "peerDependenciesMeta": {
+ "@opentelemetry/instrumentation-express": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-fastify": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-hapi": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-http": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-koa": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-nestjs-core": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-undici": {
+ "optional": true
+ }
}
},
- "node_modules/@ampproject/remapping": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
- "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
+ "node_modules/@babel/code-frame": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz",
+ "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==",
"dev": true,
- "license": "Apache-2.0",
+ "license": "MIT",
"dependencies": {
- "@jridgewell/gen-mapping": "^0.3.5",
- "@jridgewell/trace-mapping": "^0.3.24"
+ "@babel/helper-validator-identifier": "^7.28.5",
+ "js-tokens": "^4.0.0",
+ "picocolors": "^1.1.1"
},
"engines": {
- "node": ">=6.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@anthropic-ai/sdk": {
- "version": "0.25.0",
+ "node_modules/@babel/compat-data": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz",
+ "integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==",
+ "dev": true,
"license": "MIT",
- "dependencies": {
- "@types/node": "^18.11.18",
- "@types/node-fetch": "^2.6.4",
- "abort-controller": "^3.0.0",
- "agentkeepalive": "^4.2.1",
- "form-data-encoder": "1.7.2",
- "formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7"
- }
- },
- "node_modules/@aws-crypto/crc32": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/crc32/-/crc32-3.0.0.tgz",
- "integrity": "sha512-IzSgsrxUcsrejQbPVilIKy16kAT52EwB6zSaI+M3xxIhKh5+aldEyvI+z6erM7TCLB2BJsFrtHjp6/4/sr+3dA==",
- "dependencies": {
- "@aws-crypto/util": "^3.0.0",
- "@aws-sdk/types": "^3.222.0",
- "tslib": "^1.11.1"
- }
- },
- "node_modules/@aws-crypto/crc32/node_modules/@aws-crypto/util": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-3.0.0.tgz",
- "integrity": "sha512-2OJlpeJpCR48CC8r+uKVChzs9Iungj9wkZrl8Z041DWEWvyIHILYKCPNzJghKsivj+S3mLo6BVc7mBNzdxA46w==",
- "dependencies": {
- "@aws-sdk/types": "^3.222.0",
- "@aws-sdk/util-utf8-browser": "^3.0.0",
- "tslib": "^1.11.1"
- }
- },
- "node_modules/@aws-crypto/crc32/node_modules/tslib": {
- "version": "1.14.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
- "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
- },
- "node_modules/@aws-crypto/sha256-browser": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz",
- "integrity": "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw==",
- "dependencies": {
- "@aws-crypto/sha256-js": "^5.2.0",
- "@aws-crypto/supports-web-crypto": "^5.2.0",
- "@aws-crypto/util": "^5.2.0",
- "@aws-sdk/types": "^3.222.0",
- "@aws-sdk/util-locate-window": "^3.0.0",
- "@smithy/util-utf8": "^2.0.0",
- "tslib": "^2.6.2"
- }
- },
- "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/is-array-buffer": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz",
- "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==",
- "dependencies": {
- "tslib": "^2.6.2"
- },
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/util-buffer-from": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz",
- "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==",
- "dependencies": {
- "@smithy/is-array-buffer": "^2.2.0",
- "tslib": "^2.6.2"
+ "node_modules/@babel/core": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
+ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/code-frame": "^7.29.0",
+ "@babel/generator": "^7.29.0",
+ "@babel/helper-compilation-targets": "^7.28.6",
+ "@babel/helper-module-transforms": "^7.28.6",
+ "@babel/helpers": "^7.28.6",
+ "@babel/parser": "^7.29.0",
+ "@babel/template": "^7.28.6",
+ "@babel/traverse": "^7.29.0",
+ "@babel/types": "^7.29.0",
+ "@jridgewell/remapping": "^2.3.5",
+ "convert-source-map": "^2.0.0",
+ "debug": "^4.1.0",
+ "gensync": "^1.0.0-beta.2",
+ "json5": "^2.2.3",
+ "semver": "^6.3.1"
},
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/babel"
}
},
- "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/util-utf8": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz",
- "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==",
+ "node_modules/@babel/generator": {
+ "version": "7.29.1",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.1.tgz",
+ "integrity": "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/util-buffer-from": "^2.2.0",
- "tslib": "^2.6.2"
+ "@babel/parser": "^7.29.0",
+ "@babel/types": "^7.29.0",
+ "@jridgewell/gen-mapping": "^0.3.12",
+ "@jridgewell/trace-mapping": "^0.3.28",
+ "jsesc": "^3.0.2"
},
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-crypto/sha256-js": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz",
- "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==",
+ "node_modules/@babel/helper-compilation-targets": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz",
+ "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-crypto/util": "^5.2.0",
- "@aws-sdk/types": "^3.222.0",
- "tslib": "^2.6.2"
+ "@babel/compat-data": "^7.28.6",
+ "@babel/helper-validator-option": "^7.27.1",
+ "browserslist": "^4.24.0",
+ "lru-cache": "^5.1.1",
+ "semver": "^6.3.1"
},
"engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-crypto/supports-web-crypto": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz",
- "integrity": "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg==",
- "dependencies": {
- "tslib": "^2.6.2"
- }
- },
- "node_modules/@aws-crypto/util": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz",
- "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==",
- "dependencies": {
- "@aws-sdk/types": "^3.222.0",
- "@smithy/util-utf8": "^2.0.0",
- "tslib": "^2.6.2"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-crypto/util/node_modules/@smithy/is-array-buffer": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz",
- "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==",
- "dependencies": {
- "tslib": "^2.6.2"
- },
+ "node_modules/@babel/helper-globals": {
+ "version": "7.28.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz",
+ "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-crypto/util/node_modules/@smithy/util-buffer-from": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz",
- "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==",
+ "node_modules/@babel/helper-module-imports": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz",
+ "integrity": "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/is-array-buffer": "^2.2.0",
- "tslib": "^2.6.2"
+ "@babel/traverse": "^7.28.6",
+ "@babel/types": "^7.28.6"
},
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz",
- "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==",
- "dependencies": {
- "@smithy/util-buffer-from": "^2.2.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@aws-sdk/client-cognito-identity": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.658.1.tgz",
- "integrity": "sha512-MCYLKmNy0FlNT9TvXfOxj0jh+ZQq+G9qEy/VZqu3JsQSgiFvFRdzgzcbQ9gQx7fZrDC/TPdABOTh483zI4cu9g==",
- "dependencies": {
- "@aws-crypto/sha256-browser": "5.2.0",
- "@aws-crypto/sha256-js": "5.2.0",
- "@aws-sdk/client-sso-oidc": "3.658.1",
- "@aws-sdk/client-sts": "3.658.1",
- "@aws-sdk/core": "3.658.1",
- "@aws-sdk/credential-provider-node": "3.658.1",
- "@aws-sdk/middleware-host-header": "3.654.0",
- "@aws-sdk/middleware-logger": "3.654.0",
- "@aws-sdk/middleware-recursion-detection": "3.654.0",
- "@aws-sdk/middleware-user-agent": "3.654.0",
- "@aws-sdk/region-config-resolver": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@aws-sdk/util-user-agent-browser": "3.654.0",
- "@aws-sdk/util-user-agent-node": "3.654.0",
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/core": "^2.4.6",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/hash-node": "^3.0.6",
- "@smithy/invalid-dependency": "^3.0.6",
- "@smithy/middleware-content-length": "^3.0.8",
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-body-length-node": "^3.0.0",
- "@smithy/util-defaults-mode-browser": "^3.0.21",
- "@smithy/util-defaults-mode-node": "^3.0.21",
- "@smithy/util-endpoints": "^2.1.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/client-sagemaker": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/client-sagemaker/-/client-sagemaker-3.658.1.tgz",
- "integrity": "sha512-WpVs1pCWkvSAC3k7bVGSQxj1wV5Mcd+xwi9XPFbeoSkSRw2lftCiNo2laiVCQU6T9WOIK0X3FpVFK1ipag0QVw==",
- "dependencies": {
- "@aws-crypto/sha256-browser": "5.2.0",
- "@aws-crypto/sha256-js": "5.2.0",
- "@aws-sdk/client-sso-oidc": "3.658.1",
- "@aws-sdk/client-sts": "3.658.1",
- "@aws-sdk/core": "3.658.1",
- "@aws-sdk/credential-provider-node": "3.658.1",
- "@aws-sdk/middleware-host-header": "3.654.0",
- "@aws-sdk/middleware-logger": "3.654.0",
- "@aws-sdk/middleware-recursion-detection": "3.654.0",
- "@aws-sdk/middleware-user-agent": "3.654.0",
- "@aws-sdk/region-config-resolver": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@aws-sdk/util-user-agent-browser": "3.654.0",
- "@aws-sdk/util-user-agent-node": "3.654.0",
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/core": "^2.4.6",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/hash-node": "^3.0.6",
- "@smithy/invalid-dependency": "^3.0.6",
- "@smithy/middleware-content-length": "^3.0.8",
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-body-length-node": "^3.0.0",
- "@smithy/util-defaults-mode-browser": "^3.0.21",
- "@smithy/util-defaults-mode-node": "^3.0.21",
- "@smithy/util-endpoints": "^2.1.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "@smithy/util-waiter": "^3.1.5",
- "tslib": "^2.6.2",
- "uuid": "^9.0.1"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/client-sso": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.658.1.tgz",
- "integrity": "sha512-lOuaBtqPTYGn6xpXlQF4LsNDsQ8Ij2kOdnk+i69Kp6yS76TYvtUuukyLL5kx8zE1c8WbYtxj9y8VNw9/6uKl7Q==",
- "dependencies": {
- "@aws-crypto/sha256-browser": "5.2.0",
- "@aws-crypto/sha256-js": "5.2.0",
- "@aws-sdk/core": "3.658.1",
- "@aws-sdk/middleware-host-header": "3.654.0",
- "@aws-sdk/middleware-logger": "3.654.0",
- "@aws-sdk/middleware-recursion-detection": "3.654.0",
- "@aws-sdk/middleware-user-agent": "3.654.0",
- "@aws-sdk/region-config-resolver": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@aws-sdk/util-user-agent-browser": "3.654.0",
- "@aws-sdk/util-user-agent-node": "3.654.0",
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/core": "^2.4.6",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/hash-node": "^3.0.6",
- "@smithy/invalid-dependency": "^3.0.6",
- "@smithy/middleware-content-length": "^3.0.8",
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-body-length-node": "^3.0.0",
- "@smithy/util-defaults-mode-browser": "^3.0.21",
- "@smithy/util-defaults-mode-node": "^3.0.21",
- "@smithy/util-endpoints": "^2.1.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/client-sso-oidc": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.658.1.tgz",
- "integrity": "sha512-RGcZAI3qEA05JszPKwa0cAyp8rnS1nUvs0Sqw4hqLNQ1kD7b7V6CPjRXe7EFQqCOMvM4kGqx0+cEEVTOmBsFLw==",
- "dependencies": {
- "@aws-crypto/sha256-browser": "5.2.0",
- "@aws-crypto/sha256-js": "5.2.0",
- "@aws-sdk/core": "3.658.1",
- "@aws-sdk/credential-provider-node": "3.658.1",
- "@aws-sdk/middleware-host-header": "3.654.0",
- "@aws-sdk/middleware-logger": "3.654.0",
- "@aws-sdk/middleware-recursion-detection": "3.654.0",
- "@aws-sdk/middleware-user-agent": "3.654.0",
- "@aws-sdk/region-config-resolver": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@aws-sdk/util-user-agent-browser": "3.654.0",
- "@aws-sdk/util-user-agent-node": "3.654.0",
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/core": "^2.4.6",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/hash-node": "^3.0.6",
- "@smithy/invalid-dependency": "^3.0.6",
- "@smithy/middleware-content-length": "^3.0.8",
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-body-length-node": "^3.0.0",
- "@smithy/util-defaults-mode-browser": "^3.0.21",
- "@smithy/util-defaults-mode-node": "^3.0.21",
- "@smithy/util-endpoints": "^2.1.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- },
- "peerDependencies": {
- "@aws-sdk/client-sts": "^3.658.1"
- }
- },
- "node_modules/@aws-sdk/client-sts": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.658.1.tgz",
- "integrity": "sha512-yw9hc5blTnbT1V6mR7Cx9HGc9KQpcLQ1QXj8rntiJi6tIYu3aFNVEyy81JHL7NsuBSeQulJTvHO3y6r3O0sfRg==",
- "dependencies": {
- "@aws-crypto/sha256-browser": "5.2.0",
- "@aws-crypto/sha256-js": "5.2.0",
- "@aws-sdk/client-sso-oidc": "3.658.1",
- "@aws-sdk/core": "3.658.1",
- "@aws-sdk/credential-provider-node": "3.658.1",
- "@aws-sdk/middleware-host-header": "3.654.0",
- "@aws-sdk/middleware-logger": "3.654.0",
- "@aws-sdk/middleware-recursion-detection": "3.654.0",
- "@aws-sdk/middleware-user-agent": "3.654.0",
- "@aws-sdk/region-config-resolver": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@aws-sdk/util-user-agent-browser": "3.654.0",
- "@aws-sdk/util-user-agent-node": "3.654.0",
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/core": "^2.4.6",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/hash-node": "^3.0.6",
- "@smithy/invalid-dependency": "^3.0.6",
- "@smithy/middleware-content-length": "^3.0.8",
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-body-length-node": "^3.0.0",
- "@smithy/util-defaults-mode-browser": "^3.0.21",
- "@smithy/util-defaults-mode-node": "^3.0.21",
- "@smithy/util-endpoints": "^2.1.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/core": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.658.1.tgz",
- "integrity": "sha512-vJVMoMcSKXK2gBRSu9Ywwv6wQ7tXH8VL1fqB1uVxgCqBZ3IHfqNn4zvpMPWrwgO2/3wv7XFyikGQ5ypPTCw4jA==",
- "dependencies": {
- "@smithy/core": "^2.4.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/signature-v4": "^4.1.4",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/util-middleware": "^3.0.6",
- "fast-xml-parser": "4.4.1",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/credential-provider-cognito-identity": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.658.1.tgz",
- "integrity": "sha512-JY4rZ4e2emL7PNHCU7F/BQV8PpQGEBZLkEoPD55RO4CitaIhlVZRpUCGLih+0Hw4MOnTUqJdfQBM+qZk6G+Now==",
- "dependencies": {
- "@aws-sdk/client-cognito-identity": "3.658.1",
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/credential-provider-env": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.654.0.tgz",
- "integrity": "sha512-kogsx3Ql81JouHS7DkheCDU9MYAvK0AokxjcshDveGmf7BbgbWCA8Fnb9wjQyNDaOXNvkZu8Z8rgkX91z324/w==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/credential-provider-http": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.658.1.tgz",
- "integrity": "sha512-4ubkJjEVCZflxkZnV1JDQv8P2pburxk1LrEp55telfJRzXrnowzBKwuV2ED0QMNC448g2B3VCaffS+Ct7c4IWQ==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/util-stream": "^3.1.8",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/credential-provider-ini": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.658.1.tgz",
- "integrity": "sha512-2uwOamQg5ppwfegwen1ddPu5HM3/IBSnaGlaKLFhltkdtZ0jiqTZWUtX2V+4Q+buLnT0hQvLS/frQ+7QUam+0Q==",
- "dependencies": {
- "@aws-sdk/credential-provider-env": "3.654.0",
- "@aws-sdk/credential-provider-http": "3.658.1",
- "@aws-sdk/credential-provider-process": "3.654.0",
- "@aws-sdk/credential-provider-sso": "3.658.1",
- "@aws-sdk/credential-provider-web-identity": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@smithy/credential-provider-imds": "^3.2.3",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "node_modules/@babel/helper-module-transforms": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz",
+ "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-module-imports": "^7.28.6",
+ "@babel/helper-validator-identifier": "^7.28.5",
+ "@babel/traverse": "^7.28.6"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
},
"peerDependencies": {
- "@aws-sdk/client-sts": "^3.658.1"
+ "@babel/core": "^7.0.0"
}
},
- "node_modules/@aws-sdk/credential-provider-node": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.658.1.tgz",
- "integrity": "sha512-XwxW6N+uPXPYAuyq+GfOEdfL/MZGAlCSfB5gEWtLBFmFbikhmEuqfWtI6CD60OwudCUOh6argd21BsJf8o1SJA==",
- "dependencies": {
- "@aws-sdk/credential-provider-env": "3.654.0",
- "@aws-sdk/credential-provider-http": "3.658.1",
- "@aws-sdk/credential-provider-ini": "3.658.1",
- "@aws-sdk/credential-provider-process": "3.654.0",
- "@aws-sdk/credential-provider-sso": "3.658.1",
- "@aws-sdk/credential-provider-web-identity": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@smithy/credential-provider-imds": "^3.2.3",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@babel/helper-plugin-utils": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz",
+ "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-sdk/credential-provider-process": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.654.0.tgz",
- "integrity": "sha512-PmQoo8sZ9Q2Ow8OMzK++Z9lI7MsRUG7sNq3E72DVA215dhtTICTDQwGlXH2AAmIp7n+G9LLRds+4wo2ehG4mkg==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@babel/helper-string-parser": {
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-sdk/credential-provider-sso": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.658.1.tgz",
- "integrity": "sha512-YOagVEsZEk9DmgJEBg+4MBXrPcw/tYas0VQ5OVBqC5XHNbi2OBGJqgmjVPesuu393E7W0VQxtJFDS00O1ewQgA==",
- "dependencies": {
- "@aws-sdk/client-sso": "3.658.1",
- "@aws-sdk/token-providers": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@babel/helper-validator-identifier": {
+ "version": "7.28.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
+ "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-sdk/credential-provider-web-identity": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.654.0.tgz",
- "integrity": "sha512-6a2g9gMtZToqSu+CusjNK5zvbLJahQ9di7buO3iXgbizXpLXU1rnawCpWxwslMpT5fLgMSKDnKDrr6wdEk7jSw==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@babel/helper-validator-option": {
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz",
+ "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=16.0.0"
- },
- "peerDependencies": {
- "@aws-sdk/client-sts": "^3.654.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-sdk/credential-providers": {
- "version": "3.658.1",
- "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.658.1.tgz",
- "integrity": "sha512-lfXA6kZS6GHyi/67EbfrKdLoqHR6j7G35eFwaqxyNkfMhNBpAF0eZK3SYiwnzdR9+Wb/enTFawYiFbG5R+dQzA==",
+ "node_modules/@babel/helpers": {
+ "version": "7.29.2",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.2.tgz",
+ "integrity": "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/client-cognito-identity": "3.658.1",
- "@aws-sdk/client-sso": "3.658.1",
- "@aws-sdk/client-sts": "3.658.1",
- "@aws-sdk/credential-provider-cognito-identity": "3.658.1",
- "@aws-sdk/credential-provider-env": "3.654.0",
- "@aws-sdk/credential-provider-http": "3.658.1",
- "@aws-sdk/credential-provider-ini": "3.658.1",
- "@aws-sdk/credential-provider-node": "3.658.1",
- "@aws-sdk/credential-provider-process": "3.654.0",
- "@aws-sdk/credential-provider-sso": "3.658.1",
- "@aws-sdk/credential-provider-web-identity": "3.654.0",
- "@aws-sdk/types": "3.654.0",
- "@smithy/credential-provider-imds": "^3.2.3",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/template": "^7.28.6",
+ "@babel/types": "^7.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
}
},
- "node_modules/@aws-sdk/middleware-host-header": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.654.0.tgz",
- "integrity": "sha512-rxGgVHWKp8U2ubMv+t+vlIk7QYUaRCHaVpmUlJv0Wv6Q0KeO9a42T9FxHphjOTlCGQOLcjCreL9CF8Qhtb4mdQ==",
+ "node_modules/@babel/parser": {
+ "version": "7.29.2",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz",
+ "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/types": "^7.29.0"
},
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/middleware-logger": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.654.0.tgz",
- "integrity": "sha512-OQYb+nWlmASyXfRb989pwkJ9EVUMP1CrKn2eyTk3usl20JZmKo2Vjis6I0tLUkMSxMhnBJJlQKyWkRpD/u1FVg==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "bin": {
+ "parser": "bin/babel-parser.js"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.0.0"
}
},
- "node_modules/@aws-sdk/middleware-recursion-detection": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.654.0.tgz",
- "integrity": "sha512-gKSomgltKVmsT8sC6W7CrADZ4GHwX9epk3GcH6QhebVO3LA9LRbkL3TwOPUXakxxOLLUTYdOZLIOtFf7iH00lg==",
+ "node_modules/@babel/plugin-syntax-async-generators": {
+ "version": "7.8.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
+ "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=16.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/middleware-user-agent": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.654.0.tgz",
- "integrity": "sha512-liCcqPAyRsr53cy2tYu4qeH4MMN0eh9g6k56XzI5xd4SghXH5YWh4qOYAlQ8T66ZV4nPMtD8GLtLXGzsH8moFg==",
+ "node_modules/@babel/plugin-syntax-bigint": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz",
+ "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@aws-sdk/util-endpoints": "3.654.0",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=16.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/protocol-http": {
- "version": "3.374.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/protocol-http/-/protocol-http-3.374.0.tgz",
- "integrity": "sha512-9WpRUbINdGroV3HiZZIBoJvL2ndoWk39OfwxWs2otxByppJZNN14bg/lvCx5e8ggHUti7IBk5rb0nqQZ4m05pg==",
- "deprecated": "This package has moved to @smithy/protocol-http",
+ "node_modules/@babel/plugin-syntax-class-properties": {
+ "version": "7.12.13",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz",
+ "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/protocol-http": "^1.1.0",
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.12.13"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/protocol-http/node_modules/@smithy/protocol-http": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-1.2.0.tgz",
- "integrity": "sha512-GfGfruksi3nXdFok5RhgtOnWe5f6BndzYfmEXISD+5gAGdayFGpjWu5pIqIweTudMtse20bGbc+7MFZXT1Tb8Q==",
+ "node_modules/@babel/plugin-syntax-class-static-block": {
+ "version": "7.14.5",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz",
+ "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/types": "^1.2.0",
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.14.5"
},
"engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@aws-sdk/protocol-http/node_modules/@smithy/types": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz",
- "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==",
- "dependencies": {
- "tslib": "^2.5.0"
+ "node": ">=6.9.0"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/region-config-resolver": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.654.0.tgz",
- "integrity": "sha512-ydGOrXJxj3x0sJhsXyTmvJVLAE0xxuTWFJihTl67RtaO7VRNtd82I3P3bwoMMaDn5WpmV5mPo8fEUDRlBm3fPg==",
+ "node_modules/@babel/plugin-syntax-import-attributes": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.28.6.tgz",
+ "integrity": "sha512-jiLC0ma9XkQT3TKJ9uYvlakm66Pamywo+qwL+oL8HJOvc6TWdZXVfhqJr8CCzbSGUAbDOzlGHJC1U+vRfLQDvw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "@smithy/util-config-provider": "^3.0.0",
- "@smithy/util-middleware": "^3.0.6",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.28.6"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4": {
- "version": "3.374.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4/-/signature-v4-3.374.0.tgz",
- "integrity": "sha512-2xLJvSdzcZZAg0lsDLUAuSQuihzK0dcxIK7WmfuJeF7DGKJFmp9czQmz5f3qiDz6IDQzvgK1M9vtJSVCslJbyQ==",
- "deprecated": "This package has moved to @smithy/signature-v4",
+ "node_modules/@babel/plugin-syntax-import-meta": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz",
+ "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/signature-v4": "^1.0.1",
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.10.4"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/is-array-buffer": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-1.1.0.tgz",
- "integrity": "sha512-twpQ/n+3OWZJ7Z+xu43MJErmhB/WO/mMTnqR6PwWQShvSJ/emx5d1N59LQZk6ZpTAeuRWrc+eHhkzTp9NFjNRQ==",
+ "node_modules/@babel/plugin-syntax-json-strings": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz",
+ "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/signature-v4": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-1.1.0.tgz",
- "integrity": "sha512-fDo3m7YqXBs7neciOePPd/X9LPm5QLlDMdIC4m1H6dgNLnXfLMFNIxEfPyohGA8VW9Wn4X8lygnPSGxDZSmp0Q==",
+ "node_modules/@babel/plugin-syntax-jsx": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.28.6.tgz",
+ "integrity": "sha512-wgEmr06G6sIpqr8YDwA2dSRTE3bJ+V0IfpzfSY3Lfgd7YWOaAdlykvJi13ZKBt8cZHfgH1IXN+CL656W3uUa4w==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/eventstream-codec": "^1.1.0",
- "@smithy/is-array-buffer": "^1.1.0",
- "@smithy/types": "^1.2.0",
- "@smithy/util-hex-encoding": "^1.1.0",
- "@smithy/util-middleware": "^1.1.0",
- "@smithy/util-uri-escape": "^1.1.0",
- "@smithy/util-utf8": "^1.1.0",
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.28.6"
},
"engines": {
- "node": ">=14.0.0"
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/types": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz",
- "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==",
+ "node_modules/@babel/plugin-syntax-logical-assignment-operators": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz",
+ "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.10.4"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/util-buffer-from": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-1.1.0.tgz",
- "integrity": "sha512-9m6NXE0ww+ra5HKHCHig20T+FAwxBAm7DIdwc/767uGWbRcY720ybgPacQNB96JMOI7xVr/CDa3oMzKmW4a+kw==",
- "dependencies": {
- "@smithy/is-array-buffer": "^1.1.0",
- "tslib": "^2.5.0"
- },
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/util-hex-encoding": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-1.1.0.tgz",
- "integrity": "sha512-7UtIE9eH0u41zpB60Jzr0oNCQ3hMJUabMcKRUVjmyHTXiWDE4vjSqN6qlih7rCNeKGbioS7f/y2Jgym4QZcKFg==",
- "dependencies": {
- "tslib": "^2.5.0"
- },
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/util-middleware": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-1.1.0.tgz",
- "integrity": "sha512-6hhckcBqVgjWAqLy2vqlPZ3rfxLDhFWEmM7oLh2POGvsi7j0tHkbN7w4DFhuBExVJAbJ/qqxqZdRY6Fu7/OezQ==",
+ "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz",
+ "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/util-uri-escape": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-1.1.0.tgz",
- "integrity": "sha512-/jL/V1xdVRt5XppwiaEU8Etp5WHZj609n0xMTuehmCqdoOFbId1M+aEeDWZsQ+8JbEB/BJ6ynY2SlYmOaKtt8w==",
+ "node_modules/@babel/plugin-syntax-numeric-separator": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz",
+ "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.10.4"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/signature-v4/node_modules/@smithy/util-utf8": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-1.1.0.tgz",
- "integrity": "sha512-p/MYV+JmqmPyjdgyN2UxAeYDj9cBqCjp0C/NsTWnnjoZUVqoeZ6IrW915L9CAKWVECgv9lVQGc4u/yz26/bI1A==",
+ "node_modules/@babel/plugin-syntax-object-rest-spread": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz",
+ "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/util-buffer-from": "^1.1.0",
- "tslib": "^2.5.0"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=14.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/token-providers": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.654.0.tgz",
- "integrity": "sha512-D8GeJYmvbfWkQDtTB4owmIobSMexZel0fOoetwvgCQ/7L8VPph3Q2bn1TRRIXvH7wdt6DcDxA3tKMHPBkT3GlA==",
+ "node_modules/@babel/plugin-syntax-optional-catch-binding": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz",
+ "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
"peerDependencies": {
- "@aws-sdk/client-sso-oidc": "^3.654.0"
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/types": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.654.0.tgz",
- "integrity": "sha512-VWvbED3SV+10QJIcmU/PKjsKilsTV16d1I7/on4bvD/jo1qGeMXqLDBSen3ks/tuvXZF/mFc7ZW/W2DiLVtO7A==",
+ "node_modules/@babel/plugin-syntax-optional-chaining": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz",
+ "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.8.0"
},
- "engines": {
- "node": ">=16.0.0"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/util-endpoints": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.654.0.tgz",
- "integrity": "sha512-i902fcBknHs0Irgdpi62+QMvzxE+bczvILXigYrlHL4+PiEnlMVpni5L5W1qCkNZXf8AaMrSBuR1NZAGp6UOUw==",
+ "node_modules/@babel/plugin-syntax-private-property-in-object": {
+ "version": "7.14.5",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz",
+ "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/types": "^3.4.2",
- "@smithy/util-endpoints": "^2.1.2",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.14.5"
},
"engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/util-locate-window": {
- "version": "3.568.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.568.0.tgz",
- "integrity": "sha512-3nh4TINkXYr+H41QaPelCceEB2FXP3fxp93YZXB/kqJvX0U9j0N0Uk45gvsjmEPzG8XxkPEeLIfT2I1M7A6Lig==",
- "dependencies": {
- "tslib": "^2.6.2"
+ "node": ">=6.9.0"
},
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@aws-sdk/util-user-agent-browser": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.654.0.tgz",
- "integrity": "sha512-ykYAJqvnxLt7wfrqya28wuH3/7NdrwzfiFd7NqEVQf7dXVxL5RPEpD7DxjcyQo3DsHvvdUvGZVaQhozycn1pzA==",
- "dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/types": "^3.4.2",
- "bowser": "^2.11.0",
- "tslib": "^2.6.2"
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@aws-sdk/util-user-agent-node": {
- "version": "3.654.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.654.0.tgz",
- "integrity": "sha512-a0ojjdBN6pqv6gB4H/QPPSfhs7mFtlVwnmKCM/QrTaFzN0U810PJ1BST3lBx5sa23I5jWHGaoFY+5q65C3clLQ==",
+ "node_modules/@babel/plugin-syntax-top-level-await": {
+ "version": "7.14.5",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz",
+ "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@aws-sdk/types": "3.654.0",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@babel/helper-plugin-utils": "^7.14.5"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=6.9.0"
},
"peerDependencies": {
- "aws-crt": ">=1.0.0"
- },
- "peerDependenciesMeta": {
- "aws-crt": {
- "optional": true
- }
- }
- },
- "node_modules/@aws-sdk/util-utf8-browser": {
- "version": "3.259.0",
- "resolved": "https://registry.npmjs.org/@aws-sdk/util-utf8-browser/-/util-utf8-browser-3.259.0.tgz",
- "integrity": "sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw==",
- "dependencies": {
- "tslib": "^2.3.1"
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@babel/code-frame": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz",
- "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
+ "node_modules/@babel/plugin-syntax-typescript": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.28.6.tgz",
+ "integrity": "sha512-+nDNmQye7nlnuuHDboPbGm00Vqg3oO8niRRL27/4LYHUsHYh0zJ1xWOz0uRwNFmM1Avzk8wZbc6rdiYhomzv/A==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-validator-identifier": "^7.27.1",
- "js-tokens": "^4.0.0",
- "picocolors": "^1.1.1"
+ "@babel/helper-plugin-utils": "^7.28.6"
},
"engines": {
"node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
}
},
- "node_modules/@babel/compat-data": {
- "version": "7.27.7",
- "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.27.7.tgz",
- "integrity": "sha512-xgu/ySj2mTiUFmdE9yCMfBxLp4DHd5DwmbbD05YAuICfodYT3VvRxbrh81LGQ/8UpSdtMdfKMn3KouYDX59DGQ==",
+ "node_modules/@babel/template": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz",
+ "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==",
"dev": true,
"license": "MIT",
- "engines": {
- "node": ">=6.9.0"
- }
- },
- "node_modules/@babel/core": {
- "version": "7.27.7",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.27.7.tgz",
- "integrity": "sha512-BU2f9tlKQ5CAthiMIgpzAh4eDTLWo1mqi9jqE2OxMG0E/OM199VJt2q8BztTxpnSW0i1ymdwLXRJnYzvDM5r2w==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@ampproject/remapping": "^2.2.0",
- "@babel/code-frame": "^7.27.1",
- "@babel/generator": "^7.27.5",
- "@babel/helper-compilation-targets": "^7.27.2",
- "@babel/helper-module-transforms": "^7.27.3",
- "@babel/helpers": "^7.27.6",
- "@babel/parser": "^7.27.7",
- "@babel/template": "^7.27.2",
- "@babel/traverse": "^7.27.7",
- "@babel/types": "^7.27.7",
- "convert-source-map": "^2.0.0",
- "debug": "^4.1.0",
- "gensync": "^1.0.0-beta.2",
- "json5": "^2.2.3",
- "semver": "^6.3.1"
+ "dependencies": {
+ "@babel/code-frame": "^7.28.6",
+ "@babel/parser": "^7.28.6",
+ "@babel/types": "^7.28.6"
},
"engines": {
"node": ">=6.9.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/babel"
- }
- },
- "node_modules/@babel/core/node_modules/semver": {
- "version": "6.3.1",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
- "dev": true,
- "license": "ISC",
- "bin": {
- "semver": "bin/semver.js"
}
},
- "node_modules/@babel/generator": {
- "version": "7.27.5",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.27.5.tgz",
- "integrity": "sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw==",
+ "node_modules/@babel/traverse": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.0.tgz",
+ "integrity": "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/parser": "^7.27.5",
- "@babel/types": "^7.27.3",
- "@jridgewell/gen-mapping": "^0.3.5",
- "@jridgewell/trace-mapping": "^0.3.25",
- "jsesc": "^3.0.2"
+ "@babel/code-frame": "^7.29.0",
+ "@babel/generator": "^7.29.0",
+ "@babel/helper-globals": "^7.28.0",
+ "@babel/parser": "^7.29.0",
+ "@babel/template": "^7.28.6",
+ "@babel/types": "^7.29.0",
+ "debug": "^4.3.1"
},
"engines": {
"node": ">=6.9.0"
}
},
- "node_modules/@babel/helper-compilation-targets": {
- "version": "7.27.2",
- "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz",
- "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==",
+ "node_modules/@babel/types": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz",
+ "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/compat-data": "^7.27.2",
- "@babel/helper-validator-option": "^7.27.1",
- "browserslist": "^4.24.0",
- "lru-cache": "^5.1.1",
- "semver": "^6.3.1"
+ "@babel/helper-string-parser": "^7.27.1",
+ "@babel/helper-validator-identifier": "^7.28.5"
},
"engines": {
"node": ">=6.9.0"
}
},
- "node_modules/@babel/helper-compilation-targets/node_modules/semver": {
- "version": "6.3.1",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
+ "node_modules/@bcoe/v8-coverage": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
+ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true,
- "license": "ISC",
- "bin": {
- "semver": "bin/semver.js"
- }
+ "license": "MIT"
},
- "node_modules/@babel/helper-module-imports": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz",
- "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==",
+ "node_modules/@cspotcode/source-map-support": {
+ "version": "0.8.1",
+ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
+ "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/traverse": "^7.27.1",
- "@babel/types": "^7.27.1"
+ "@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
- "node": ">=6.9.0"
+ "node": ">=12"
}
},
- "node_modules/@babel/helper-module-transforms": {
- "version": "7.27.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz",
- "integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==",
+ "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.9",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
+ "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
+ "node_modules/@eslint-community/eslint-utils": {
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
+ "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-module-imports": "^7.27.1",
- "@babel/helper-validator-identifier": "^7.27.1",
- "@babel/traverse": "^7.27.3"
+ "eslint-visitor-keys": "^3.4.3"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
},
"peerDependencies": {
- "@babel/core": "^7.0.0"
+ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
}
},
- "node_modules/@babel/helper-plugin-utils": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz",
- "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==",
+ "node_modules/@eslint-community/regexpp": {
+ "version": "4.12.2",
+ "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz",
+ "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==",
"dev": true,
"license": "MIT",
"engines": {
- "node": ">=6.9.0"
+ "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
}
},
- "node_modules/@babel/helper-string-parser": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
- "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
+ "node_modules/@eslint/eslintrc": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz",
+ "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==",
"dev": true,
"license": "MIT",
+ "dependencies": {
+ "ajv": "^6.12.4",
+ "debug": "^4.3.2",
+ "espree": "^9.6.0",
+ "globals": "^13.19.0",
+ "ignore": "^5.2.0",
+ "import-fresh": "^3.2.1",
+ "js-yaml": "^4.1.0",
+ "minimatch": "^3.1.2",
+ "strip-json-comments": "^3.1.1"
+ },
"engines": {
- "node": ">=6.9.0"
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
}
},
- "node_modules/@babel/helper-validator-identifier": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
- "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
+ "node_modules/@eslint/eslintrc/node_modules/globals": {
+ "version": "13.24.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
+ "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==",
"dev": true,
"license": "MIT",
+ "dependencies": {
+ "type-fest": "^0.20.2"
+ },
"engines": {
- "node": ">=6.9.0"
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/@babel/helper-validator-option": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz",
- "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==",
+ "node_modules/@eslint/eslintrc/node_modules/type-fest": {
+ "version": "0.20.2",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
+ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
"dev": true,
- "license": "MIT",
+ "license": "(MIT OR CC0-1.0)",
"engines": {
- "node": ">=6.9.0"
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/@babel/helpers": {
- "version": "7.27.6",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.6.tgz",
- "integrity": "sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug==",
+ "node_modules/@eslint/js": {
+ "version": "9.39.4",
+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.4.tgz",
+ "integrity": "sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==",
"dev": true,
"license": "MIT",
- "dependencies": {
- "@babel/template": "^7.27.2",
- "@babel/types": "^7.27.6"
- },
"engines": {
- "node": ">=6.9.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "url": "https://eslint.org/donate"
}
},
- "node_modules/@babel/parser": {
- "version": "7.27.7",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.7.tgz",
- "integrity": "sha512-qnzXzDXdr/po3bOTbTIQZ7+TxNKxpkN5IifVLXS+r7qwynkZfPyjZfE7hCXbo7IoO9TNcSyibgONsf2HauUd3Q==",
+ "node_modules/@humanwhocodes/config-array": {
+ "version": "0.13.0",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz",
+ "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==",
+ "deprecated": "Use @eslint/config-array instead",
"dev": true,
- "license": "MIT",
+ "license": "Apache-2.0",
"dependencies": {
- "@babel/types": "^7.27.7"
- },
- "bin": {
- "parser": "bin/babel-parser.js"
+ "@humanwhocodes/object-schema": "^2.0.3",
+ "debug": "^4.3.1",
+ "minimatch": "^3.0.5"
},
"engines": {
- "node": ">=6.0.0"
+ "node": ">=10.10.0"
}
},
- "node_modules/@babel/plugin-syntax-async-generators": {
- "version": "7.8.4",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
- "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==",
+ "node_modules/@humanwhocodes/module-importer": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
+ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
"dev": true,
- "license": "MIT",
- "dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=12.22"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/nzakas"
}
},
- "node_modules/@babel/plugin-syntax-bigint": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz",
- "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==",
+ "node_modules/@humanwhocodes/object-schema": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz",
+ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==",
+ "deprecated": "Use @eslint/object-schema instead",
"dev": true,
- "license": "MIT",
- "dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
- }
+ "license": "BSD-3-Clause"
},
- "node_modules/@babel/plugin-syntax-class-properties": {
- "version": "7.12.13",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz",
- "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==",
+ "node_modules/@istanbuljs/load-nyc-config": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
+ "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==",
"dev": true,
- "license": "MIT",
+ "license": "ISC",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.12.13"
+ "camelcase": "^5.3.1",
+ "find-up": "^4.1.0",
+ "get-package-type": "^0.1.0",
+ "js-yaml": "^3.13.1",
+ "resolve-from": "^5.0.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-class-static-block": {
- "version": "7.14.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz",
- "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.14.5"
- },
- "engines": {
- "node": ">=6.9.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "sprintf-js": "~1.0.2"
}
},
- "node_modules/@babel/plugin-syntax-import-attributes": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz",
- "integrity": "sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.27.1"
+ "locate-path": "^5.0.0",
+ "path-exists": "^4.0.0"
},
"engines": {
- "node": ">=6.9.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-import-meta": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz",
- "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
+ "version": "3.14.2",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
+ "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.10.4"
+ "argparse": "^1.0.7",
+ "esprima": "^4.0.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
}
},
- "node_modules/@babel/plugin-syntax-json-strings": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz",
- "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
+ "p-locate": "^4.1.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-jsx": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz",
- "integrity": "sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.27.1"
+ "p-try": "^2.0.0"
},
"engines": {
- "node": ">=6.9.0"
+ "node": ">=6"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/@babel/plugin-syntax-logical-assignment-operators": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz",
- "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.10.4"
+ "p-limit": "^2.2.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz",
- "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==",
+ "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true,
"license": "MIT",
- "dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-numeric-separator": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz",
- "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==",
+ "node_modules/@istanbuljs/schema": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz",
+ "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",
"dev": true,
"license": "MIT",
- "dependencies": {
- "@babel/helper-plugin-utils": "^7.10.4"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": ">=8"
}
},
- "node_modules/@babel/plugin-syntax-object-rest-spread": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz",
- "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==",
+ "node_modules/@jest/console": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz",
+ "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
+ "@jest/types": "^29.6.3",
+ "@types/node": "*",
+ "chalk": "^4.0.0",
+ "jest-message-util": "^29.7.0",
+ "jest-util": "^29.7.0",
+ "slash": "^3.0.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/plugin-syntax-optional-catch-binding": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz",
- "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==",
+ "node_modules/@jest/core": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz",
+ "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
+ "@jest/console": "^29.7.0",
+ "@jest/reporters": "^29.7.0",
+ "@jest/test-result": "^29.7.0",
+ "@jest/transform": "^29.7.0",
+ "@jest/types": "^29.6.3",
+ "@types/node": "*",
+ "ansi-escapes": "^4.2.1",
+ "chalk": "^4.0.0",
+ "ci-info": "^3.2.0",
+ "exit": "^0.1.2",
+ "graceful-fs": "^4.2.9",
+ "jest-changed-files": "^29.7.0",
+ "jest-config": "^29.7.0",
+ "jest-haste-map": "^29.7.0",
+ "jest-message-util": "^29.7.0",
+ "jest-regex-util": "^29.6.3",
+ "jest-resolve": "^29.7.0",
+ "jest-resolve-dependencies": "^29.7.0",
+ "jest-runner": "^29.7.0",
+ "jest-runtime": "^29.7.0",
+ "jest-snapshot": "^29.7.0",
+ "jest-util": "^29.7.0",
+ "jest-validate": "^29.7.0",
+ "jest-watcher": "^29.7.0",
+ "micromatch": "^4.0.4",
+ "pretty-format": "^29.7.0",
+ "slash": "^3.0.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
+ },
+ "peerDependenciesMeta": {
+ "node-notifier": {
+ "optional": true
+ }
}
},
- "node_modules/@babel/plugin-syntax-optional-chaining": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz",
- "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==",
+ "node_modules/@jest/environment": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz",
+ "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.8.0"
+ "@jest/fake-timers": "^29.7.0",
+ "@jest/types": "^29.6.3",
+ "@types/node": "*",
+ "jest-mock": "^29.7.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/plugin-syntax-private-property-in-object": {
- "version": "7.14.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz",
- "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==",
+ "node_modules/@jest/expect": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz",
+ "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.14.5"
+ "expect": "^29.7.0",
+ "jest-snapshot": "^29.7.0"
},
"engines": {
- "node": ">=6.9.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/plugin-syntax-top-level-await": {
- "version": "7.14.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz",
- "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==",
+ "node_modules/@jest/expect-utils": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz",
+ "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.14.5"
+ "jest-get-type": "^29.6.3"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
+ }
+ },
+ "node_modules/@jest/fake-timers": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz",
+ "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jest/types": "^29.6.3",
+ "@sinonjs/fake-timers": "^10.0.2",
+ "@types/node": "*",
+ "jest-message-util": "^29.7.0",
+ "jest-mock": "^29.7.0",
+ "jest-util": "^29.7.0"
},
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/plugin-syntax-typescript": {
- "version": "7.27.1",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz",
- "integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==",
+ "node_modules/@jest/globals": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz",
+ "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-plugin-utils": "^7.27.1"
+ "@jest/environment": "^29.7.0",
+ "@jest/expect": "^29.7.0",
+ "@jest/types": "^29.6.3",
+ "jest-mock": "^29.7.0"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
+ }
+ },
+ "node_modules/@jest/reporters": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz",
+ "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@bcoe/v8-coverage": "^0.2.3",
+ "@jest/console": "^29.7.0",
+ "@jest/test-result": "^29.7.0",
+ "@jest/transform": "^29.7.0",
+ "@jest/types": "^29.6.3",
+ "@jridgewell/trace-mapping": "^0.3.18",
+ "@types/node": "*",
+ "chalk": "^4.0.0",
+ "collect-v8-coverage": "^1.0.0",
+ "exit": "^0.1.2",
+ "glob": "^7.1.3",
+ "graceful-fs": "^4.2.9",
+ "istanbul-lib-coverage": "^3.0.0",
+ "istanbul-lib-instrument": "^6.0.0",
+ "istanbul-lib-report": "^3.0.0",
+ "istanbul-lib-source-maps": "^4.0.0",
+ "istanbul-reports": "^3.1.3",
+ "jest-message-util": "^29.7.0",
+ "jest-util": "^29.7.0",
+ "jest-worker": "^29.7.0",
+ "slash": "^3.0.0",
+ "string-length": "^4.0.1",
+ "strip-ansi": "^6.0.0",
+ "v8-to-istanbul": "^9.0.1"
+ },
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"peerDependencies": {
- "@babel/core": "^7.0.0-0"
+ "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
+ },
+ "peerDependenciesMeta": {
+ "node-notifier": {
+ "optional": true
+ }
}
},
- "node_modules/@babel/template": {
- "version": "7.27.2",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz",
- "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==",
+ "node_modules/@jest/schemas": {
+ "version": "29.6.3",
+ "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz",
+ "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/code-frame": "^7.27.1",
- "@babel/parser": "^7.27.2",
- "@babel/types": "^7.27.1"
+ "@sinclair/typebox": "^0.27.8"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/traverse": {
- "version": "7.27.7",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.27.7.tgz",
- "integrity": "sha512-X6ZlfR/O/s5EQ/SnUSLzr+6kGnkg8HXGMzpgsMsrJVcfDtH1vIp6ctCN4eZ1LS5c0+te5Cb6Y514fASjMRJ1nw==",
+ "node_modules/@jest/source-map": {
+ "version": "29.6.3",
+ "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz",
+ "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/code-frame": "^7.27.1",
- "@babel/generator": "^7.27.5",
- "@babel/parser": "^7.27.7",
- "@babel/template": "^7.27.2",
- "@babel/types": "^7.27.7",
- "debug": "^4.3.1",
- "globals": "^11.1.0"
+ "@jridgewell/trace-mapping": "^0.3.18",
+ "callsites": "^3.0.0",
+ "graceful-fs": "^4.2.9"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/traverse/node_modules/globals": {
- "version": "11.12.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
- "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
+ "node_modules/@jest/test-result": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz",
+ "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==",
"dev": true,
"license": "MIT",
+ "dependencies": {
+ "@jest/console": "^29.7.0",
+ "@jest/types": "^29.6.3",
+ "@types/istanbul-lib-coverage": "^2.0.0",
+ "collect-v8-coverage": "^1.0.0"
+ },
"engines": {
- "node": ">=4"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@babel/types": {
- "version": "7.27.7",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.7.tgz",
- "integrity": "sha512-8OLQgDScAOHXnAz2cV+RfzzNMipuLVBz2biuAJFMV9bfkNf393je3VM8CLkjQodW5+iWsSJdSgSWT6rsZoXHPw==",
+ "node_modules/@jest/test-sequencer": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz",
+ "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/helper-string-parser": "^7.27.1",
- "@babel/helper-validator-identifier": "^7.27.1"
+ "@jest/test-result": "^29.7.0",
+ "graceful-fs": "^4.2.9",
+ "jest-haste-map": "^29.7.0",
+ "slash": "^3.0.0"
},
"engines": {
- "node": ">=6.9.0"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@bcoe/v8-coverage": {
- "version": "0.2.3",
- "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
- "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
+ "node_modules/@jest/transform": {
+ "version": "29.7.0",
+ "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz",
+ "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "dependencies": {
+ "@babel/core": "^7.11.6",
+ "@jest/types": "^29.6.3",
+ "@jridgewell/trace-mapping": "^0.3.18",
+ "babel-plugin-istanbul": "^6.1.1",
+ "chalk": "^4.0.0",
+ "convert-source-map": "^2.0.0",
+ "fast-json-stable-stringify": "^2.1.0",
+ "graceful-fs": "^4.2.9",
+ "jest-haste-map": "^29.7.0",
+ "jest-regex-util": "^29.6.3",
+ "jest-util": "^29.7.0",
+ "micromatch": "^4.0.4",
+ "pirates": "^4.0.4",
+ "slash": "^3.0.0",
+ "write-file-atomic": "^4.0.2"
+ },
+ "engines": {
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
+ }
},
- "node_modules/@cspotcode/source-map-support": {
- "version": "0.8.1",
- "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
- "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
+ "node_modules/@jest/types": {
+ "version": "29.6.3",
+ "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz",
+ "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@jridgewell/trace-mapping": "0.3.9"
+ "@jest/schemas": "^29.6.3",
+ "@types/istanbul-lib-coverage": "^2.0.0",
+ "@types/istanbul-reports": "^3.0.0",
+ "@types/node": "*",
+ "@types/yargs": "^17.0.8",
+ "chalk": "^4.0.0"
},
"engines": {
- "node": ">=12"
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": {
- "version": "0.3.9",
- "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
- "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
+ "node_modules/@jridgewell/gen-mapping": {
+ "version": "0.3.13",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@jridgewell/resolve-uri": "^3.0.3",
- "@jridgewell/sourcemap-codec": "^1.4.10"
+ "@jridgewell/sourcemap-codec": "^1.5.0",
+ "@jridgewell/trace-mapping": "^0.3.24"
}
},
- "node_modules/@eslint-community/eslint-utils": {
- "version": "4.4.0",
+ "node_modules/@jridgewell/remapping": {
+ "version": "2.3.5",
+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
"dev": true,
"license": "MIT",
"dependencies": {
- "eslint-visitor-keys": "^3.3.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "peerDependencies": {
- "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
+ "@jridgewell/gen-mapping": "^0.3.5",
+ "@jridgewell/trace-mapping": "^0.3.24"
}
},
- "node_modules/@eslint-community/regexpp": {
- "version": "4.10.0",
+ "node_modules/@jridgewell/resolve-uri": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"dev": true,
"license": "MIT",
"engines": {
- "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
+ "node": ">=6.0.0"
}
},
- "node_modules/@eslint/eslintrc": {
- "version": "2.1.4",
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.5.5",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
+ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.31",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "ajv": "^6.12.4",
- "debug": "^4.3.2",
- "espree": "^9.6.0",
- "globals": "^13.19.0",
- "ignore": "^5.2.0",
- "import-fresh": "^3.2.1",
- "js-yaml": "^4.1.0",
- "minimatch": "^3.1.2",
- "strip-json-comments": "^3.1.1"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/eslint"
+ "@jridgewell/resolve-uri": "^3.1.0",
+ "@jridgewell/sourcemap-codec": "^1.4.14"
}
},
- "node_modules/@eslint/eslintrc/node_modules/globals": {
- "version": "13.24.0",
+ "node_modules/@nodelib/fs.scandir": {
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
+ "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
"dev": true,
"license": "MIT",
"dependencies": {
- "type-fest": "^0.20.2"
+ "@nodelib/fs.stat": "2.0.5",
+ "run-parallel": "^1.1.9"
},
"engines": {
- "node": ">=8"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
+ "node": ">= 8"
}
},
- "node_modules/@eslint/js": {
- "version": "9.2.0",
+ "node_modules/@nodelib/fs.stat": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
+ "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
"dev": true,
"license": "MIT",
"engines": {
- "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ "node": ">= 8"
}
},
- "node_modules/@grpc/grpc-js": {
- "version": "1.13.4",
- "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.13.4.tgz",
- "integrity": "sha512-GsFaMXCkMqkKIvwCQjCrwH+GHbPKBjhwo/8ZuUkWHqbI73Kky9I+pQltrlT0+MWpedCoosda53lgjYfyEPgxBg==",
- "license": "Apache-2.0",
+ "node_modules/@nodelib/fs.walk": {
+ "version": "1.2.8",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
+ "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
+ "dev": true,
+ "license": "MIT",
"dependencies": {
- "@grpc/proto-loader": "^0.7.13",
- "@js-sdsl/ordered-map": "^4.4.2"
+ "@nodelib/fs.scandir": "2.1.5",
+ "fastq": "^1.6.0"
},
"engines": {
- "node": ">=12.10.0"
+ "node": ">= 8"
}
},
- "node_modules/@grpc/proto-loader": {
- "version": "0.7.15",
- "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.15.tgz",
- "integrity": "sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "lodash.camelcase": "^4.3.0",
- "long": "^5.0.0",
- "protobufjs": "^7.2.5",
- "yargs": "^17.7.2"
- },
- "bin": {
- "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js"
- },
- "engines": {
- "node": ">=6"
- }
- },
- "node_modules/@humanwhocodes/config-array": {
- "version": "0.11.14",
- "dev": true,
- "license": "Apache-2.0",
- "dependencies": {
- "@humanwhocodes/object-schema": "^2.0.2",
- "debug": "^4.3.1",
- "minimatch": "^3.0.5"
- },
- "engines": {
- "node": ">=10.10.0"
- }
- },
- "node_modules/@humanwhocodes/module-importer": {
- "version": "1.0.1",
- "dev": true,
- "license": "Apache-2.0",
- "engines": {
- "node": ">=12.22"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/nzakas"
- }
- },
- "node_modules/@humanwhocodes/object-schema": {
- "version": "2.0.3",
- "dev": true,
- "license": "BSD-3-Clause"
- },
- "node_modules/@istanbuljs/load-nyc-config": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
- "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==",
- "dev": true,
- "license": "ISC",
- "dependencies": {
- "camelcase": "^5.3.1",
- "find-up": "^4.1.0",
- "get-package-type": "^0.1.0",
- "js-yaml": "^3.13.1",
- "resolve-from": "^5.0.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": {
- "version": "1.0.10",
- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
- "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "sprintf-js": "~1.0.2"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
- "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "locate-path": "^5.0.0",
- "path-exists": "^4.0.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
- "version": "3.14.1",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
- "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "argparse": "^1.0.7",
- "esprima": "^4.0.0"
- },
- "bin": {
- "js-yaml": "bin/js-yaml.js"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
- "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "p-locate": "^4.1.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
- "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "p-try": "^2.0.0"
- },
- "engines": {
- "node": ">=6"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
- "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "p-limit": "^2.2.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
- "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@istanbuljs/schema": {
- "version": "0.1.3",
- "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz",
- "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/@jest/console": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz",
- "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/types": "^29.6.3",
- "@types/node": "*",
- "chalk": "^4.0.0",
- "jest-message-util": "^29.7.0",
- "jest-util": "^29.7.0",
- "slash": "^3.0.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/core": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz",
- "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/console": "^29.7.0",
- "@jest/reporters": "^29.7.0",
- "@jest/test-result": "^29.7.0",
- "@jest/transform": "^29.7.0",
- "@jest/types": "^29.6.3",
- "@types/node": "*",
- "ansi-escapes": "^4.2.1",
- "chalk": "^4.0.0",
- "ci-info": "^3.2.0",
- "exit": "^0.1.2",
- "graceful-fs": "^4.2.9",
- "jest-changed-files": "^29.7.0",
- "jest-config": "^29.7.0",
- "jest-haste-map": "^29.7.0",
- "jest-message-util": "^29.7.0",
- "jest-regex-util": "^29.6.3",
- "jest-resolve": "^29.7.0",
- "jest-resolve-dependencies": "^29.7.0",
- "jest-runner": "^29.7.0",
- "jest-runtime": "^29.7.0",
- "jest-snapshot": "^29.7.0",
- "jest-util": "^29.7.0",
- "jest-validate": "^29.7.0",
- "jest-watcher": "^29.7.0",
- "micromatch": "^4.0.4",
- "pretty-format": "^29.7.0",
- "slash": "^3.0.0",
- "strip-ansi": "^6.0.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- },
- "peerDependencies": {
- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
- },
- "peerDependenciesMeta": {
- "node-notifier": {
- "optional": true
- }
- }
- },
- "node_modules/@jest/environment": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz",
- "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/fake-timers": "^29.7.0",
- "@jest/types": "^29.6.3",
- "@types/node": "*",
- "jest-mock": "^29.7.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/expect": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz",
- "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "expect": "^29.7.0",
- "jest-snapshot": "^29.7.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/expect-utils": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz",
- "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "jest-get-type": "^29.6.3"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/fake-timers": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz",
- "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/types": "^29.6.3",
- "@sinonjs/fake-timers": "^10.0.2",
- "@types/node": "*",
- "jest-message-util": "^29.7.0",
- "jest-mock": "^29.7.0",
- "jest-util": "^29.7.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/globals": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz",
- "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/environment": "^29.7.0",
- "@jest/expect": "^29.7.0",
- "@jest/types": "^29.6.3",
- "jest-mock": "^29.7.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/reporters": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz",
- "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@bcoe/v8-coverage": "^0.2.3",
- "@jest/console": "^29.7.0",
- "@jest/test-result": "^29.7.0",
- "@jest/transform": "^29.7.0",
- "@jest/types": "^29.6.3",
- "@jridgewell/trace-mapping": "^0.3.18",
- "@types/node": "*",
- "chalk": "^4.0.0",
- "collect-v8-coverage": "^1.0.0",
- "exit": "^0.1.2",
- "glob": "^7.1.3",
- "graceful-fs": "^4.2.9",
- "istanbul-lib-coverage": "^3.0.0",
- "istanbul-lib-instrument": "^6.0.0",
- "istanbul-lib-report": "^3.0.0",
- "istanbul-lib-source-maps": "^4.0.0",
- "istanbul-reports": "^3.1.3",
- "jest-message-util": "^29.7.0",
- "jest-util": "^29.7.0",
- "jest-worker": "^29.7.0",
- "slash": "^3.0.0",
- "string-length": "^4.0.1",
- "strip-ansi": "^6.0.0",
- "v8-to-istanbul": "^9.0.1"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- },
- "peerDependencies": {
- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
- },
- "peerDependenciesMeta": {
- "node-notifier": {
- "optional": true
- }
- }
- },
- "node_modules/@jest/schemas": {
- "version": "29.6.3",
- "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz",
- "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@sinclair/typebox": "^0.27.8"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/source-map": {
- "version": "29.6.3",
- "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz",
- "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jridgewell/trace-mapping": "^0.3.18",
- "callsites": "^3.0.0",
- "graceful-fs": "^4.2.9"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/test-result": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz",
- "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/console": "^29.7.0",
- "@jest/types": "^29.6.3",
- "@types/istanbul-lib-coverage": "^2.0.0",
- "collect-v8-coverage": "^1.0.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/test-sequencer": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz",
- "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/test-result": "^29.7.0",
- "graceful-fs": "^4.2.9",
- "jest-haste-map": "^29.7.0",
- "slash": "^3.0.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/transform": {
- "version": "29.7.0",
- "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz",
- "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@babel/core": "^7.11.6",
- "@jest/types": "^29.6.3",
- "@jridgewell/trace-mapping": "^0.3.18",
- "babel-plugin-istanbul": "^6.1.1",
- "chalk": "^4.0.0",
- "convert-source-map": "^2.0.0",
- "fast-json-stable-stringify": "^2.1.0",
- "graceful-fs": "^4.2.9",
- "jest-haste-map": "^29.7.0",
- "jest-regex-util": "^29.6.3",
- "jest-util": "^29.7.0",
- "micromatch": "^4.0.4",
- "pirates": "^4.0.4",
- "slash": "^3.0.0",
- "write-file-atomic": "^4.0.2"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jest/types": {
- "version": "29.6.3",
- "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz",
- "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jest/schemas": "^29.6.3",
- "@types/istanbul-lib-coverage": "^2.0.0",
- "@types/istanbul-reports": "^3.0.0",
- "@types/node": "*",
- "@types/yargs": "^17.0.8",
- "chalk": "^4.0.0"
- },
- "engines": {
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
- }
- },
- "node_modules/@jridgewell/gen-mapping": {
- "version": "0.3.11",
- "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.11.tgz",
- "integrity": "sha512-C512c1ytBTio4MrpWKlJpyFHT6+qfFL8SZ58zBzJ1OOzUEjHeF1BtjY2fH7n4x/g2OV/KiiMLAivOp1DXmiMMw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jridgewell/sourcemap-codec": "^1.5.0",
- "@jridgewell/trace-mapping": "^0.3.24"
- }
- },
- "node_modules/@jridgewell/resolve-uri": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
- "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=6.0.0"
- }
- },
- "node_modules/@jridgewell/sourcemap-codec": {
- "version": "1.5.3",
- "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.3.tgz",
- "integrity": "sha512-AiR5uKpFxP3PjO4R19kQGIMwxyRyPuXmKEEy301V1C0+1rVjS94EZQXf1QKZYN8Q0YM+estSPhmx5JwNftv6nw==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/@jridgewell/trace-mapping": {
- "version": "0.3.28",
- "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.28.tgz",
- "integrity": "sha512-KNNHHwW3EIp4EDYOvYFGyIFfx36R2dNJYH4knnZlF8T5jdbD5Wx8xmSaQ2gP9URkJ04LGEtlcCtwArKcmFcwKw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@jridgewell/resolve-uri": "^3.1.0",
- "@jridgewell/sourcemap-codec": "^1.4.14"
- }
- },
- "node_modules/@js-sdsl/ordered-map": {
- "version": "4.4.2",
- "resolved": "https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz",
- "integrity": "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==",
- "license": "MIT",
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/js-sdsl"
- }
- },
- "node_modules/@nodelib/fs.scandir": {
- "version": "2.1.5",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@nodelib/fs.stat": "2.0.5",
- "run-parallel": "^1.1.9"
- },
- "engines": {
- "node": ">= 8"
- }
- },
- "node_modules/@nodelib/fs.stat": {
- "version": "2.0.5",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">= 8"
- }
- },
- "node_modules/@nodelib/fs.walk": {
- "version": "1.2.8",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@nodelib/fs.scandir": "2.1.5",
- "fastq": "^1.6.0"
- },
- "engines": {
- "node": ">= 8"
- }
- },
- "node_modules/@opentelemetry/api": {
- "version": "1.9.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz",
- "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=8.0.0"
- }
- },
- "node_modules/@opentelemetry/api-logs": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.203.0.tgz",
- "integrity": "sha512-9B9RU0H7Ya1Dx/Rkyc4stuBZSGVQF27WigitInx2QQoj6KUpEFYPKoWjdFTunJYxmXmh17HeBvbMa1EhGyPmqQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api": "^1.3.0"
- },
- "engines": {
- "node": ">=8.0.0"
- }
- },
- "node_modules/@opentelemetry/auto-instrumentations-node": {
- "version": "0.62.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/auto-instrumentations-node/-/auto-instrumentations-node-0.62.0.tgz",
- "integrity": "sha512-h5g+VNJjiyX6u/IQpn36ZCHOENg1QW0GgBOHBcFGnHBBhmTww4R3brExdeuYbvLj3UQY09n+UHFEoMOqkhq07A==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/instrumentation-amqplib": "^0.50.0",
- "@opentelemetry/instrumentation-aws-lambda": "^0.54.0",
- "@opentelemetry/instrumentation-aws-sdk": "^0.56.0",
- "@opentelemetry/instrumentation-bunyan": "^0.49.0",
- "@opentelemetry/instrumentation-cassandra-driver": "^0.49.0",
- "@opentelemetry/instrumentation-connect": "^0.47.0",
- "@opentelemetry/instrumentation-cucumber": "^0.18.0",
- "@opentelemetry/instrumentation-dataloader": "^0.21.0",
- "@opentelemetry/instrumentation-dns": "^0.47.0",
- "@opentelemetry/instrumentation-express": "^0.52.0",
- "@opentelemetry/instrumentation-fastify": "^0.48.0",
- "@opentelemetry/instrumentation-fs": "^0.23.0",
- "@opentelemetry/instrumentation-generic-pool": "^0.47.0",
- "@opentelemetry/instrumentation-graphql": "^0.51.0",
- "@opentelemetry/instrumentation-grpc": "^0.203.0",
- "@opentelemetry/instrumentation-hapi": "^0.50.0",
- "@opentelemetry/instrumentation-http": "^0.203.0",
- "@opentelemetry/instrumentation-ioredis": "^0.51.0",
- "@opentelemetry/instrumentation-kafkajs": "^0.12.0",
- "@opentelemetry/instrumentation-knex": "^0.48.0",
- "@opentelemetry/instrumentation-koa": "^0.51.0",
- "@opentelemetry/instrumentation-lru-memoizer": "^0.48.0",
- "@opentelemetry/instrumentation-memcached": "^0.47.0",
- "@opentelemetry/instrumentation-mongodb": "^0.56.0",
- "@opentelemetry/instrumentation-mongoose": "^0.50.0",
- "@opentelemetry/instrumentation-mysql": "^0.49.0",
- "@opentelemetry/instrumentation-mysql2": "^0.49.0",
- "@opentelemetry/instrumentation-nestjs-core": "^0.49.0",
- "@opentelemetry/instrumentation-net": "^0.47.0",
- "@opentelemetry/instrumentation-oracledb": "^0.29.0",
- "@opentelemetry/instrumentation-pg": "^0.55.0",
- "@opentelemetry/instrumentation-pino": "^0.50.0",
- "@opentelemetry/instrumentation-redis": "^0.51.0",
- "@opentelemetry/instrumentation-restify": "^0.49.0",
- "@opentelemetry/instrumentation-router": "^0.48.0",
- "@opentelemetry/instrumentation-runtime-node": "^0.17.0",
- "@opentelemetry/instrumentation-socket.io": "^0.50.0",
- "@opentelemetry/instrumentation-tedious": "^0.22.0",
- "@opentelemetry/instrumentation-undici": "^0.14.0",
- "@opentelemetry/instrumentation-winston": "^0.48.0",
- "@opentelemetry/resource-detector-alibaba-cloud": "^0.31.3",
- "@opentelemetry/resource-detector-aws": "^2.3.0",
- "@opentelemetry/resource-detector-azure": "^0.10.0",
- "@opentelemetry/resource-detector-container": "^0.7.3",
- "@opentelemetry/resource-detector-gcp": "^0.37.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/sdk-node": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.4.1",
- "@opentelemetry/core": "^2.0.0"
- }
- },
- "node_modules/@opentelemetry/context-async-hooks": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.0.1.tgz",
- "integrity": "sha512-XuY23lSI3d4PEqKA+7SLtAgwqIfc6E/E9eAQWLN1vlpC53ybO3o6jW4BsXo1xvz9lYyyWItfQDDLzezER01mCw==",
- "license": "Apache-2.0",
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.0.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/core": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.0.1.tgz",
- "integrity": "sha512-MaZk9SJIDgo1peKevlbhP6+IwIiNPNmswNL4AF0WaQJLbHXjr9SrZMgS12+iqr9ToV4ZVosCcc0f8Rg67LXjxw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.0.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/exporter-jaeger": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-jaeger/-/exporter-jaeger-2.0.1.tgz",
- "integrity": "sha512-FeHtOp2XMhYxzYhC8sXhsc3gMeoDzjI+CGuPX+vRSyUdHZHDKTMoY9jRfk8ObmZsZDTWmd63Yqcf4X472YtHeA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1",
- "@opentelemetry/semantic-conventions": "^1.29.0",
- "jaeger-client": "^3.15.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/exporter-logs-otlp-grpc": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-grpc/-/exporter-logs-otlp-grpc-0.203.0.tgz",
- "integrity": "sha512-g/2Y2noc/l96zmM+g0LdeuyYKINyBwN6FJySoU15LHPLcMN/1a0wNk2SegwKcxrRdE7Xsm7fkIR5n6XFe3QpPw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@grpc/grpc-js": "^1.7.1",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-grpc-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/sdk-logs": "0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-logs-otlp-http": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-http/-/exporter-logs-otlp-http-0.203.0.tgz",
- "integrity": "sha512-s0hys1ljqlMTbXx2XiplmMJg9wG570Z5lH7wMvrZX6lcODI56sG4HL03jklF63tBeyNwK2RV1/ntXGo3HgG4Qw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/sdk-logs": "0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-logs-otlp-proto": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-proto/-/exporter-logs-otlp-proto-0.203.0.tgz",
- "integrity": "sha512-nl/7S91MXn5R1aIzoWtMKGvqxgJgepB/sH9qW0rZvZtabnsjbf8OQ1uSx3yogtvLr0GzwD596nQKz2fV7q2RBw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-logs": "0.203.0",
- "@opentelemetry/sdk-trace-base": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-metrics-otlp-grpc": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-grpc/-/exporter-metrics-otlp-grpc-0.203.0.tgz",
- "integrity": "sha512-FCCj9nVZpumPQSEI57jRAA89hQQgONuoC35Lt+rayWY/mzCAc6BQT7RFyFaZKJ2B7IQ8kYjOCPsF/HGFWjdQkQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@grpc/grpc-js": "^1.7.1",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/exporter-metrics-otlp-http": "0.203.0",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-grpc-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-metrics": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-metrics-otlp-http": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.203.0.tgz",
- "integrity": "sha512-HFSW10y8lY6BTZecGNpV3GpoSy7eaO0Z6GATwZasnT4bEsILp8UJXNG5OmEsz4SdwCSYvyCbTJdNbZP3/8LGCQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-metrics": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-metrics-otlp-proto": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-proto/-/exporter-metrics-otlp-proto-0.203.0.tgz",
- "integrity": "sha512-OZnhyd9npU7QbyuHXFEPVm3LnjZYifuKpT3kTnF84mXeEQ84pJJZgyLBpU4FSkSwUkt/zbMyNAI7y5+jYTWGIg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/exporter-metrics-otlp-http": "0.203.0",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-metrics": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-prometheus": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-prometheus/-/exporter-prometheus-0.203.0.tgz",
- "integrity": "sha512-2jLuNuw5m4sUj/SncDf/mFPabUxMZmmYetx5RKIMIQyPnl6G6ooFzfeE8aXNRf8YD1ZXNlCnRPcISxjveGJHNg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-metrics": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-trace-otlp-grpc": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-grpc/-/exporter-trace-otlp-grpc-0.203.0.tgz",
- "integrity": "sha512-322coOTf81bm6cAA8+ML6A+m4r2xTCdmAZzGNTboPXRzhwPt4JEmovsFAs+grpdarObd68msOJ9FfH3jxM6wqA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@grpc/grpc-js": "^1.7.1",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-grpc-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-trace-otlp-http": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.203.0.tgz",
- "integrity": "sha512-ZDiaswNYo0yq/cy1bBLJFe691izEJ6IgNmkjm4C6kE9ub/OMQqDXORx2D2j8fzTBTxONyzusbaZlqtfmyqURPw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-trace-otlp-proto": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-proto/-/exporter-trace-otlp-proto-0.203.0.tgz",
- "integrity": "sha512-1xwNTJ86L0aJmWRwENCJlH4LULMG2sOXWIVw+Szta4fkqKVY50Eo4HoVKKq6U9QEytrWCr8+zjw0q/ZOeXpcAQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/exporter-zipkin": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-zipkin/-/exporter-zipkin-2.0.1.tgz",
- "integrity": "sha512-a9eeyHIipfdxzCfc2XPrE+/TI3wmrZUDFtG2RRXHSbZZULAny7SyybSvaDvS77a7iib5MPiAvluwVvbGTsHxsw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1",
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.203.0.tgz",
- "integrity": "sha512-ke1qyM+3AK2zPuBPb6Hk/GCsc5ewbLvPNkEuELx/JmANeEp6ZjnZ+wypPAJSucTw0wvCGrUaibDSdcrGFoWxKQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "import-in-the-middle": "^1.8.1",
- "require-in-the-middle": "^7.1.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-amqplib": {
- "version": "0.50.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-amqplib/-/instrumentation-amqplib-0.50.0.tgz",
- "integrity": "sha512-kwNs/itehHG/qaQBcVrLNcvXVPW0I4FCOVtw3LHMLdYIqD7GJ6Yv2nX+a4YHjzbzIeRYj8iyMp0Bl7tlkidq5w==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-aws-lambda": {
- "version": "0.54.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-aws-lambda/-/instrumentation-aws-lambda-0.54.0.tgz",
- "integrity": "sha512-uiYI+kcMUJ/H9cxAwB8c9CaG8behLRgcYSOEA8M/tMQ54Y1ZmzAuEE3QKOi21/s30x5Q+by9g7BwiVfDtqzeMA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/aws-lambda": "8.10.150"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-aws-sdk": {
- "version": "0.56.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-aws-sdk/-/instrumentation-aws-sdk-0.56.0.tgz",
- "integrity": "sha512-Jl2B/FYEb6tBCk9G31CMomKPikGU2g+CEhrGddDI0o1YeNpg3kAO9dExF+w489/IJUGZX6/wudyNvV7z4k9NjQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/propagation-utils": "^0.31.3",
- "@opentelemetry/semantic-conventions": "^1.34.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-bunyan": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-bunyan/-/instrumentation-bunyan-0.49.0.tgz",
- "integrity": "sha512-ky5Am1y6s3Ex/3RygHxB/ZXNG07zPfg9Z6Ora+vfeKcr/+I6CJbWXWhSBJor3gFgKN3RvC11UWVURnmDpBS6Pg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "^0.203.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@types/bunyan": "1.8.11"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-cassandra-driver": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-cassandra-driver/-/instrumentation-cassandra-driver-0.49.0.tgz",
- "integrity": "sha512-BNIvqldmLkeikfI5w5Rlm9vG5NnQexfPoxOgEMzfDVOEF+vS6351I6DzWLLgWWR9CNF/jQJJi/lr6am2DLp0Rw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-connect": {
- "version": "0.47.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-connect/-/instrumentation-connect-0.47.0.tgz",
- "integrity": "sha512-pjenvjR6+PMRb6/4X85L4OtkQCootgb/Jzh/l/Utu3SJHBid1F+gk9sTGU2FWuhhEfV6P7MZ7BmCdHXQjgJ42g==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/connect": "3.4.38"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-cucumber": {
- "version": "0.18.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-cucumber/-/instrumentation-cucumber-0.18.0.tgz",
- "integrity": "sha512-i+cUbLHvRShuevtM0NwjQR9wnABhmYw8+dbgD57LNBde7xkuSDot0CTzX+pYn32djtQ1bPYZiLf+uwS0JsMUrw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-dataloader": {
- "version": "0.21.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-dataloader/-/instrumentation-dataloader-0.21.0.tgz",
- "integrity": "sha512-Xu4CZ1bfhdkV3G6iVHFgKTgHx8GbKSqrTU01kcIJRGHpowVnyOPEv1CW5ow+9GU2X4Eki8zoNuVUenFc3RluxQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-dns": {
- "version": "0.47.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-dns/-/instrumentation-dns-0.47.0.tgz",
- "integrity": "sha512-775fOnewWkTF4iXMGKgwvOGqEmPrU1PZpXjjqvTrEErYBJe7Fz1WlEeUStHepyKOdld7Ghv7TOF/kE3QDctvrg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-express": {
- "version": "0.52.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-express/-/instrumentation-express-0.52.0.tgz",
- "integrity": "sha512-W7pizN0Wh1/cbNhhTf7C62NpyYw7VfCFTYg0DYieSTrtPBT1vmoSZei19wfKLnrMsz3sHayCg0HxCVL2c+cz5w==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-fastify": {
- "version": "0.48.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-fastify/-/instrumentation-fastify-0.48.0.tgz",
- "integrity": "sha512-3zQlE/DoVfVH6/ycuTv7vtR/xib6WOa0aLFfslYcvE62z0htRu/ot8PV/zmMZfnzpTQj8S/4ULv36R6UIbpJIg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-fs": {
- "version": "0.23.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-fs/-/instrumentation-fs-0.23.0.tgz",
- "integrity": "sha512-Puan+QopWHA/KNYvDfOZN6M/JtF6buXEyD934vrb8WhsX1/FuM7OtoMlQyIqAadnE8FqqDL4KDPiEfCQH6pQcQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-generic-pool": {
- "version": "0.47.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-generic-pool/-/instrumentation-generic-pool-0.47.0.tgz",
- "integrity": "sha512-UfHqf3zYK+CwDwEtTjaD12uUqGGTswZ7ofLBEdQ4sEJp9GHSSJMQ2hT3pgBxyKADzUdoxQAv/7NqvL42ZI+Qbw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-graphql": {
- "version": "0.51.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-graphql/-/instrumentation-graphql-0.51.0.tgz",
- "integrity": "sha512-LchkOu9X5DrXAnPI1+Z06h/EH/zC7D6sA86hhPrk3evLlsJTz0grPrkL/yUJM9Ty0CL/y2HSvmWQCjbJEz/ADg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-grpc": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-grpc/-/instrumentation-grpc-0.203.0.tgz",
- "integrity": "sha512-Qmjx2iwccHYRLoE4RFS46CvQE9JG9Pfeae4EPaNZjvIuJxb/pZa2R9VWzRlTehqQWpAvto/dGhtkw8Tv+o0LTg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "0.203.0",
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-hapi": {
- "version": "0.50.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-hapi/-/instrumentation-hapi-0.50.0.tgz",
- "integrity": "sha512-5xGusXOFQXKacrZmDbpHQzqYD1gIkrMWuwvlrEPkYOsjUqGUjl1HbxCsn5Y9bUXOCgP1Lj6A4PcKt1UiJ2MujA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-http": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-http/-/instrumentation-http-0.203.0.tgz",
- "integrity": "sha512-y3uQAcCOAwnO6vEuNVocmpVzG3PER6/YZqbPbbffDdJ9te5NkHEkfSMNzlC3+v7KlE+WinPGc3N7MR30G1HY2g==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/instrumentation": "0.203.0",
- "@opentelemetry/semantic-conventions": "^1.29.0",
- "forwarded-parse": "2.1.2"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-ioredis": {
- "version": "0.51.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-ioredis/-/instrumentation-ioredis-0.51.0.tgz",
- "integrity": "sha512-9IUws0XWCb80NovS+17eONXsw1ZJbHwYYMXiwsfR9TSurkLV5UNbRSKb9URHO+K+pIJILy9wCxvyiOneMr91Ig==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/redis-common": "^0.38.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-kafkajs": {
- "version": "0.12.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-kafkajs/-/instrumentation-kafkajs-0.12.0.tgz",
- "integrity": "sha512-bIe4aSAAxytp88nzBstgr6M7ZiEpW6/D1/SuKXdxxuprf18taVvFL2H5BDNGZ7A14K27haHqzYqtCTqFXHZOYg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.30.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-knex": {
- "version": "0.48.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-knex/-/instrumentation-knex-0.48.0.tgz",
- "integrity": "sha512-V5wuaBPv/lwGxuHjC6Na2JFRjtPgstw19jTFl1B1b6zvaX8zVDYUDaR5hL7glnQtUSCMktPttQsgK4dhXpddcA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.33.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-koa": {
- "version": "0.51.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-koa/-/instrumentation-koa-0.51.0.tgz",
- "integrity": "sha512-XNLWeMTMG1/EkQBbgPYzCeBD0cwOrfnn8ao4hWgLv0fNCFQu1kCsJYygz2cvKuCs340RlnG4i321hX7R8gj3Rg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-lru-memoizer": {
- "version": "0.48.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-lru-memoizer/-/instrumentation-lru-memoizer-0.48.0.tgz",
- "integrity": "sha512-KUW29wfMlTPX1wFz+NNrmE7IzN7NWZDrmFWHM/VJcmFEuQGnnBuTIdsP55CnBDxKgQ/qqYFp4udQFNtjeFosPw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-memcached": {
- "version": "0.47.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-memcached/-/instrumentation-memcached-0.47.0.tgz",
- "integrity": "sha512-vXDs/l4hlWy1IepPG1S6aYiIZn+tZDI24kAzwKKJmR2QEJRL84PojmALAEJGazIOLl/VdcCPZdMb0U2K0VzojA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/memcached": "^2.2.6"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-mongodb": {
- "version": "0.56.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-mongodb/-/instrumentation-mongodb-0.56.0.tgz",
- "integrity": "sha512-YG5IXUUmxX3Md2buVMvxm9NWlKADrnavI36hbJsihqqvBGsWnIfguf0rUP5Srr0pfPqhQjUP+agLMsvu0GmUpA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-mongoose": {
- "version": "0.50.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-mongoose/-/instrumentation-mongoose-0.50.0.tgz",
- "integrity": "sha512-Am8pk1Ct951r4qCiqkBcGmPIgGhoDiFcRtqPSLbJrUZqEPUsigjtMjoWDRLG1Ki1NHgOF7D0H7d+suWz1AAizw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-mysql": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-mysql/-/instrumentation-mysql-0.49.0.tgz",
- "integrity": "sha512-QU9IUNqNsrlfE3dJkZnFHqLjlndiU39ll/YAAEvWE40sGOCi9AtOF6rmEGzJ1IswoZ3oyePV7q2MP8SrhJfVAA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/mysql": "2.15.27"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-mysql2": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-mysql2/-/instrumentation-mysql2-0.49.0.tgz",
- "integrity": "sha512-dCub9wc02mkJWNyHdVEZ7dvRzy295SmNJa+LrAJY2a/+tIiVBQqEAajFzKwp9zegVVnel9L+WORu34rGLQDzxA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@opentelemetry/sql-common": "^0.41.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-nestjs-core": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-nestjs-core/-/instrumentation-nestjs-core-0.49.0.tgz",
- "integrity": "sha512-1R/JFwdmZIk3T/cPOCkVvFQeKYzbbUvDxVH3ShXamUwBlGkdEu5QJitlRMyVNZaHkKZKWgYrBarGQsqcboYgaw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.30.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-net": {
- "version": "0.47.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-net/-/instrumentation-net-0.47.0.tgz",
- "integrity": "sha512-csoJ++Njpf7C09JH+0HNGenuNbDZBqO1rFhMRo6s0rAmJwNh9zY3M/urzptmKlqbKnf4eH0s+CKHy/+M8fbFsQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-oracledb": {
- "version": "0.29.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-oracledb/-/instrumentation-oracledb-0.29.0.tgz",
- "integrity": "sha512-2aHLiJdkyiUbooIUm7FaZf+O4jyqEl+RfFpgud1dxT87QeeYM216wi+xaMNzsb5yKtRBqbA3qeHBCyenYrOZwA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/oracledb": "6.5.2"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-pg": {
- "version": "0.55.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-pg/-/instrumentation-pg-0.55.0.tgz",
- "integrity": "sha512-yfJ5bYE7CnkW/uNsnrwouG/FR7nmg09zdk2MSs7k0ZOMkDDAE3WBGpVFFApGgNu2U+gtzLgEzOQG4I/X+60hXw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@opentelemetry/sql-common": "^0.41.0",
- "@types/pg": "8.15.4",
- "@types/pg-pool": "2.0.6"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-pino": {
- "version": "0.50.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-pino/-/instrumentation-pino-0.50.0.tgz",
- "integrity": "sha512-Pi0cWGp4f2gresq2xqef4IsuunLdebJ9n9tZxytDz2ci4euIfW36ILpszQmRNhwCVDCZLmUgGDKZGj4PXyPd0w==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "^0.203.0",
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-redis": {
- "version": "0.51.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-redis/-/instrumentation-redis-0.51.0.tgz",
- "integrity": "sha512-uL/GtBA0u72YPPehwOvthAe+Wf8k3T+XQPBssJmTYl6fzuZjNq8zTfxVFhl9nRFjFVEe+CtiYNT0Q3AyqW1Z0A==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/redis-common": "^0.38.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-restify": {
- "version": "0.49.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-restify/-/instrumentation-restify-0.49.0.tgz",
- "integrity": "sha512-tsGZZhS4mVZH7omYxw5jpsrD3LhWizqWc0PYtAnzpFUvL5ZINHE+cm57bssTQ2AK/GtZMxu9LktwCvIIf3dSmw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-router": {
- "version": "0.48.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-router/-/instrumentation-router-0.48.0.tgz",
- "integrity": "sha512-Wixrc8CchuJojXpaS/dCQjFOMc+3OEil1H21G+WLYQb8PcKt5kzW9zDBT19nyjjQOx/D/uHPfgbrT+Dc7cfJ9w==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-runtime-node": {
- "version": "0.17.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-runtime-node/-/instrumentation-runtime-node-0.17.0.tgz",
- "integrity": "sha512-O+xc0woqrSjue5IgpCCMvlgsuDrq6DDEfiHW3S3vRMCjXE1ZoPjaDE/K6EURorN+tjnzZQN1gOMSrscSGAbjHg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-socket.io": {
- "version": "0.50.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-socket.io/-/instrumentation-socket.io-0.50.0.tgz",
- "integrity": "sha512-6JN6lnKN9ZuZtZdMQIR+no1qHzQvXSZUsNe3sSWMgqmNRyEXuDUWBIyKKeG0oHRHtR4xE4QhJyD4D5kKRPWZFA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-tedious": {
- "version": "0.22.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-tedious/-/instrumentation-tedious-0.22.0.tgz",
- "integrity": "sha512-XrrNSUCyEjH1ax9t+Uo6lv0S2FCCykcF7hSxBMxKf7Xn0bPRxD3KyFUZy25aQXzbbbUHhtdxj3r2h88SfEM3aA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/instrumentation": "^0.203.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "@types/tedious": "^4.0.14"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-undici": {
- "version": "0.14.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-undici/-/instrumentation-undici-0.14.0.tgz",
- "integrity": "sha512-2HN+7ztxAReXuxzrtA3WboAKlfP5OsPA57KQn2AdYZbJ3zeRPcLXyW4uO/jpLE6PLm0QRtmeGCmfYpqRlwgSwg==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.7.0"
- }
- },
- "node_modules/@opentelemetry/instrumentation-winston": {
- "version": "0.48.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-winston/-/instrumentation-winston-0.48.0.tgz",
- "integrity": "sha512-QuKbswAaQfRULhtlYbeNC9gOAXPxOSCE4BjIzuY1oEsc84kIsHUjn3yvY9Q83s3eg3j0JycNcAMi8u0yTl5PIQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "^0.203.0",
- "@opentelemetry/instrumentation": "^0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/otlp-exporter-base": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.203.0.tgz",
- "integrity": "sha512-Wbxf7k+87KyvxFr5D7uOiSq/vHXWommvdnNE7vECO3tAhsA2GfOlpWINCMWUEPdHZ7tCXxw6Epp3vgx3jU7llQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-transformer": "0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/otlp-grpc-exporter-base": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-grpc-exporter-base/-/otlp-grpc-exporter-base-0.203.0.tgz",
- "integrity": "sha512-te0Ze1ueJF+N/UOFl5jElJW4U0pZXQ8QklgSfJ2linHN0JJsuaHG8IabEUi2iqxY8ZBDlSiz1Trfv5JcjWWWwQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@grpc/grpc-js": "^1.7.1",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/otlp-exporter-base": "0.203.0",
- "@opentelemetry/otlp-transformer": "0.203.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/otlp-transformer": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.203.0.tgz",
- "integrity": "sha512-Y8I6GgoCna0qDQ2W6GCRtaF24SnvqvA8OfeTi7fqigD23u8Jpb4R5KFv/pRvrlGagcCLICMIyh9wiejp4TXu/A==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-logs": "0.203.0",
- "@opentelemetry/sdk-metrics": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1",
- "protobufjs": "^7.3.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.3.0"
- }
- },
- "node_modules/@opentelemetry/propagation-utils": {
- "version": "0.31.3",
- "resolved": "https://registry.npmjs.org/@opentelemetry/propagation-utils/-/propagation-utils-0.31.3.tgz",
- "integrity": "sha512-ZI6LKjyo+QYYZY5SO8vfoCQ9A69r1/g+pyjvtu5RSK38npINN1evEmwqbqhbg2CdcIK3a4PN6pDAJz/yC5/gAA==",
- "license": "Apache-2.0",
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/propagator-b3": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-b3/-/propagator-b3-2.0.1.tgz",
- "integrity": "sha512-Hc09CaQ8Tf5AGLmf449H726uRoBNGPBL4bjr7AnnUpzWMvhdn61F78z9qb6IqB737TffBsokGAK1XykFEZ1igw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.0.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/propagator-jaeger": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-jaeger/-/propagator-jaeger-2.0.1.tgz",
- "integrity": "sha512-7PMdPBmGVH2eQNb/AtSJizQNgeNTfh6jQFqys6lfhd6P4r+m/nTh3gKPPpaCXVdRQ+z93vfKk+4UGty390283w==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.0.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/redis-common": {
- "version": "0.38.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/redis-common/-/redis-common-0.38.0.tgz",
- "integrity": "sha512-4Wc0AWURII2cfXVVoZ6vDqK+s5n4K5IssdrlVrvGsx6OEOKdghKtJZqXAHWFiZv4nTDLH2/2fldjIHY8clMOjQ==",
- "license": "Apache-2.0",
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- }
- },
- "node_modules/@opentelemetry/resource-detector-alibaba-cloud": {
- "version": "0.31.3",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resource-detector-alibaba-cloud/-/resource-detector-alibaba-cloud-0.31.3.tgz",
- "integrity": "sha512-I556LHcLVsBXEgnbPgQISP/JezDt5OfpgOaJNR1iVJl202r+K145OSSOxnH5YOc/KvrydBD0FOE03F7x0xnVTw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/resource-detector-aws": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resource-detector-aws/-/resource-detector-aws-2.3.0.tgz",
- "integrity": "sha512-PkD/lyXG3B3REq1Y6imBLckljkJYXavtqGYSryAeJYvGOf5Ds3doR+BCGjmKeF6ObAtI5MtpBeUStTDtGtBsWA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/resource-detector-azure": {
- "version": "0.10.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resource-detector-azure/-/resource-detector-azure-0.10.0.tgz",
- "integrity": "sha512-5cNAiyPBg53Uxe/CW7hsCq8HiKNAUGH+gi65TtgpzSR9bhJG4AEbuZhbJDFwe97tn2ifAD1JTkbc/OFuaaFWbA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/resource-detector-container": {
- "version": "0.7.3",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resource-detector-container/-/resource-detector-container-0.7.3.tgz",
- "integrity": "sha512-SK+xUFw6DKYbQniaGmIFsFxAZsr8RpRSRWxKi5/ZJAoqqPnjcyGI/SeUx8zzPk4XLO084zyM4pRHgir0hRTaSQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/semantic-conventions": "^1.27.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/resource-detector-gcp": {
- "version": "0.37.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resource-detector-gcp/-/resource-detector-gcp-0.37.0.tgz",
- "integrity": "sha512-LGpJBECIMsVKhiulb4nxUw++m1oF4EiDDPmFGW2aqYaAF0oUvJNv8Z/55CAzcZ7SxvlTgUwzewXDBsuCup7iqw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "^2.0.0",
- "@opentelemetry/resources": "^2.0.0",
- "@opentelemetry/semantic-conventions": "^1.27.0",
- "gcp-metadata": "^6.0.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.0"
- }
- },
- "node_modules/@opentelemetry/resources": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.0.1.tgz",
- "integrity": "sha512-dZOB3R6zvBwDKnHDTB4X1xtMArB/d324VsbiPkX/Yu0Q8T2xceRthoIVFhJdvgVM2QhGVUyX9tzwiNxGtoBJUw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.3.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/sdk-logs": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.203.0.tgz",
- "integrity": "sha512-vM2+rPq0Vi3nYA5akQD2f3QwossDnTDLvKbea6u/A2NZ3XDkPxMfo/PNrDoXhDUD/0pPo2CdH5ce/thn9K0kLw==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.4.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/sdk-metrics": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.0.1.tgz",
- "integrity": "sha512-wf8OaJoSnujMAHWR3g+/hGvNcsC16rf9s1So4JlMiFaFHiE4HpIA3oUh+uWZQ7CNuK8gVW/pQSkgoa5HkkOl0g==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.9.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/sdk-node": {
- "version": "0.203.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-node/-/sdk-node-0.203.0.tgz",
- "integrity": "sha512-zRMvrZGhGVMvAbbjiNQW3eKzW/073dlrSiAKPVWmkoQzah9wfynpVPeL55f9fVIm0GaBxTLcPeukWGy0/Wj7KQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/api-logs": "0.203.0",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/exporter-logs-otlp-grpc": "0.203.0",
- "@opentelemetry/exporter-logs-otlp-http": "0.203.0",
- "@opentelemetry/exporter-logs-otlp-proto": "0.203.0",
- "@opentelemetry/exporter-metrics-otlp-grpc": "0.203.0",
- "@opentelemetry/exporter-metrics-otlp-http": "0.203.0",
- "@opentelemetry/exporter-metrics-otlp-proto": "0.203.0",
- "@opentelemetry/exporter-prometheus": "0.203.0",
- "@opentelemetry/exporter-trace-otlp-grpc": "0.203.0",
- "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
- "@opentelemetry/exporter-trace-otlp-proto": "0.203.0",
- "@opentelemetry/exporter-zipkin": "2.0.1",
- "@opentelemetry/instrumentation": "0.203.0",
- "@opentelemetry/propagator-b3": "2.0.1",
- "@opentelemetry/propagator-jaeger": "2.0.1",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/sdk-logs": "0.203.0",
- "@opentelemetry/sdk-metrics": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1",
- "@opentelemetry/sdk-trace-node": "2.0.1",
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.3.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/sdk-trace-base": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.0.1.tgz",
- "integrity": "sha512-xYLlvk/xdScGx1aEqvxLwf6sXQLXCjk3/1SQT9X9AoN5rXRhkdvIFShuNNmtTEPRBqcsMbS4p/gJLNI2wXaDuQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/resources": "2.0.1",
- "@opentelemetry/semantic-conventions": "^1.29.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.3.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/sdk-trace-node": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.0.1.tgz",
- "integrity": "sha512-UhdbPF19pMpBtCWYP5lHbTogLWx9N0EBxtdagvkn5YtsAnCBZzL7SjktG+ZmupRgifsHMjwUaCCaVmqGfSADmA==",
- "license": "Apache-2.0",
- "dependencies": {
- "@opentelemetry/context-async-hooks": "2.0.1",
- "@opentelemetry/core": "2.0.1",
- "@opentelemetry/sdk-trace-base": "2.0.1"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": ">=1.0.0 <1.10.0"
- }
- },
- "node_modules/@opentelemetry/semantic-conventions": {
- "version": "1.36.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.36.0.tgz",
- "integrity": "sha512-TtxJSRD8Ohxp6bKkhrm27JRHAxPczQA7idtcTOMYI+wQRRrfgqxHv1cFbCApcSnNjtXkmzFozn6jQtFrOmbjPQ==",
+ "node_modules/@opentelemetry/api": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz",
+ "integrity": "sha512-gLyJlPHPZYdAk1JENA9LeHejZe1Ti77/pTeFm/nMXmQH/HFZlcS/O2XJB+L8fkbrNSqhdtlvjBVjxwUYanNH5Q==",
"license": "Apache-2.0",
"engines": {
- "node": ">=14"
+ "node": ">=8.0.0"
}
},
- "node_modules/@opentelemetry/sql-common": {
- "version": "0.41.0",
- "resolved": "https://registry.npmjs.org/@opentelemetry/sql-common/-/sql-common-0.41.0.tgz",
- "integrity": "sha512-pmzXctVbEERbqSfiAgdes9Y63xjoOyXcD7B6IXBkVb+vbM7M9U98mn33nGXxPf4dfYR0M+vhcKRZmbSJ7HfqFA==",
+ "node_modules/@opentelemetry/api-logs": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.214.0.tgz",
+ "integrity": "sha512-40lSJeqYO8Uz2Yj7u94/SJWE/wONa7rmMKjI1ZcIjgf3MHNHv1OZUCrCETGuaRF62d5pQD1wKIW+L4lmSMTzZA==",
"license": "Apache-2.0",
"dependencies": {
- "@opentelemetry/core": "^2.0.0"
- },
- "engines": {
- "node": "^18.19.0 || >=20.6.0"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.1.0"
- }
- },
- "node_modules/@pkgr/core": {
- "version": "0.1.1",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/unts"
- }
- },
- "node_modules/@protobufjs/aspromise": {
- "version": "1.1.2",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/base64": {
- "version": "1.1.2",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/codegen": {
- "version": "2.0.4",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/eventemitter": {
- "version": "1.1.0",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/fetch": {
- "version": "1.1.0",
- "license": "BSD-3-Clause",
- "dependencies": {
- "@protobufjs/aspromise": "^1.1.1",
- "@protobufjs/inquire": "^1.1.0"
- }
- },
- "node_modules/@protobufjs/float": {
- "version": "1.0.2",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/inquire": {
- "version": "1.1.0",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/path": {
- "version": "1.1.2",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/pool": {
- "version": "1.1.0",
- "license": "BSD-3-Clause"
- },
- "node_modules/@protobufjs/utf8": {
- "version": "1.1.0",
- "license": "BSD-3-Clause"
- },
- "node_modules/@sinclair/typebox": {
- "version": "0.27.8",
- "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz",
- "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/@sinonjs/commons": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz",
- "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==",
- "dev": true,
- "license": "BSD-3-Clause",
- "dependencies": {
- "type-detect": "4.0.8"
- }
- },
- "node_modules/@sinonjs/fake-timers": {
- "version": "10.3.0",
- "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz",
- "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==",
- "dev": true,
- "license": "BSD-3-Clause",
- "dependencies": {
- "@sinonjs/commons": "^3.0.0"
- }
- },
- "node_modules/@smithy/abort-controller": {
- "version": "3.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-3.1.4.tgz",
- "integrity": "sha512-VupaALAQlXViW3/enTf/f5l5JZYSAxoJL7f0nanhNNKnww6DGCg1oYIuNP78KDugnkwthBO6iEcym16HhWV8RQ==",
- "dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/config-resolver": {
- "version": "3.0.8",
- "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-3.0.8.tgz",
- "integrity": "sha512-Tv1obAC18XOd2OnDAjSWmmthzx6Pdeh63FbLin8MlPiuJ2ATpKkq0NcNOJFr0dO+JmZXnwu8FQxKJ3TKJ3Hulw==",
- "dependencies": {
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "@smithy/util-config-provider": "^3.0.0",
- "@smithy/util-middleware": "^3.0.6",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/core": {
- "version": "2.4.6",
- "resolved": "https://registry.npmjs.org/@smithy/core/-/core-2.4.6.tgz",
- "integrity": "sha512-6lQQp99hnyuNNIzeTYSzCUXJHwvvFLY7hfdFGSJM95tjRDJGfzWYFRBXPaM9766LiiTsQ561KErtbufzUFSYUg==",
- "dependencies": {
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-retry": "^3.0.21",
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/util-body-length-browser": "^3.0.0",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/credential-provider-imds": {
- "version": "3.2.3",
- "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-3.2.3.tgz",
- "integrity": "sha512-VoxMzSzdvkkjMJNE38yQgx4CfnmT+Z+5EUXkg4x7yag93eQkVQgZvN3XBSHC/ylfBbLbAtdu7flTCChX9I+mVg==",
- "dependencies": {
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/eventstream-codec": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/eventstream-codec/-/eventstream-codec-1.1.0.tgz",
- "integrity": "sha512-3tEbUb8t8an226jKB6V/Q2XU/J53lCwCzULuBPEaF4JjSh+FlCMp7TmogE/Aij5J9DwlsZ4VAD/IRDuQ/0ZtMw==",
- "dependencies": {
- "@aws-crypto/crc32": "3.0.0",
- "@smithy/types": "^1.2.0",
- "@smithy/util-hex-encoding": "^1.1.0",
- "tslib": "^2.5.0"
- }
- },
- "node_modules/@smithy/eventstream-codec/node_modules/@smithy/types": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz",
- "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==",
- "dependencies": {
- "tslib": "^2.5.0"
- },
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@smithy/eventstream-codec/node_modules/@smithy/util-hex-encoding": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-1.1.0.tgz",
- "integrity": "sha512-7UtIE9eH0u41zpB60Jzr0oNCQ3hMJUabMcKRUVjmyHTXiWDE4vjSqN6qlih7rCNeKGbioS7f/y2Jgym4QZcKFg==",
- "dependencies": {
- "tslib": "^2.5.0"
- },
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/@smithy/fetch-http-handler": {
- "version": "3.2.8",
- "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-3.2.8.tgz",
- "integrity": "sha512-Lqe0B8F5RM7zkw//6avq1SJ8AfaRd3ubFUS1eVp5WszV7p6Ne5hQ4dSuMHDpNRPhgTvj4va9Kd/pcVigHEHRow==",
- "dependencies": {
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/querystring-builder": "^3.0.6",
- "@smithy/types": "^3.4.2",
- "@smithy/util-base64": "^3.0.0",
- "tslib": "^2.6.2"
- }
- },
- "node_modules/@smithy/hash-node": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-3.0.6.tgz",
- "integrity": "sha512-c/FHEdKK/7DU2z6ZE91L36ahyXWayR3B+FzELjnYq7wH5YqIseM24V+pWCS9kFn1Ln8OFGTf+pyYPiHZuX0s/Q==",
- "dependencies": {
- "@smithy/types": "^3.4.2",
- "@smithy/util-buffer-from": "^3.0.0",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/invalid-dependency": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-3.0.6.tgz",
- "integrity": "sha512-czM7Ioq3s8pIXht7oD+vmgy4Wfb4XavU/k/irO8NdXFFOx7YAlsCCcKOh/lJD1mJSYQqiR7NmpZ9JviryD/7AQ==",
- "dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- }
- },
- "node_modules/@smithy/is-array-buffer": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-3.0.0.tgz",
- "integrity": "sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ==",
- "dependencies": {
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/middleware-content-length": {
- "version": "3.0.8",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-3.0.8.tgz",
- "integrity": "sha512-VuyszlSO49WKh3H9/kIO2kf07VUwGV80QRiaDxUfP8P8UKlokz381ETJvwLhwuypBYhLymCYyNhB3fLAGBX2og==",
- "dependencies": {
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/middleware-endpoint": {
- "version": "3.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-3.1.3.tgz",
- "integrity": "sha512-KeM/OrK8MVFUsoJsmCN0MZMVPjKKLudn13xpgwIMpGTYpA8QZB2Xq5tJ+RE6iu3A6NhOI4VajDTwBsm8pwwrhg==",
- "dependencies": {
- "@smithy/middleware-serde": "^3.0.6",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "@smithy/url-parser": "^3.0.6",
- "@smithy/util-middleware": "^3.0.6",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/middleware-retry": {
- "version": "3.0.21",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-3.0.21.tgz",
- "integrity": "sha512-/h0fElV95LekVVEJuSw+aI11S1Y3zIUwBc6h9ZbUv43Gl2weXsbQwjLoet6j/Qtb0phfrSxS6pNg6FqgJOWZkA==",
- "dependencies": {
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/service-error-classification": "^3.0.6",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-retry": "^3.0.6",
- "tslib": "^2.6.2",
- "uuid": "^9.0.1"
+ "@opentelemetry/api": "^1.3.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=8.0.0"
}
},
- "node_modules/@smithy/middleware-serde": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-3.0.6.tgz",
- "integrity": "sha512-KKTUSl1MzOM0MAjGbudeaVNtIDo+PpekTBkCNwvfZlKndodrnvRo+00USatiyLOc0ujjO9UydMRu3O9dYML7ag==",
- "dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@opentelemetry/context-async-hooks": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.6.1.tgz",
+ "integrity": "sha512-XHzhwRNkBpeP8Fs/qjGrAf9r9PRv67wkJQ/7ZPaBQQ68DYlTBBx5MF9LvPx7mhuXcDessKK2b+DcxqwpgkcivQ==",
+ "license": "Apache-2.0",
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
}
},
- "node_modules/@smithy/middleware-stack": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-3.0.6.tgz",
- "integrity": "sha512-2c0eSYhTQ8xQqHMcRxLMpadFbTXg6Zla5l0mwNftFCZMQmuhI7EbAJMx6R5eqfuV3YbJ3QGyS3d5uSmrHV8Khg==",
+ "node_modules/@opentelemetry/core": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.6.1.tgz",
+ "integrity": "sha512-8xHSGWpJP9wBxgBpnqGL0R3PbdWQndL1Qp50qrg71+B28zK5OQmUgcDKLJgzyAAV38t4tOyLMGDD60LneR5W8g==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
}
},
- "node_modules/@smithy/node-config-provider": {
- "version": "3.1.7",
- "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-3.1.7.tgz",
- "integrity": "sha512-g3mfnC3Oo8pOI0dYuPXLtdW1WGVb3bR2tkV21GNkm0ZvQjLTtamXAwCWt/FCb0HGvKt3gHHmF1XerG0ICfalOg==",
+ "node_modules/@opentelemetry/exporter-logs-otlp-http": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-http/-/exporter-logs-otlp-http-0.214.0.tgz",
+ "integrity": "sha512-9qv2Tl/Hq6qc5pJCbzFJnzA0uvlb9DgM70yGJPYf3bA5LlLkRCpcn81i4JbcIH4grlQIWY6A+W7YG0LLvS1BAw==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/property-provider": "^3.1.6",
- "@smithy/shared-ini-file-loader": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.214.0",
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/otlp-exporter-base": "0.214.0",
+ "@opentelemetry/otlp-transformer": "0.214.0",
+ "@opentelemetry/sdk-logs": "0.214.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/node-http-handler": {
- "version": "3.2.3",
- "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-3.2.3.tgz",
- "integrity": "sha512-/gcm5DJ3k1b1zEInzBGAZC8ntJ+jwrz1NcSIu+9dSXd1FfG0G6QgkDI40tt8/WYUbHtLyo8fEqtm2v29koWo/w==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.203.0.tgz",
+ "integrity": "sha512-HFSW10y8lY6BTZecGNpV3GpoSy7eaO0Z6GATwZasnT4bEsILp8UJXNG5OmEsz4SdwCSYvyCbTJdNbZP3/8LGCQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/abort-controller": "^3.1.4",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/querystring-builder": "^3.0.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/otlp-exporter-base": "0.203.0",
+ "@opentelemetry/otlp-transformer": "0.203.0",
+ "@opentelemetry/resources": "2.0.1",
+ "@opentelemetry/sdk-metrics": "2.0.1"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/property-provider": {
- "version": "3.1.6",
- "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-3.1.6.tgz",
- "integrity": "sha512-NK3y/T7Q/Bw+Z8vsVs9MYIQ5v7gOX7clyrXcwhhIBQhbPgRl6JDrZbusO9qWDhcEus75Tg+VCxtIRfo3H76fpw==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/api-logs": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.203.0.tgz",
+ "integrity": "sha512-9B9RU0H7Ya1Dx/Rkyc4stuBZSGVQF27WigitInx2QQoj6KUpEFYPKoWjdFTunJYxmXmh17HeBvbMa1EhGyPmqQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/api": "^1.3.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=8.0.0"
}
},
- "node_modules/@smithy/protocol-http": {
- "version": "4.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.1.3.tgz",
- "integrity": "sha512-GcbMmOYpH9iRqtC05RbRnc/0FssxSTHlmaNhYBTgSgNCYpdR3Kt88u5GAZTBmouzv+Zlj/VRv92J9ruuDeJuEw==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/core": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.0.1.tgz",
+ "integrity": "sha512-MaZk9SJIDgo1peKevlbhP6+IwIiNPNmswNL4AF0WaQJLbHXjr9SrZMgS12+iqr9ToV4ZVosCcc0f8Rg67LXjxw==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
}
},
- "node_modules/@smithy/querystring-builder": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-3.0.6.tgz",
- "integrity": "sha512-sQe08RunoObe+Usujn9+R2zrLuQERi3CWvRO3BvnoWSYUaIrLKuAIeY7cMeDax6xGyfIP3x/yFWbEKSXvOnvVg==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-exporter-base": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.203.0.tgz",
+ "integrity": "sha512-Wbxf7k+87KyvxFr5D7uOiSq/vHXWommvdnNE7vECO3tAhsA2GfOlpWINCMWUEPdHZ7tCXxw6Epp3vgx3jU7llQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "@smithy/util-uri-escape": "^3.0.0",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/otlp-transformer": "0.203.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/querystring-parser": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-3.0.6.tgz",
- "integrity": "sha512-UJKw4LlEkytzz2Wq+uIdHf6qOtFfee/o7ruH0jF5I6UAuU+19r9QV7nU3P/uI0l6+oElRHmG/5cBBcGJrD7Ozg==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-transformer": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.203.0.tgz",
+ "integrity": "sha512-Y8I6GgoCna0qDQ2W6GCRtaF24SnvqvA8OfeTi7fqigD23u8Jpb4R5KFv/pRvrlGagcCLICMIyh9wiejp4TXu/A==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.203.0",
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/resources": "2.0.1",
+ "@opentelemetry/sdk-logs": "0.203.0",
+ "@opentelemetry/sdk-metrics": "2.0.1",
+ "@opentelemetry/sdk-trace-base": "2.0.1",
+ "protobufjs": "^7.3.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/service-error-classification": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-3.0.6.tgz",
- "integrity": "sha512-53SpchU3+DUZrN7J6sBx9tBiCVGzsib2e4sc512Q7K9fpC5zkJKs6Z9s+qbMxSYrkEkle6hnMtrts7XNkMJJMg==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/resources": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.0.1.tgz",
+ "integrity": "sha512-dZOB3R6zvBwDKnHDTB4X1xtMArB/d324VsbiPkX/Yu0Q8T2xceRthoIVFhJdvgVM2QhGVUyX9tzwiNxGtoBJUw==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2"
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
}
},
- "node_modules/@smithy/shared-ini-file-loader": {
- "version": "3.1.7",
- "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-3.1.7.tgz",
- "integrity": "sha512-IA4K2qTJYXkF5OfVN4vsY1hfnUZjaslEE8Fsr/gGFza4TAC2A9NfnZuSY2srQIbt9bwtjHiAayrRVgKse4Q7fA==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-logs": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.203.0.tgz",
+ "integrity": "sha512-vM2+rPq0Vi3nYA5akQD2f3QwossDnTDLvKbea6u/A2NZ3XDkPxMfo/PNrDoXhDUD/0pPo2CdH5ce/thn9K0kLw==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.203.0",
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/resources": "2.0.1"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.4.0 <1.10.0"
}
},
- "node_modules/@smithy/signature-v4": {
- "version": "4.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-4.1.4.tgz",
- "integrity": "sha512-72MiK7xYukNsnLJI9NqvUHqTu0ziEsfMsYNlWpiJfuGQnCTFKpckThlEatirvcA/LmT1h7rRO+pJD06PYsPu9Q==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-metrics": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.0.1.tgz",
+ "integrity": "sha512-wf8OaJoSnujMAHWR3g+/hGvNcsC16rf9s1So4JlMiFaFHiE4HpIA3oUh+uWZQ7CNuK8gVW/pQSkgoa5HkkOl0g==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/is-array-buffer": "^3.0.0",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "@smithy/util-hex-encoding": "^3.0.0",
- "@smithy/util-middleware": "^3.0.6",
- "@smithy/util-uri-escape": "^3.0.0",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/resources": "2.0.1"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.9.0 <1.10.0"
}
},
- "node_modules/@smithy/smithy-client": {
- "version": "3.3.5",
- "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-3.3.5.tgz",
- "integrity": "sha512-7IZi8J3Dr9n3tX+lcpmJ/5tCYIqoXdblFBaPuv0SEKZFRpCxE+TqIWL6I3t7jLlk9TWu3JSvEZAhtjB9yvB+zA==",
+ "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-trace-base": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.0.1.tgz",
+ "integrity": "sha512-xYLlvk/xdScGx1aEqvxLwf6sXQLXCjk3/1SQT9X9AoN5rXRhkdvIFShuNNmtTEPRBqcsMbS4p/gJLNI2wXaDuQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/middleware-endpoint": "^3.1.3",
- "@smithy/middleware-stack": "^3.0.6",
- "@smithy/protocol-http": "^4.1.3",
- "@smithy/types": "^3.4.2",
- "@smithy/util-stream": "^3.1.8",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.0.1",
+ "@opentelemetry/resources": "2.0.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
}
},
- "node_modules/@smithy/types": {
- "version": "3.4.2",
- "resolved": "https://registry.npmjs.org/@smithy/types/-/types-3.4.2.tgz",
- "integrity": "sha512-tHiFcfcVedVBHpmHUEUHOCCih8iZbIAYn9NvPsNzaPm/237I3imdDdZoOC8c87H5HBAVEa06tTgb+OcSWV9g5w==",
+ "node_modules/@opentelemetry/exporter-trace-otlp-http": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.214.0.tgz",
+ "integrity": "sha512-kIN8nTBMgV2hXzV/a20BCFilPZdAIMYYJGSgfMMRm/Xa+07y5hRDS2Vm12A/z8Cdu3Sq++ZvJfElokX2rkgGgw==",
+ "license": "Apache-2.0",
"dependencies": {
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/otlp-exporter-base": "0.214.0",
+ "@opentelemetry/otlp-transformer": "0.214.0",
+ "@opentelemetry/resources": "2.6.1",
+ "@opentelemetry/sdk-trace-base": "2.6.1"
},
"engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/url-parser": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-3.0.6.tgz",
- "integrity": "sha512-47Op/NU8Opt49KyGpHtVdnmmJMsp2hEwBdyjuFB9M2V5QVOwA7pBhhxKN5z6ztKGrMw76gd8MlbPuzzvaAncuQ==",
- "dependencies": {
- "@smithy/querystring-parser": "^3.0.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/util-base64": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-3.0.0.tgz",
- "integrity": "sha512-Kxvoh5Qtt0CDsfajiZOCpJxgtPHXOKwmM+Zy4waD43UoEMA+qPxxa98aE/7ZhdnBFZFXMOiBR5xbcaMhLtznQQ==",
+ "node_modules/@opentelemetry/instrumentation": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.203.0.tgz",
+ "integrity": "sha512-ke1qyM+3AK2zPuBPb6Hk/GCsc5ewbLvPNkEuELx/JmANeEp6ZjnZ+wypPAJSucTw0wvCGrUaibDSdcrGFoWxKQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/util-buffer-from": "^3.0.0",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.203.0",
+ "import-in-the-middle": "^1.8.1",
+ "require-in-the-middle": "^7.1.1"
},
"engines": {
- "node": ">=16.0.0"
- }
- },
- "node_modules/@smithy/util-body-length-browser": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-3.0.0.tgz",
- "integrity": "sha512-cbjJs2A1mLYmqmyVl80uoLTJhAcfzMOyPgjwAYusWKMdLeNtzmMz9YxNl3/jRLoxSS3wkqkf0jwNdtXWtyEBaQ==",
- "dependencies": {
- "tslib": "^2.6.2"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/util-body-length-node": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-3.0.0.tgz",
- "integrity": "sha512-Tj7pZ4bUloNUP6PzwhN7K386tmSmEET9QtQg0TgdNOnxhZvCssHji+oZTUIuzxECRfG8rdm2PMw2WCFs6eIYkA==",
+ "node_modules/@opentelemetry/instrumentation/node_modules/@opentelemetry/api-logs": {
+ "version": "0.203.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.203.0.tgz",
+ "integrity": "sha512-9B9RU0H7Ya1Dx/Rkyc4stuBZSGVQF27WigitInx2QQoj6KUpEFYPKoWjdFTunJYxmXmh17HeBvbMa1EhGyPmqQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "tslib": "^2.6.2"
+ "@opentelemetry/api": "^1.3.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": ">=8.0.0"
}
},
- "node_modules/@smithy/util-buffer-from": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz",
- "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==",
+ "node_modules/@opentelemetry/otlp-exporter-base": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.214.0.tgz",
+ "integrity": "sha512-u1Gdv0/E9wP+apqWf7Wv2npXmgJtxsW2XL0TEv9FZloTZRuMBKmu8cYVXwS4Hm3q/f/3FuCnPTgiwYvIqRSpRg==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/is-array-buffer": "^3.0.0",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/otlp-transformer": "0.214.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/util-config-provider": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-3.0.0.tgz",
- "integrity": "sha512-pbjk4s0fwq3Di/ANL+rCvJMKM5bzAQdE5S/6RL5NXgMExFAi6UgQMPOm5yPaIWPpr+EOXKXRonJ3FoxKf4mCJQ==",
+ "node_modules/@opentelemetry/otlp-transformer": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.214.0.tgz",
+ "integrity": "sha512-DSaYcuBRh6uozfsWN3R8HsN0yDhCuWP7tOFdkUOVaWD1KVJg8m4qiLUsg/tNhTLS9HUYUcwNpwL2eroLtsZZ/w==",
+ "license": "Apache-2.0",
"dependencies": {
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.214.0",
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/resources": "2.6.1",
+ "@opentelemetry/sdk-logs": "0.214.0",
+ "@opentelemetry/sdk-metrics": "2.6.1",
+ "@opentelemetry/sdk-trace-base": "2.6.1",
+ "protobufjs": "^7.0.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
}
},
- "node_modules/@smithy/util-defaults-mode-browser": {
- "version": "3.0.21",
- "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-3.0.21.tgz",
- "integrity": "sha512-M/FhTBk4c/SsB91dD/M4gMGfJO7z/qJaM9+XQQIqBOf4qzZYMExnP7R4VdGwxxH8IKMGW+8F0I4rNtVRrcfPoA==",
+ "node_modules/@opentelemetry/resources": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.6.1.tgz",
+ "integrity": "sha512-lID/vxSuKWXM55XhAKNoYXu9Cutoq5hFdkbTdI/zDKQktXzcWBVhNsOkiZFTMU9UtEWuGRNe0HUgmsFldIdxVA==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/property-provider": "^3.1.6",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "bowser": "^2.11.0",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">= 10.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
}
},
- "node_modules/@smithy/util-defaults-mode-node": {
- "version": "3.0.21",
- "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-3.0.21.tgz",
- "integrity": "sha512-NiLinPvF86U3S2Pdx/ycqd4bnY5dmFSPNL5KYRwbNjqQFS09M5Wzqk8BNk61/47xCYz1X/6KeiSk9qgYPTtuDw==",
+ "node_modules/@opentelemetry/sdk-logs": {
+ "version": "0.214.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.214.0.tgz",
+ "integrity": "sha512-zf6acnScjhsaBUU22zXZ/sLWim1dfhUAbGXdMmHmNG3LfBnQ3DKsOCITb2IZwoUsNNMTogqFKBnlIPPftUgGwA==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/config-resolver": "^3.0.8",
- "@smithy/credential-provider-imds": "^3.2.3",
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/property-provider": "^3.1.6",
- "@smithy/smithy-client": "^3.3.5",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/api-logs": "0.214.0",
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/resources": "2.6.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">= 10.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.4.0 <1.10.0"
}
},
- "node_modules/@smithy/util-endpoints": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-2.1.2.tgz",
- "integrity": "sha512-FEISzffb4H8DLzGq1g4MuDpcv6CIG15fXoQzDH9SjpRJv6h7J++1STFWWinilG0tQh9H1v2UKWG19Jjr2B16zQ==",
+ "node_modules/@opentelemetry/sdk-metrics": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.6.1.tgz",
+ "integrity": "sha512-9t9hJHX15meBy2NmTJxL+NJfXmnausR2xUDvE19XQce0Qi/GBtDGamU8nS1RMbdgDmhgpm3VaOu2+fiS/SfTpQ==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/node-config-provider": "^3.1.7",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/resources": "2.6.1"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.9.0 <1.10.0"
}
},
- "node_modules/@smithy/util-hex-encoding": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-3.0.0.tgz",
- "integrity": "sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ==",
+ "node_modules/@opentelemetry/sdk-trace-base": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.6.1.tgz",
+ "integrity": "sha512-r86ut4T1e8vNwB35CqCcKd45yzqH6/6Wzvpk2/cZB8PsPLlZFTvrh8yfOS3CYZYcUmAx4hHTZJ8AO8Dj8nrdhw==",
+ "license": "Apache-2.0",
"dependencies": {
- "tslib": "^2.6.2"
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/resources": "2.6.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
}
},
- "node_modules/@smithy/util-middleware": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-3.0.6.tgz",
- "integrity": "sha512-BxbX4aBhI1O9p87/xM+zWy0GzT3CEVcXFPBRDoHAM+pV0eSW156pR+PSYEz0DQHDMYDsYAflC2bQNz2uaDBUZQ==",
+ "node_modules/@opentelemetry/sdk-trace-node": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.6.1.tgz",
+ "integrity": "sha512-Hh2i4FwHWRFhnO2Q/p6svMxy8MPsNCG0uuzUY3glqm0rwM0nQvbTO1dXSp9OqQoTKXcQzaz9q1f65fsurmOhNw==",
+ "license": "Apache-2.0",
"dependencies": {
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
+ "@opentelemetry/context-async-hooks": "2.6.1",
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/sdk-trace-base": "2.6.1"
},
"engines": {
- "node": ">=16.0.0"
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
}
},
- "node_modules/@smithy/util-retry": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-3.0.6.tgz",
- "integrity": "sha512-BRZiuF7IwDntAbevqMco67an0Sr9oLQJqqRCsSPZZHYRnehS0LHDAkJk/pSmI7Z8c/1Vet294H7fY2fWUgB+Rg==",
- "dependencies": {
- "@smithy/service-error-classification": "^3.0.6",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
+ "node_modules/@opentelemetry/semantic-conventions": {
+ "version": "1.40.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.40.0.tgz",
+ "integrity": "sha512-cifvXDhcqMwwTlTK04GBNeIe7yyo28Mfby85QXFe1Yk8nmi36Ab/5UQwptOx84SsoGNRg+EVSjwzfSZMy6pmlw==",
+ "license": "Apache-2.0",
"engines": {
- "node": ">=16.0.0"
+ "node": ">=14"
}
},
- "node_modules/@smithy/util-stream": {
- "version": "3.1.8",
- "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-3.1.8.tgz",
- "integrity": "sha512-hoKOqSmb8FD3WLObuB5hwbM7bNIWgcnvkThokTvVq7J5PKjlLUK5qQQcB9zWLHIoSaIlf3VIv2OxZY2wtQjcRQ==",
- "dependencies": {
- "@smithy/fetch-http-handler": "^3.2.8",
- "@smithy/node-http-handler": "^3.2.3",
- "@smithy/types": "^3.4.2",
- "@smithy/util-base64": "^3.0.0",
- "@smithy/util-buffer-from": "^3.0.0",
- "@smithy/util-hex-encoding": "^3.0.0",
- "@smithy/util-utf8": "^3.0.0",
- "tslib": "^2.6.2"
- },
+ "node_modules/@pkgr/core": {
+ "version": "0.2.9",
+ "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz",
+ "integrity": "sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">=16.0.0"
+ "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/pkgr"
}
},
- "node_modules/@smithy/util-uri-escape": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-3.0.0.tgz",
- "integrity": "sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg==",
+ "node_modules/@protobufjs/aspromise": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
+ "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/base64": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
+ "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/codegen": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
+ "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/eventemitter": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
+ "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/fetch": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
+ "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
+ "license": "BSD-3-Clause",
"dependencies": {
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
+ "@protobufjs/aspromise": "^1.1.1",
+ "@protobufjs/inquire": "^1.1.0"
}
},
- "node_modules/@smithy/util-utf8": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-3.0.0.tgz",
- "integrity": "sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==",
+ "node_modules/@protobufjs/float": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
+ "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/inquire": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
+ "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/path": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
+ "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/pool": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
+ "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/utf8": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
+ "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@sinclair/typebox": {
+ "version": "0.27.10",
+ "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.10.tgz",
+ "integrity": "sha512-MTBk/3jGLNB2tVxv6uLlFh1iu64iYOQ2PbdOSK3NW8JZsmlaOh2q6sdtKowBhfw8QFLmYNzTW4/oK4uATIi6ZA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@sinonjs/commons": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz",
+ "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==",
+ "dev": true,
+ "license": "BSD-3-Clause",
"dependencies": {
- "@smithy/util-buffer-from": "^3.0.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
+ "type-detect": "4.0.8"
}
},
- "node_modules/@smithy/util-waiter": {
- "version": "3.1.5",
- "resolved": "https://registry.npmjs.org/@smithy/util-waiter/-/util-waiter-3.1.5.tgz",
- "integrity": "sha512-jYOSvM3H6sZe3CHjzD2VQNCjWBJs+4DbtwBMvUp9y5EnnwNa7NQxTeYeQw0CKCAdGGZ3QvVkyJmvbvs5M/B10A==",
+ "node_modules/@sinonjs/fake-timers": {
+ "version": "10.3.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz",
+ "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==",
+ "dev": true,
+ "license": "BSD-3-Clause",
"dependencies": {
- "@smithy/abort-controller": "^3.1.4",
- "@smithy/types": "^3.4.2",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": ">=16.0.0"
+ "@sinonjs/commons": "^3.0.0"
}
},
"node_modules/@tsconfig/node10": {
- "version": "1.0.11",
- "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
- "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
+ "version": "1.0.12",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz",
+ "integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==",
"dev": true,
"license": "MIT"
},
@@ -4168,12 +1746,6 @@
"dev": true,
"license": "MIT"
},
- "node_modules/@types/aws-lambda": {
- "version": "8.10.150",
- "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.150.tgz",
- "integrity": "sha512-AX+AbjH/rH5ezX1fbK8onC/a+HyQHo7QGmvoxAE42n22OsciAxvZoZNEr22tbXs8WfP1nIsBjKDpgPm3HjOZbA==",
- "license": "MIT"
- },
"node_modules/@types/babel__core": {
"version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
@@ -4210,31 +1782,13 @@
}
},
"node_modules/@types/babel__traverse": {
- "version": "7.20.7",
- "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.7.tgz",
- "integrity": "sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==",
+ "version": "7.28.0",
+ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz",
+ "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/types": "^7.20.7"
- }
- },
- "node_modules/@types/bunyan": {
- "version": "1.8.11",
- "resolved": "https://registry.npmjs.org/@types/bunyan/-/bunyan-1.8.11.tgz",
- "integrity": "sha512-758fRH7umIMk5qt5ELmRMff4mLDlN+xyYzC+dkPTdKwbSkJFvz6xwyScrytPU0QIBbRRwbiE8/BIg8bpajerNQ==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
- "node_modules/@types/connect": {
- "version": "3.4.38",
- "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
- "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
+ "@babel/types": "^7.28.2"
}
},
"node_modules/@types/graceful-fs": {
@@ -4285,78 +1839,15 @@
"pretty-format": "^29.0.0"
}
},
- "node_modules/@types/json-schema": {
- "version": "7.0.15",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/@types/memcached": {
- "version": "2.2.10",
- "resolved": "https://registry.npmjs.org/@types/memcached/-/memcached-2.2.10.tgz",
- "integrity": "sha512-AM9smvZN55Gzs2wRrqeMHVP7KE8KWgCJO/XL5yCly2xF6EKa4YlbpK+cLSAH4NG/Ah64HrlegmGqW8kYws7Vxg==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
- "node_modules/@types/mysql": {
- "version": "2.15.27",
- "resolved": "https://registry.npmjs.org/@types/mysql/-/mysql-2.15.27.tgz",
- "integrity": "sha512-YfWiV16IY0OeBfBCk8+hXKmdTKrKlwKN1MNKAPBu5JYxLwBEZl7QzeEpGnlZb3VMGJrrGmB84gXiH+ofs/TezA==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
"node_modules/@types/node": {
- "version": "18.19.33",
- "license": "MIT",
- "dependencies": {
- "undici-types": "~5.26.4"
- }
- },
- "node_modules/@types/node-fetch": {
- "version": "2.6.11",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*",
- "form-data": "^4.0.0"
- }
- },
- "node_modules/@types/oracledb": {
- "version": "6.5.2",
- "resolved": "https://registry.npmjs.org/@types/oracledb/-/oracledb-6.5.2.tgz",
- "integrity": "sha512-kK1eBS/Adeyis+3OlBDMeQQuasIDLUYXsi2T15ccNJ0iyUpQ4xDF7svFu3+bGVrI0CMBUclPciz+lsQR3JX3TQ==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
- "node_modules/@types/pg": {
- "version": "8.15.4",
- "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.15.4.tgz",
- "integrity": "sha512-I6UNVBAoYbvuWkkU3oosC8yxqH21f4/Jc4DK71JLG3dT2mdlGe1z+ep/LQGXaKaOgcvUrsQoPRqfgtMcvZiJhg==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*",
- "pg-protocol": "*",
- "pg-types": "^2.2.0"
- }
- },
- "node_modules/@types/pg-pool": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/@types/pg-pool/-/pg-pool-2.0.6.tgz",
- "integrity": "sha512-TaAUE5rq2VQYxab5Ts7WZhKNmuN78Q6PiFonTDdpbx8a1H0M1vhy3rhiMjl+e2iHmogyMw7jZF4FrE6eJUy5HQ==",
+ "version": "25.5.0",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.0.tgz",
+ "integrity": "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw==",
"license": "MIT",
"dependencies": {
- "@types/pg": "*"
+ "undici-types": "~7.18.0"
}
},
- "node_modules/@types/semver": {
- "version": "7.5.8",
- "dev": true,
- "license": "MIT"
- },
"node_modules/@types/stack-utils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
@@ -4364,19 +1855,10 @@
"dev": true,
"license": "MIT"
},
- "node_modules/@types/tedious": {
- "version": "4.0.14",
- "resolved": "https://registry.npmjs.org/@types/tedious/-/tedious-4.0.14.tgz",
- "integrity": "sha512-KHPsfX/FoVbUGbyYvk1q9MMQHLPeRZhRJZdO45Q4YjvFkv4hMNghCWTvy7rdKessBsmtz4euWCWAB6/tVpI1Iw==",
- "license": "MIT",
- "dependencies": {
- "@types/node": "*"
- }
- },
"node_modules/@types/yargs": {
- "version": "17.0.33",
- "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz",
- "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==",
+ "version": "17.0.35",
+ "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.35.tgz",
+ "integrity": "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4391,20 +1873,20 @@
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz",
+ "integrity": "sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
- "@typescript-eslint/scope-manager": "7.8.0",
- "@typescript-eslint/type-utils": "7.8.0",
- "@typescript-eslint/utils": "7.8.0",
- "@typescript-eslint/visitor-keys": "7.8.0",
- "debug": "^4.3.4",
+ "@typescript-eslint/scope-manager": "7.18.0",
+ "@typescript-eslint/type-utils": "7.18.0",
+ "@typescript-eslint/utils": "7.18.0",
+ "@typescript-eslint/visitor-keys": "7.18.0",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
- "semver": "^7.6.0",
"ts-api-utils": "^1.3.0"
},
"engines": {
@@ -4425,14 +1907,16 @@
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.18.0.tgz",
+ "integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
- "@typescript-eslint/scope-manager": "7.8.0",
- "@typescript-eslint/types": "7.8.0",
- "@typescript-eslint/typescript-estree": "7.8.0",
- "@typescript-eslint/visitor-keys": "7.8.0",
+ "@typescript-eslint/scope-manager": "7.18.0",
+ "@typescript-eslint/types": "7.18.0",
+ "@typescript-eslint/typescript-estree": "7.18.0",
+ "@typescript-eslint/visitor-keys": "7.18.0",
"debug": "^4.3.4"
},
"engines": {
@@ -4452,12 +1936,14 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.18.0.tgz",
+ "integrity": "sha512-jjhdIE/FPF2B7Z1uzc6i3oWKbGcHb87Qw7AWj6jmEqNOfDFbJWtjt/XfwCpvNkpGWlcJaog5vTR+VV8+w9JflA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/types": "7.8.0",
- "@typescript-eslint/visitor-keys": "7.8.0"
+ "@typescript-eslint/types": "7.18.0",
+ "@typescript-eslint/visitor-keys": "7.18.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -4468,12 +1954,14 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.18.0.tgz",
+ "integrity": "sha512-XL0FJXuCLaDuX2sYqZUUSOJ2sG5/i1AAze+axqmLnSkNEVMVYLF+cbwlB2w8D1tinFuSikHmFta+P+HOofrLeA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/typescript-estree": "7.8.0",
- "@typescript-eslint/utils": "7.8.0",
+ "@typescript-eslint/typescript-estree": "7.18.0",
+ "@typescript-eslint/utils": "7.18.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
@@ -4494,7 +1982,9 @@
}
},
"node_modules/@typescript-eslint/types": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz",
+ "integrity": "sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -4506,12 +1996,14 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.18.0.tgz",
+ "integrity": "sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
- "@typescript-eslint/types": "7.8.0",
- "@typescript-eslint/visitor-keys": "7.8.0",
+ "@typescript-eslint/types": "7.18.0",
+ "@typescript-eslint/visitor-keys": "7.18.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@@ -4533,7 +2025,9 @@
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
- "version": "2.0.1",
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
+ "integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4541,11 +2035,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
- "version": "9.0.4",
+ "version": "9.0.9",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
+ "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
"dev": true,
"license": "ISC",
"dependencies": {
- "brace-expansion": "^2.0.1"
+ "brace-expansion": "^2.0.2"
},
"engines": {
"node": ">=16 || 14 >=14.17"
@@ -4554,18 +2050,30 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/@typescript-eslint/utils": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.18.0.tgz",
+ "integrity": "sha512-kK0/rNa2j74XuHVcoCZxdFBMF+aq/vH83CXAOHieC+2Gis4mF8jJXT5eAfyD3K0sAxtPuwxaIOIOvhwzVDt/kw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
- "@types/json-schema": "^7.0.15",
- "@types/semver": "^7.5.8",
- "@typescript-eslint/scope-manager": "7.8.0",
- "@typescript-eslint/types": "7.8.0",
- "@typescript-eslint/typescript-estree": "7.8.0",
- "semver": "^7.6.0"
+ "@typescript-eslint/scope-manager": "7.18.0",
+ "@typescript-eslint/types": "7.18.0",
+ "@typescript-eslint/typescript-estree": "7.18.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -4579,11 +2087,13 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz",
+ "integrity": "sha512-cDF0/Gf81QpY3xYyJKDV14Zwdmid5+uuENhjH2EqFaF0ni+yAyq/LzMaIJdhNJXZI7uLzwIlA+V7oWoyn6Curg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/types": "7.8.0",
+ "@typescript-eslint/types": "7.18.0",
"eslint-visitor-keys": "^3.4.3"
},
"engines": {
@@ -4595,24 +2105,16 @@
}
},
"node_modules/@ungap/structured-clone": {
- "version": "1.2.0",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz",
+ "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
"dev": true,
"license": "ISC"
},
- "node_modules/abort-controller": {
- "version": "3.0.0",
- "license": "MIT",
- "dependencies": {
- "event-target-shim": "^5.0.0"
- },
- "engines": {
- "node": ">=6.5"
- }
- },
"node_modules/acorn": {
- "version": "8.15.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
- "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
+ "version": "8.16.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
+ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
@@ -4632,6 +2134,8 @@
},
"node_modules/acorn-jsx": {
"version": "5.3.2",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
+ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"dev": true,
"license": "MIT",
"peerDependencies": {
@@ -4639,9 +2143,9 @@
}
},
"node_modules/acorn-walk": {
- "version": "8.3.4",
- "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
- "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
+ "version": "8.3.5",
+ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.5.tgz",
+ "integrity": "sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4651,27 +2155,10 @@
"node": ">=0.4.0"
}
},
- "node_modules/agent-base": {
- "version": "7.1.4",
- "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
- "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
- "license": "MIT",
- "engines": {
- "node": ">= 14"
- }
- },
- "node_modules/agentkeepalive": {
- "version": "4.5.0",
- "license": "MIT",
- "dependencies": {
- "humanize-ms": "^1.2.1"
- },
- "engines": {
- "node": ">= 8.0.0"
- }
- },
"node_modules/ajv": {
- "version": "6.12.6",
+ "version": "6.14.0",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
+ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4685,9 +2172,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
- "node_modules/ansi-color": {
- "version": "0.2.1"
- },
"node_modules/ansi-escapes": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
@@ -4704,21 +2188,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/ansi-escapes/node_modules/type-fest": {
- "version": "0.21.3",
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
- "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
- "dev": true,
- "license": "(MIT OR CC0-1.0)",
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/ansi-regex": {
"version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -4726,6 +2200,9 @@
},
"node_modules/ansi-styles": {
"version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
@@ -4760,28 +2237,21 @@
},
"node_modules/argparse": {
"version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0"
},
"node_modules/array-union": {
"version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
+ "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
- "node_modules/async": {
- "version": "3.2.6",
- "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
- "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/asynckit": {
- "version": "0.4.0",
- "license": "MIT"
- },
"node_modules/babel-jest": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz",
@@ -4838,16 +2308,6 @@
"node": ">=8"
}
},
- "node_modules/babel-plugin-istanbul/node_modules/semver": {
- "version": "6.3.1",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
- "dev": true,
- "license": "ISC",
- "bin": {
- "semver": "bin/semver.js"
- }
- },
"node_modules/babel-plugin-jest-hoist": {
"version": "29.6.3",
"resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz",
@@ -4865,9 +2325,9 @@
}
},
"node_modules/babel-preset-current-node-syntax": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz",
- "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.2.0.tgz",
+ "integrity": "sha512-E/VlAEzRrsLEb2+dv8yp3bo4scof3l9nR4lrld+Iy5NyVqgVYUJnDAmunkhPMisRI32Qc4iRiz425d8vM++2fg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4888,7 +2348,7 @@
"@babel/plugin-syntax-top-level-await": "^7.14.5"
},
"peerDependencies": {
- "@babel/core": "^7.0.0"
+ "@babel/core": "^7.0.0 || ^8.0.0-0"
}
},
"node_modules/babel-preset-jest": {
@@ -4910,11 +2370,15 @@
},
"node_modules/balanced-match": {
"version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true,
"license": "MIT"
},
"node_modules/base64-js": {
"version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
+ "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
@@ -4931,22 +2395,23 @@
],
"license": "MIT"
},
- "node_modules/bignumber.js": {
- "version": "9.3.1",
- "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz",
- "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==",
- "license": "MIT",
+ "node_modules/baseline-browser-mapping": {
+ "version": "2.10.13",
+ "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.13.tgz",
+ "integrity": "sha512-BL2sTuHOdy0YT1lYieUxTw/QMtPBC3pmlJC6xk8BBYVv6vcw3SGdKemQ+Xsx9ik2F/lYDO9tqsFQH1r9PFuHKw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "baseline-browser-mapping": "dist/cli.cjs"
+ },
"engines": {
- "node": "*"
+ "node": ">=6.0.0"
}
},
- "node_modules/bowser": {
- "version": "2.11.0",
- "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
- "integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
- },
"node_modules/brace-expansion": {
- "version": "1.1.11",
+ "version": "1.1.13",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz",
+ "integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4955,20 +2420,22 @@
}
},
"node_modules/braces": {
- "version": "3.0.2",
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "fill-range": "^7.0.1"
+ "fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/browserslist": {
- "version": "4.25.1",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.1.tgz",
- "integrity": "sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw==",
+ "version": "4.28.2",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
+ "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==",
"dev": true,
"funding": [
{
@@ -4986,10 +2453,11 @@
],
"license": "MIT",
"dependencies": {
- "caniuse-lite": "^1.0.30001726",
- "electron-to-chromium": "^1.5.173",
- "node-releases": "^2.0.19",
- "update-browserslist-db": "^1.1.3"
+ "baseline-browser-mapping": "^2.10.12",
+ "caniuse-lite": "^1.0.30001782",
+ "electron-to-chromium": "^1.5.328",
+ "node-releases": "^2.0.36",
+ "update-browserslist-db": "^1.2.3"
},
"bin": {
"browserslist": "cli.js"
@@ -5021,29 +2489,6 @@
"node-int64": "^0.4.0"
}
},
- "node_modules/buffer": {
- "version": "6.0.3",
- "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
- "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/feross"
- },
- {
- "type": "patreon",
- "url": "https://www.patreon.com/feross"
- },
- {
- "type": "consulting",
- "url": "https://feross.org/support"
- }
- ],
- "dependencies": {
- "base64-js": "^1.3.1",
- "ieee754": "^1.2.1"
- }
- },
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -5051,38 +2496,10 @@
"dev": true,
"license": "MIT"
},
- "node_modules/bufrw": {
- "version": "1.4.0",
- "dependencies": {
- "ansi-color": "^0.2.1",
- "error": "^7.0.0",
- "hexer": "^1.5.0",
- "xtend": "^4.0.0"
- },
- "engines": {
- "node": ">= 0.10.x"
- }
- },
- "node_modules/call-bind": {
- "version": "1.0.7",
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
- "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
- "dependencies": {
- "es-define-property": "^1.0.0",
- "es-errors": "^1.3.0",
- "function-bind": "^1.1.2",
- "get-intrinsic": "^1.2.4",
- "set-function-length": "^1.2.1"
- },
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/callsites": {
"version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
+ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -5100,9 +2517,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001726",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001726.tgz",
- "integrity": "sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw==",
+ "version": "1.0.30001784",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001784.tgz",
+ "integrity": "sha512-WU346nBTklUV9YfUl60fqRbU5ZqyXlqvo1SgigE1OAXK5bFL8LL9q1K7aap3N739l4BvNqnkm3YrGHiY9sfUQw==",
"dev": true,
"funding": [
{
@@ -5122,6 +2539,8 @@
},
"node_modules/chalk": {
"version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5162,11 +2581,16 @@
}
},
"node_modules/cjs-module-lexer": {
- "version": "1.3.1",
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz",
+ "integrity": "sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==",
"license": "MIT"
},
"node_modules/cliui": {
"version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
+ "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
+ "dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
@@ -5188,50 +2612,18 @@
"node": ">= 0.12.0"
}
},
- "node_modules/cohere-ai": {
- "version": "7.13.2",
- "resolved": "https://registry.npmjs.org/cohere-ai/-/cohere-ai-7.13.2.tgz",
- "integrity": "sha512-VCEzlwo/SYCBtDWpCTs9JsEn6jLAPxOvFcqdhT+urCl32hQhs1ENH20c5tvNPupTN/UdP8tkOPJdlrxfBRh5Yw==",
- "dependencies": {
- "@aws-sdk/client-sagemaker": "^3.583.0",
- "@aws-sdk/credential-providers": "^3.583.0",
- "@aws-sdk/protocol-http": "^3.374.0",
- "@aws-sdk/signature-v4": "^3.374.0",
- "form-data": "^4.0.0",
- "form-data-encoder": "^4.0.2",
- "formdata-node": "^6.0.3",
- "js-base64": "3.7.2",
- "node-fetch": "2.7.0",
- "qs": "6.11.2",
- "readable-stream": "^4.5.2",
- "url-join": "4.0.1"
- }
- },
- "node_modules/cohere-ai/node_modules/form-data-encoder": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-4.0.2.tgz",
- "integrity": "sha512-KQVhvhK8ZkWzxKxOr56CPulAhH3dobtuQ4+hNQ+HekH/Wp5gSOafqRAeTphQUJAIk0GBvHZgJ2ZGRWd5kphMuw==",
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/cohere-ai/node_modules/formdata-node": {
- "version": "6.0.3",
- "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-6.0.3.tgz",
- "integrity": "sha512-8e1++BCiTzUno9v5IZ2J6bv4RU+3UKDmqWUQD0MIMVCd9AdhWkO1gw57oo1mNEX1dMq2EGI+FbWz4B92pscSQg==",
- "engines": {
- "node": ">= 18"
- }
- },
"node_modules/collect-v8-coverage": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz",
- "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==",
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz",
+ "integrity": "sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw==",
"dev": true,
"license": "MIT"
},
"node_modules/color-convert": {
"version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
@@ -5242,20 +2634,15 @@
},
"node_modules/color-name": {
"version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true,
"license": "MIT"
},
- "node_modules/combined-stream": {
- "version": "1.0.8",
- "license": "MIT",
- "dependencies": {
- "delayed-stream": "~1.0.0"
- },
- "engines": {
- "node": ">= 0.8"
- }
- },
"node_modules/concat-map": {
"version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true,
"license": "MIT"
},
@@ -5296,7 +2683,9 @@
"license": "MIT"
},
"node_modules/cross-spawn": {
- "version": "7.0.3",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5309,9 +2698,9 @@
}
},
"node_modules/debug": {
- "version": "4.4.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
- "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
+ "version": "4.4.3",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@@ -5326,9 +2715,9 @@
}
},
"node_modules/dedent": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.6.0.tgz",
- "integrity": "sha512-F1Z+5UCFpmQUzJa11agbyPVMbpgT/qA3/SKyJ1jyBgm7dUcUEa8v9JwDkerSQXfakBwFljIxhOJqGkjUwZ9FSA==",
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.2.tgz",
+ "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==",
"dev": true,
"license": "MIT",
"peerDependencies": {
@@ -5342,6 +2731,8 @@
},
"node_modules/deep-is": {
"version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
+ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true,
"license": "MIT"
},
@@ -5355,29 +2746,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/define-data-property": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
- "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
- "dependencies": {
- "es-define-property": "^1.0.0",
- "es-errors": "^1.3.0",
- "gopd": "^1.0.1"
- },
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
- "node_modules/delayed-stream": {
- "version": "1.0.0",
- "license": "MIT",
- "engines": {
- "node": ">=0.4.0"
- }
- },
"node_modules/detect-newline": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz",
@@ -5389,9 +2757,9 @@
}
},
"node_modules/diff": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
- "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz",
+ "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
@@ -5410,6 +2778,8 @@
},
"node_modules/dir-glob": {
"version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
+ "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5421,6 +2791,8 @@
},
"node_modules/doctrine": {
"version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
+ "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@@ -5430,26 +2802,10 @@
"node": ">=6.0.0"
}
},
- "node_modules/ejs": {
- "version": "3.1.10",
- "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
- "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
- "dev": true,
- "license": "Apache-2.0",
- "dependencies": {
- "jake": "^10.8.5"
- },
- "bin": {
- "ejs": "bin/cli.js"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/electron-to-chromium": {
- "version": "1.5.178",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.178.tgz",
- "integrity": "sha512-wObbz/ar3Bc6e4X5vf0iO8xTN8YAjN/tgiAOJLr7yjYFtP9wAjq8Mb5h0yn6kResir+VYx2DXBj9NNobs0ETSA==",
+ "version": "1.5.330",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.330.tgz",
+ "integrity": "sha512-jFNydB5kFtYUobh4IkWUnXeyDbjf/r9gcUEXe1xcrcUxIGfTdzPXA+ld6zBRbwvgIGVzDll/LTIiDztEtckSnA==",
"dev": true,
"license": "ISC"
},
@@ -5468,48 +2824,26 @@
},
"node_modules/emoji-regex": {
"version": "8.0.0",
- "license": "MIT"
- },
- "node_modules/error": {
- "version": "7.0.2",
- "dependencies": {
- "string-template": "~0.2.1",
- "xtend": "~4.0.0"
- }
- },
- "node_modules/error-ex": {
- "version": "1.3.2",
- "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
- "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
- "license": "MIT",
- "dependencies": {
- "is-arrayish": "^0.2.1"
- }
- },
- "node_modules/es-define-property": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
- "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
- "dependencies": {
- "get-intrinsic": "^1.2.4"
- },
- "engines": {
- "node": ">= 0.4"
- }
+ "license": "MIT"
},
- "node_modules/es-errors": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
- "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
- "engines": {
- "node": ">= 0.4"
+ "node_modules/error-ex": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz",
+ "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-arrayish": "^0.2.1"
}
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -5517,6 +2851,8 @@
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -5527,15 +2863,18 @@
}
},
"node_modules/eslint": {
- "version": "8.57.0",
+ "version": "8.57.1",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
+ "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
+ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.4",
- "@eslint/js": "8.57.0",
- "@humanwhocodes/config-array": "^0.11.14",
+ "@eslint/js": "8.57.1",
+ "@humanwhocodes/config-array": "^0.13.0",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"@ungap/structured-clone": "^1.2.0",
@@ -5581,7 +2920,9 @@
}
},
"node_modules/eslint-config-prettier": {
- "version": "9.1.0",
+ "version": "9.1.2",
+ "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz",
+ "integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
"dev": true,
"license": "MIT",
"bin": {
@@ -5592,12 +2933,14 @@
}
},
"node_modules/eslint-plugin-prettier": {
- "version": "5.1.3",
+ "version": "5.5.5",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.5.tgz",
+ "integrity": "sha512-hscXkbqUZ2sPithAuLm5MXL+Wph+U7wHngPBv9OMWwlP8iaflyxpjTYZkmdgB4/vPIhemRlBEoLrH7UC1n7aUw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "prettier-linter-helpers": "^1.0.0",
- "synckit": "^0.8.6"
+ "prettier-linter-helpers": "^1.0.1",
+ "synckit": "^0.11.12"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
@@ -5608,7 +2951,7 @@
"peerDependencies": {
"@types/eslint": ">=8.0.0",
"eslint": ">=8.0.0",
- "eslint-config-prettier": "*",
+ "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0",
"prettier": ">=3.0.0"
},
"peerDependenciesMeta": {
@@ -5622,6 +2965,8 @@
},
"node_modules/eslint-scope": {
"version": "7.2.2",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
+ "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
@@ -5637,6 +2982,8 @@
},
"node_modules/eslint-visitor-keys": {
"version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
+ "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
"dev": true,
"license": "Apache-2.0",
"engines": {
@@ -5647,7 +2994,9 @@
}
},
"node_modules/eslint/node_modules/@eslint/js": {
- "version": "8.57.0",
+ "version": "8.57.1",
+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz",
+ "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==",
"dev": true,
"license": "MIT",
"engines": {
@@ -5656,6 +3005,8 @@
},
"node_modules/eslint/node_modules/globals": {
"version": "13.24.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
+ "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5668,8 +3019,23 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/eslint/node_modules/type-fest": {
+ "version": "0.20.2",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
+ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
+ "dev": true,
+ "license": "(MIT OR CC0-1.0)",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/espree": {
"version": "9.6.1",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz",
+ "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
@@ -5699,7 +3065,9 @@
}
},
"node_modules/esquery": {
- "version": "1.5.0",
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
+ "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -5711,6 +3079,8 @@
},
"node_modules/esrecurse": {
"version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
+ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
@@ -5722,6 +3092,8 @@
},
"node_modules/estraverse": {
"version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
+ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {
@@ -5730,27 +3102,14 @@
},
"node_modules/esutils": {
"version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
+ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.10.0"
}
},
- "node_modules/event-target-shim": {
- "version": "5.0.1",
- "license": "MIT",
- "engines": {
- "node": ">=6"
- }
- },
- "node_modules/events": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
- "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
- "engines": {
- "node": ">=0.8.x"
- }
- },
"node_modules/execa": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",
@@ -5801,24 +3160,24 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
- "node_modules/extend": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
- "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
- "license": "MIT"
- },
"node_modules/fast-deep-equal": {
"version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true,
"license": "MIT"
},
"node_modules/fast-diff": {
"version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
+ "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/fast-glob": {
- "version": "3.3.2",
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
+ "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5826,7 +3185,7 @@
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
- "micromatch": "^4.0.4"
+ "micromatch": "^4.0.8"
},
"engines": {
"node": ">=8.6.0"
@@ -5834,6 +3193,8 @@
},
"node_modules/fast-glob/node_modules/glob-parent": {
"version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -5845,37 +3206,22 @@
},
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"dev": true,
"license": "MIT"
},
"node_modules/fast-levenshtein": {
"version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
+ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true,
"license": "MIT"
},
- "node_modules/fast-xml-parser": {
- "version": "4.4.1",
- "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz",
- "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/NaturalIntelligence"
- },
- {
- "type": "paypal",
- "url": "https://paypal.me/naturalintelligence"
- }
- ],
- "dependencies": {
- "strnum": "^1.0.5"
- },
- "bin": {
- "fxparser": "src/cli/cli.js"
- }
- },
"node_modules/fastq": {
- "version": "1.17.1",
+ "version": "1.20.1",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz",
+ "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -5894,6 +3240,8 @@
},
"node_modules/file-entry-cache": {
"version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
+ "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5903,41 +3251,10 @@
"node": "^10.12.0 || >=12.0.0"
}
},
- "node_modules/filelist": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
- "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
- "dev": true,
- "license": "Apache-2.0",
- "dependencies": {
- "minimatch": "^5.0.1"
- }
- },
- "node_modules/filelist/node_modules/brace-expansion": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
- "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "balanced-match": "^1.0.0"
- }
- },
- "node_modules/filelist/node_modules/minimatch": {
- "version": "5.1.6",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
- "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
- "dev": true,
- "license": "ISC",
- "dependencies": {
- "brace-expansion": "^2.0.1"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/fill-range": {
- "version": "7.0.1",
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5949,6 +3266,8 @@
},
"node_modules/find-up": {
"version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5964,6 +3283,8 @@
},
"node_modules/flat-cache": {
"version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz",
+ "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5976,52 +3297,16 @@
}
},
"node_modules/flatted": {
- "version": "3.3.1",
+ "version": "3.4.2",
+ "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
+ "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
"dev": true,
"license": "ISC"
},
- "node_modules/form-data": {
- "version": "4.0.0",
- "license": "MIT",
- "dependencies": {
- "asynckit": "^0.4.0",
- "combined-stream": "^1.0.8",
- "mime-types": "^2.1.12"
- },
- "engines": {
- "node": ">= 6"
- }
- },
- "node_modules/form-data-encoder": {
- "version": "1.7.2",
- "license": "MIT"
- },
- "node_modules/formdata-node": {
- "version": "4.4.1",
- "license": "MIT",
- "dependencies": {
- "node-domexception": "1.0.0",
- "web-streams-polyfill": "4.0.0-beta.3"
- },
- "engines": {
- "node": ">= 12.20"
- }
- },
- "node_modules/formdata-node/node_modules/web-streams-polyfill": {
- "version": "4.0.0-beta.3",
- "license": "MIT",
- "engines": {
- "node": ">= 14"
- }
- },
- "node_modules/forwarded-parse": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/forwarded-parse/-/forwarded-parse-2.1.2.tgz",
- "integrity": "sha512-alTFZZQDKMporBH77856pXgzhEzaUVmLCDk+egLgIgHst3Tpndzz8MnKe+GzRJRfvVdn69HhpW7cmXzvtLvJAw==",
- "license": "MIT"
- },
"node_modules/fs.realpath": {
"version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"dev": true,
"license": "ISC"
},
@@ -6042,41 +3327,13 @@
},
"node_modules/function-bind": {
"version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/gaxios": {
- "version": "6.7.1",
- "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz",
- "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==",
- "license": "Apache-2.0",
- "dependencies": {
- "extend": "^3.0.2",
- "https-proxy-agent": "^7.0.1",
- "is-stream": "^2.0.0",
- "node-fetch": "^2.6.9",
- "uuid": "^9.0.1"
- },
- "engines": {
- "node": ">=14"
- }
- },
- "node_modules/gcp-metadata": {
- "version": "6.1.1",
- "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.1.1.tgz",
- "integrity": "sha512-a4tiq7E0/5fTjxPAaH4jpjkSv/uCaU2p5KC6HVGrvl0cDjA8iBZv4vv1gyzlmK0ZUKqwpOyQMKzZQe3lTit77A==",
- "license": "Apache-2.0",
- "dependencies": {
- "gaxios": "^6.1.1",
- "google-logging-utils": "^0.0.2",
- "json-bigint": "^1.0.0"
- },
- "engines": {
- "node": ">=14"
- }
- },
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@@ -6089,29 +3346,14 @@
},
"node_modules/get-caller-file": {
"version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+ "dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
- "node_modules/get-intrinsic": {
- "version": "1.2.4",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
- "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
- "dependencies": {
- "es-errors": "^1.3.0",
- "function-bind": "^1.1.2",
- "has-proto": "^1.0.1",
- "has-symbols": "^1.0.3",
- "hasown": "^2.0.0"
- },
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/get-package-type": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
@@ -6137,6 +3379,9 @@
},
"node_modules/glob": {
"version": "7.2.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
+ "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
+ "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -6156,6 +3401,8 @@
},
"node_modules/glob-parent": {
"version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
+ "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -6166,7 +3413,9 @@
}
},
"node_modules/globals": {
- "version": "15.1.0",
+ "version": "15.15.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz",
+ "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6178,6 +3427,8 @@
},
"node_modules/globby": {
"version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -6195,26 +3446,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/google-logging-utils": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-0.0.2.tgz",
- "integrity": "sha512-NEgUnEcBiP5HrPzufUkBzJOD/Sxsco3rLNo1F1TNf7ieU8ryUzBhqba8r756CjLX7rn3fHl6iLEwPYuqpoKgQQ==",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=14"
- }
- },
- "node_modules/gopd": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
- "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
- "dependencies": {
- "get-intrinsic": "^1.1.3"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@@ -6224,52 +3455,47 @@
},
"node_modules/graphemer": {
"version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
+ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true,
"license": "MIT"
},
- "node_modules/has-flag": {
- "version": "4.0.0",
+ "node_modules/handlebars": {
+ "version": "4.7.9",
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz",
+ "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==",
"dev": true,
"license": "MIT",
- "engines": {
- "node": ">=8"
- }
- },
- "node_modules/has-property-descriptors": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
- "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"dependencies": {
- "es-define-property": "^1.0.0"
+ "minimist": "^1.2.5",
+ "neo-async": "^2.6.2",
+ "source-map": "^0.6.1",
+ "wordwrap": "^1.0.0"
+ },
+ "bin": {
+ "handlebars": "bin/handlebars"
},
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
- "node_modules/has-proto": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
- "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
"engines": {
- "node": ">= 0.4"
+ "node": ">=0.4.7"
},
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
+ "optionalDependencies": {
+ "uglify-js": "^3.1.4"
}
},
- "node_modules/has-symbols": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
- "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
+ "node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "dev": true,
+ "license": "MIT",
"engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
+ "node": ">=8"
}
},
"node_modules/hasown": {
"version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
@@ -6278,21 +3504,6 @@
"node": ">= 0.4"
}
},
- "node_modules/hexer": {
- "version": "1.5.0",
- "dependencies": {
- "ansi-color": "^0.2.1",
- "minimist": "^1.1.0",
- "process": "^0.10.0",
- "xtend": "^4.0.0"
- },
- "bin": {
- "hexer": "cli.js"
- },
- "engines": {
- "node": ">= 0.10.x"
- }
- },
"node_modules/html-escaper": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
@@ -6300,19 +3511,6 @@
"dev": true,
"license": "MIT"
},
- "node_modules/https-proxy-agent": {
- "version": "7.0.6",
- "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
- "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
- "license": "MIT",
- "dependencies": {
- "agent-base": "^7.1.2",
- "debug": "4"
- },
- "engines": {
- "node": ">= 14"
- }
- },
"node_modules/human-signals": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
@@ -6323,34 +3521,10 @@
"node": ">=10.17.0"
}
},
- "node_modules/humanize-ms": {
- "version": "1.2.1",
- "license": "MIT",
- "dependencies": {
- "ms": "^2.0.0"
- }
- },
- "node_modules/ieee754": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
- "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/feross"
- },
- {
- "type": "patreon",
- "url": "https://www.patreon.com/feross"
- },
- {
- "type": "consulting",
- "url": "https://feross.org/support"
- }
- ]
- },
"node_modules/ignore": {
- "version": "5.3.1",
+ "version": "5.3.2",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
+ "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6358,7 +3532,9 @@
}
},
"node_modules/import-fresh": {
- "version": "3.3.0",
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
+ "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -6373,9 +3549,9 @@
}
},
"node_modules/import-in-the-middle": {
- "version": "1.14.2",
- "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.14.2.tgz",
- "integrity": "sha512-5tCuY9BV8ujfOpwtAGgsTx9CGUapcFMEEyByLv1B+v2+6DhAcw+Zr0nhQT7uwaZ7DiourxFEscghOR8e1aPLQw==",
+ "version": "1.15.0",
+ "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.15.0.tgz",
+ "integrity": "sha512-bpQy+CrsRmYmoPMAE/0G33iwRqwW4ouqdRg8jgbH3aKuCtOc8lxgmYXg2dMM92CRiGP660EtBcymH/eVUpCSaA==",
"license": "Apache-2.0",
"dependencies": {
"acorn": "^8.14.0",
@@ -6406,6 +3582,8 @@
},
"node_modules/imurmurhash": {
"version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
+ "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6414,6 +3592,9 @@
},
"node_modules/inflight": {
"version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
+ "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -6423,6 +3604,8 @@
},
"node_modules/inherits": {
"version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true,
"license": "ISC"
},
@@ -6434,10 +3617,15 @@
"license": "MIT"
},
"node_modules/is-core-module": {
- "version": "2.13.1",
+ "version": "2.16.1",
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
+ "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
"license": "MIT",
"dependencies": {
- "hasown": "^2.0.0"
+ "hasown": "^2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -6445,6 +3633,8 @@
},
"node_modules/is-extglob": {
"version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6453,6 +3643,9 @@
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -6470,6 +3663,8 @@
},
"node_modules/is-glob": {
"version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -6481,6 +3676,8 @@
},
"node_modules/is-number": {
"version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6489,6 +3686,8 @@
},
"node_modules/is-path-inside": {
"version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
+ "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6497,6 +3696,9 @@
},
"node_modules/is-stream": {
"version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -6507,6 +3709,8 @@
},
"node_modules/isexe": {
"version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true,
"license": "ISC"
},
@@ -6537,6 +3741,19 @@
"node": ">=10"
}
},
+ "node_modules/istanbul-lib-instrument/node_modules/semver": {
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/istanbul-lib-report": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",
@@ -6568,9 +3785,9 @@
}
},
"node_modules/istanbul-reports": {
- "version": "3.1.7",
- "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz",
- "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==",
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz",
+ "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -6581,46 +3798,6 @@
"node": ">=8"
}
},
- "node_modules/jaeger-client": {
- "version": "3.19.0",
- "license": "Apache-2.0",
- "dependencies": {
- "node-int64": "^0.4.0",
- "opentracing": "^0.14.4",
- "thriftrw": "^3.5.0",
- "uuid": "^8.3.2",
- "xorshift": "^1.1.1"
- },
- "engines": {
- "node": ">=10"
- }
- },
- "node_modules/jaeger-client/node_modules/uuid": {
- "version": "8.3.2",
- "license": "MIT",
- "bin": {
- "uuid": "dist/bin/uuid"
- }
- },
- "node_modules/jake": {
- "version": "10.9.2",
- "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz",
- "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==",
- "dev": true,
- "license": "Apache-2.0",
- "dependencies": {
- "async": "^3.2.3",
- "chalk": "^4.0.2",
- "filelist": "^1.0.4",
- "minimatch": "^3.1.2"
- },
- "bin": {
- "jake": "bin/cli.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/jest": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
@@ -7103,6 +4280,19 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
+ "node_modules/jest-snapshot/node_modules/semver": {
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/jest-util": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz",
@@ -7204,13 +4394,10 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
- "node_modules/js-base64": {
- "version": "3.7.2",
- "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.2.tgz",
- "integrity": "sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ=="
- },
"node_modules/js-tiktoken": {
- "version": "1.0.12",
+ "version": "1.0.21",
+ "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.21.tgz",
+ "integrity": "sha512-biOj/6M5qdgx5TKjDnFT1ymSpM5tbd3ylwDtrQvFQSu0Z7bBYko2dF+W/aUkXUPuk6IVpRxk/3Q2sHOzGlS36g==",
"license": "MIT",
"dependencies": {
"base64-js": "^1.5.1"
@@ -7224,7 +4411,9 @@
"license": "MIT"
},
"node_modules/js-yaml": {
- "version": "4.1.0",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
+ "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7247,17 +4436,10 @@
"node": ">=6"
}
},
- "node_modules/json-bigint": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
- "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
- "license": "MIT",
- "dependencies": {
- "bignumber.js": "^9.0.0"
- }
- },
"node_modules/json-buffer": {
"version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
+ "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==",
"dev": true,
"license": "MIT"
},
@@ -7270,11 +4452,15 @@
},
"node_modules/json-schema-traverse": {
"version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true,
"license": "MIT"
},
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
+ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"dev": true,
"license": "MIT"
},
@@ -7293,6 +4479,8 @@
},
"node_modules/keyv": {
"version": "4.5.4",
+ "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
+ "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7321,6 +4509,8 @@
},
"node_modules/levn": {
"version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
+ "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7340,6 +4530,8 @@
},
"node_modules/locate-path": {
"version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7349,14 +4541,8 @@
"node": ">=10"
},
"funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
- "node_modules/lodash.camelcase": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
- "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==",
- "license": "MIT"
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
},
"node_modules/lodash.memoize": {
"version": "4.1.2",
@@ -7367,11 +4553,15 @@
},
"node_modules/lodash.merge": {
"version": "4.6.2",
+ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
+ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true,
"license": "MIT"
},
"node_modules/long": {
- "version": "5.2.3",
+ "version": "5.3.2",
+ "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
+ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
"license": "Apache-2.0"
},
"node_modules/lru-cache": {
@@ -7400,6 +4590,19 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/make-dir/node_modules/semver": {
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
@@ -7426,6 +4629,8 @@
},
"node_modules/merge2": {
"version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
+ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7433,34 +4638,19 @@
}
},
"node_modules/micromatch": {
- "version": "4.0.5",
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "braces": "^3.0.2",
+ "braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
}
},
- "node_modules/mime-db": {
- "version": "1.52.0",
- "license": "MIT",
- "engines": {
- "node": ">= 0.6"
- }
- },
- "node_modules/mime-types": {
- "version": "2.1.35",
- "license": "MIT",
- "dependencies": {
- "mime-db": "1.52.0"
- },
- "engines": {
- "node": ">= 0.6"
- }
- },
"node_modules/mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
@@ -7472,7 +4662,9 @@
}
},
"node_modules/minimatch": {
- "version": "3.1.2",
+ "version": "3.1.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
+ "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -7484,6 +4676,9 @@
},
"node_modules/minimist": {
"version": "1.2.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
+ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
+ "dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -7503,52 +4698,29 @@
},
"node_modules/natural-compare": {
"version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
+ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true,
"license": "MIT"
},
- "node_modules/node-domexception": {
- "version": "1.0.0",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/jimmywarting"
- },
- {
- "type": "github",
- "url": "https://paypal.me/jimmywarting"
- }
- ],
- "license": "MIT",
- "engines": {
- "node": ">=10.5.0"
- }
- },
- "node_modules/node-fetch": {
- "version": "2.7.0",
- "license": "MIT",
- "dependencies": {
- "whatwg-url": "^5.0.0"
- },
- "engines": {
- "node": "4.x || >=6.0.0"
- },
- "peerDependencies": {
- "encoding": "^0.1.0"
- },
- "peerDependenciesMeta": {
- "encoding": {
- "optional": true
- }
- }
+ "node_modules/neo-async": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
+ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
+ "dev": true,
+ "license": "MIT"
},
"node_modules/node-int64": {
"version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
+ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
+ "dev": true,
"license": "MIT"
},
"node_modules/node-releases": {
- "version": "2.0.19",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz",
- "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==",
+ "version": "2.0.36",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.36.tgz",
+ "integrity": "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA==",
"dev": true,
"license": "MIT"
},
@@ -7575,19 +4747,10 @@
"node": ">=8"
}
},
- "node_modules/object-inspect": {
- "version": "1.13.2",
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz",
- "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==",
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/once": {
"version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -7610,32 +4773,10 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/openai": {
- "version": "4.47.1",
- "license": "Apache-2.0",
- "dependencies": {
- "@types/node": "^18.11.18",
- "@types/node-fetch": "^2.6.4",
- "abort-controller": "^3.0.0",
- "agentkeepalive": "^4.2.1",
- "form-data-encoder": "1.7.2",
- "formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7",
- "web-streams-polyfill": "^3.2.1"
- },
- "bin": {
- "openai": "bin/cli"
- }
- },
- "node_modules/opentracing": {
- "version": "0.14.7",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=0.10"
- }
- },
"node_modules/optionator": {
"version": "0.9.4",
+ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
+ "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7652,6 +4793,8 @@
},
"node_modules/p-limit": {
"version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7666,6 +4809,8 @@
},
"node_modules/p-locate": {
"version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7690,6 +4835,8 @@
},
"node_modules/parent-module": {
"version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
+ "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7720,6 +4867,8 @@
},
"node_modules/path-exists": {
"version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7728,6 +4877,8 @@
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7736,6 +4887,8 @@
},
"node_modules/path-key": {
"version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7744,47 +4897,20 @@
},
"node_modules/path-parse": {
"version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"license": "MIT"
},
"node_modules/path-type": {
"version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
+ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
- "node_modules/pg-int8": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
- "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
- "license": "ISC",
- "engines": {
- "node": ">=4.0.0"
- }
- },
- "node_modules/pg-protocol": {
- "version": "1.10.3",
- "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz",
- "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==",
- "license": "MIT"
- },
- "node_modules/pg-types": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
- "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
- "license": "MIT",
- "dependencies": {
- "pg-int8": "1.0.1",
- "postgres-array": "~2.0.0",
- "postgres-bytea": "~1.0.0",
- "postgres-date": "~1.0.4",
- "postgres-interval": "^1.1.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -7793,7 +4919,9 @@
"license": "ISC"
},
"node_modules/picomatch": {
- "version": "2.3.1",
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
+ "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7882,47 +5010,10 @@
"node": ">=8"
}
},
- "node_modules/postgres-array": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
- "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
- "license": "MIT",
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/postgres-bytea": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
- "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
- "license": "MIT",
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/postgres-date": {
- "version": "1.0.7",
- "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
- "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
- "license": "MIT",
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/postgres-interval": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
- "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
- "license": "MIT",
- "dependencies": {
- "xtend": "^4.0.0"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/prelude-ls": {
"version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
+ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true,
"license": "MIT",
"engines": {
@@ -7930,7 +5021,9 @@
}
},
"node_modules/prettier": {
- "version": "3.2.5",
+ "version": "3.8.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
+ "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
"dev": true,
"license": "MIT",
"bin": {
@@ -7944,7 +5037,9 @@
}
},
"node_modules/prettier-linter-helpers": {
- "version": "1.0.0",
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.1.tgz",
+ "integrity": "sha512-SxToR7P8Y2lWmv/kTzVLC1t/GDI2WGjMwNhLLE9qtH8Q13C+aEmuRlzDst4Up4s0Wc8sF2M+J57iB3cMLqftfg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -7982,12 +5077,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
- "node_modules/process": {
- "version": "0.10.1",
- "engines": {
- "node": ">= 0.6.0"
- }
- },
"node_modules/prompts": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
@@ -8003,7 +5092,9 @@
}
},
"node_modules/protobufjs": {
- "version": "7.3.0",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.4.tgz",
+ "integrity": "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==",
"hasInstallScript": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -8026,6 +5117,8 @@
},
"node_modules/punycode": {
"version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8049,22 +5142,10 @@
],
"license": "MIT"
},
- "node_modules/qs": {
- "version": "6.11.2",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz",
- "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==",
- "dependencies": {
- "side-channel": "^1.0.4"
- },
- "engines": {
- "node": ">=0.6"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/queue-microtask": {
"version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
+ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true,
"funding": [
{
@@ -8089,31 +5170,11 @@
"dev": true,
"license": "MIT"
},
- "node_modules/readable-stream": {
- "version": "4.5.2",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz",
- "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==",
- "dependencies": {
- "abort-controller": "^3.0.0",
- "buffer": "^6.0.3",
- "events": "^3.3.0",
- "process": "^0.11.10",
- "string_decoder": "^1.3.0"
- },
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- }
- },
- "node_modules/readable-stream/node_modules/process": {
- "version": "0.11.10",
- "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
- "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
- "engines": {
- "node": ">= 0.6.0"
- }
- },
"node_modules/require-directory": {
"version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@@ -8134,16 +5195,21 @@
}
},
"node_modules/resolve": {
- "version": "1.22.8",
+ "version": "1.22.11",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
+ "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==",
"license": "MIT",
"dependencies": {
- "is-core-module": "^2.13.0",
+ "is-core-module": "^2.16.1",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
+ "engines": {
+ "node": ">= 0.4"
+ },
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@@ -8173,6 +5239,8 @@
},
"node_modules/resolve-from": {
"version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
+ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8190,7 +5258,9 @@
}
},
"node_modules/reusify": {
- "version": "1.0.4",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
+ "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8200,6 +5270,9 @@
},
"node_modules/rimraf": {
"version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
+ "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
+ "deprecated": "Rimraf versions prior to v4 are no longer supported",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -8214,6 +5287,8 @@
},
"node_modules/run-parallel": {
"version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
+ "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"dev": true,
"funding": [
{
@@ -8234,54 +5309,20 @@
"queue-microtask": "^1.2.2"
}
},
- "node_modules/safe-buffer": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
- "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/feross"
- },
- {
- "type": "patreon",
- "url": "https://www.patreon.com/feross"
- },
- {
- "type": "consulting",
- "url": "https://feross.org/support"
- }
- ]
- },
"node_modules/semver": {
- "version": "7.6.1",
+ "version": "6.3.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
+ "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
- "node_modules/set-function-length": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
- "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
- "dependencies": {
- "define-data-property": "^1.1.4",
- "es-errors": "^1.3.0",
- "function-bind": "^1.1.2",
- "get-intrinsic": "^1.2.4",
- "gopd": "^1.0.1",
- "has-property-descriptors": "^1.0.2"
- },
- "engines": {
- "node": ">= 0.4"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -8293,29 +5334,14 @@
},
"node_modules/shebang-regex": {
"version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
- "node_modules/side-channel": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
- "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
- "dependencies": {
- "call-bind": "^1.0.7",
- "es-errors": "^1.3.0",
- "get-intrinsic": "^1.2.4",
- "object-inspect": "^1.13.1"
- },
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
@@ -8332,6 +5358,8 @@
},
"node_modules/slash": {
"version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8389,14 +5417,6 @@
"node": ">=8"
}
},
- "node_modules/string_decoder": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
- "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
- "dependencies": {
- "safe-buffer": "~5.2.0"
- }
- },
"node_modules/string-length": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz",
@@ -8411,11 +5431,11 @@
"node": ">=10"
}
},
- "node_modules/string-template": {
- "version": "0.2.1"
- },
"node_modules/string-width": {
"version": "4.2.3",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
+ "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
@@ -8428,6 +5448,9 @@
},
"node_modules/strip-ansi": {
"version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
@@ -8458,6 +5481,8 @@
},
"node_modules/strip-json-comments": {
"version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
+ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8467,13 +5492,10 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/strnum": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
- "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
- },
"node_modules/supports-color": {
"version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -8485,6 +5507,8 @@
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
@@ -8494,18 +5518,19 @@
}
},
"node_modules/synckit": {
- "version": "0.8.8",
+ "version": "0.11.12",
+ "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.12.tgz",
+ "integrity": "sha512-Bh7QjT8/SuKUIfObSXNHNSK6WHo6J1tHCqJsuaFDP7gP0fkzSfTxI8y85JrppZ0h8l0maIgc2tfuZQ6/t3GtnQ==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@pkgr/core": "^0.1.0",
- "tslib": "^2.6.2"
+ "@pkgr/core": "^0.2.9"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"funding": {
- "url": "https://opencollective.com/unts"
+ "url": "https://opencollective.com/synckit"
}
},
"node_modules/test-exclude": {
@@ -8525,34 +5550,11 @@
},
"node_modules/text-table": {
"version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
+ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true,
"license": "MIT"
},
- "node_modules/thriftrw": {
- "version": "3.11.4",
- "dependencies": {
- "bufrw": "^1.2.1",
- "error": "7.0.2",
- "long": "^2.4.0"
- },
- "bin": {
- "thrift2json": "thrift2json.js"
- },
- "engines": {
- "node": ">= 0.10.x"
- }
- },
- "node_modules/thriftrw/node_modules/long": {
- "version": "2.4.0",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=0.6"
- }
- },
- "node_modules/tiktoken": {
- "version": "1.0.15",
- "license": "MIT"
- },
"node_modules/tmpl": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
@@ -8562,6 +5564,8 @@
},
"node_modules/to-regex-range": {
"version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -8571,12 +5575,10 @@
"node": ">=8.0"
}
},
- "node_modules/tr46": {
- "version": "0.0.3",
- "license": "MIT"
- },
"node_modules/ts-api-utils": {
- "version": "1.3.0",
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz",
+ "integrity": "sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==",
"dev": true,
"license": "MIT",
"engines": {
@@ -8587,19 +5589,19 @@
}
},
"node_modules/ts-jest": {
- "version": "29.4.0",
- "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.0.tgz",
- "integrity": "sha512-d423TJMnJGu80/eSgfQ5w/R+0zFJvdtTxwtF9KzFFunOpSeD+79lHJQIiAhluJoyGRbvj9NZJsl9WjCUo0ND7Q==",
+ "version": "29.4.9",
+ "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.9.tgz",
+ "integrity": "sha512-LTb9496gYPMCqjeDLdPrKuXtncudeV1yRZnF4Wo5l3SFi0RYEnYRNgMrFIdg+FHvfzjCyQk1cLncWVqiSX+EvQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"bs-logger": "^0.2.6",
- "ejs": "^3.1.10",
"fast-json-stable-stringify": "^2.1.0",
+ "handlebars": "^4.7.9",
"json5": "^2.2.3",
"lodash.memoize": "^4.1.2",
"make-error": "^1.3.6",
- "semver": "^7.7.2",
+ "semver": "^7.7.4",
"type-fest": "^4.41.0",
"yargs-parser": "^21.1.1"
},
@@ -8616,7 +5618,7 @@
"babel-jest": "^29.0.0 || ^30.0.0",
"jest": "^29.0.0 || ^30.0.0",
"jest-util": "^29.0.0 || ^30.0.0",
- "typescript": ">=4.3 <6"
+ "typescript": ">=4.3 <7"
},
"peerDependenciesMeta": {
"@babel/core": {
@@ -8640,9 +5642,9 @@
}
},
"node_modules/ts-jest/node_modules/semver": {
- "version": "7.7.2",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
- "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"dev": true,
"license": "ISC",
"bin": {
@@ -8709,12 +5711,10 @@
}
}
},
- "node_modules/tslib": {
- "version": "2.6.2",
- "license": "0BSD"
- },
"node_modules/type-check": {
"version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
+ "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -8735,7 +5735,9 @@
}
},
"node_modules/type-fest": {
- "version": "0.20.2",
+ "version": "0.21.3",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
+ "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
"dev": true,
"license": "(MIT OR CC0-1.0)",
"engines": {
@@ -8746,9 +5748,9 @@
}
},
"node_modules/typescript": {
- "version": "5.8.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
- "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
+ "version": "5.9.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -8760,13 +5762,15 @@
}
},
"node_modules/typescript-eslint": {
- "version": "7.8.0",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.18.0.tgz",
+ "integrity": "sha512-PonBkP603E3tt05lDkbOMyaxJjvKqQrXsnow72sVeOFINDE/qNmnnd+f9b4N+U7W6MXnnYyrhtmF2t08QWwUbA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/eslint-plugin": "7.8.0",
- "@typescript-eslint/parser": "7.8.0",
- "@typescript-eslint/utils": "7.8.0"
+ "@typescript-eslint/eslint-plugin": "7.18.0",
+ "@typescript-eslint/parser": "7.18.0",
+ "@typescript-eslint/utils": "7.18.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -8784,14 +5788,30 @@
}
}
},
+ "node_modules/uglify-js": {
+ "version": "3.19.3",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
+ "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "optional": true,
+ "bin": {
+ "uglifyjs": "bin/uglifyjs"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ }
+ },
"node_modules/undici-types": {
- "version": "5.26.5",
+ "version": "7.18.2",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
+ "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
"license": "MIT"
},
"node_modules/update-browserslist-db": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz",
- "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==",
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
+ "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==",
"dev": true,
"funding": [
{
@@ -8821,28 +5841,14 @@
},
"node_modules/uri-js": {
"version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
+ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
"punycode": "^2.1.0"
}
},
- "node_modules/url-join": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
- "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
- },
- "node_modules/uuid": {
- "version": "9.0.1",
- "funding": [
- "https://github.com/sponsors/broofa",
- "https://github.com/sponsors/ctavan"
- ],
- "license": "MIT",
- "bin": {
- "uuid": "dist/bin/uuid"
- }
- },
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
@@ -8875,27 +5881,10 @@
"makeerror": "1.0.12"
}
},
- "node_modules/web-streams-polyfill": {
- "version": "3.3.3",
- "license": "MIT",
- "engines": {
- "node": ">= 8"
- }
- },
- "node_modules/webidl-conversions": {
- "version": "3.0.1",
- "license": "BSD-2-Clause"
- },
- "node_modules/whatwg-url": {
- "version": "5.0.0",
- "license": "MIT",
- "dependencies": {
- "tr46": "~0.0.3",
- "webidl-conversions": "^3.0.0"
- }
- },
"node_modules/which": {
"version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -8910,14 +5899,26 @@
},
"node_modules/word-wrap": {
"version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
+ "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
+ "node_modules/wordwrap": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
+ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/wrap-ansi": {
"version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+ "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
@@ -8933,6 +5934,8 @@
},
"node_modules/wrappy": {
"version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true,
"license": "ISC"
},
@@ -8950,19 +5953,11 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
- "node_modules/xorshift": {
- "version": "1.2.0",
- "license": "MIT"
- },
- "node_modules/xtend": {
- "version": "4.0.2",
- "license": "MIT",
- "engines": {
- "node": ">=0.4"
- }
- },
"node_modules/y18n": {
"version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
+ "dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
@@ -8977,6 +5972,9 @@
},
"node_modules/yargs": {
"version": "17.7.2",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
+ "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^8.0.1",
@@ -8993,6 +5991,9 @@
},
"node_modules/yargs-parser": {
"version": "21.1.1",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
+ "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
+ "dev": true,
"license": "ISC",
"engines": {
"node": ">=12"
@@ -9010,6 +6011,8 @@
},
"node_modules/yocto-queue": {
"version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
"dev": true,
"license": "MIT",
"engines": {
diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json
index 9612e06c..1506f545 100644
--- a/sdk/typescript/package.json
+++ b/sdk/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "openlit",
- "version": "1.11.0",
+ "version": "1.12.0",
"homepage": "https://github.com/openlit/openlit#readme",
"bugs": {
"url": "https://github.com/openlit/openlit/issues",
@@ -12,6 +12,7 @@
},
"scripts": {
"build": "tsc --build",
+ "lint": "eslint src/",
"test": "jest"
},
"files": [
@@ -57,19 +58,50 @@
"typescript-eslint": "^7.8.0"
},
"dependencies": {
- "@anthropic-ai/sdk": "^0.25.0",
"@opentelemetry/api": "^1.9.0",
- "@opentelemetry/auto-instrumentations-node": "^0.62.0",
- "@opentelemetry/exporter-jaeger": "^2.0.1",
+ "@opentelemetry/api-logs": "^0.214.0",
+ "@opentelemetry/exporter-logs-otlp-http": "^0.214.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.203.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
"@opentelemetry/instrumentation": "^0.203.0",
"@opentelemetry/resources": "^2.0.1",
- "@opentelemetry/sdk-trace-base": "^2.0.1",
+ "@opentelemetry/sdk-logs": "^0.214.0",
+ "@opentelemetry/sdk-metrics": "^2.6.1",
+ "@opentelemetry/sdk-trace-base": "^2.6.1",
"@opentelemetry/sdk-trace-node": "^2.0.1",
"@opentelemetry/semantic-conventions": "^1.36.0",
- "cohere-ai": "^7.13.0",
- "js-tiktoken": "^1.0.12",
- "openai": "^4.47.1",
- "tiktoken": "^1.0.15"
+ "js-tiktoken": "^1.0.12"
+ },
+ "peerDependencies": {
+ "@opentelemetry/instrumentation-express": ">=0.40.0",
+ "@opentelemetry/instrumentation-fastify": ">=0.38.0",
+ "@opentelemetry/instrumentation-hapi": ">=0.40.0",
+ "@opentelemetry/instrumentation-http": ">=0.50.0",
+ "@opentelemetry/instrumentation-koa": ">=0.42.0",
+ "@opentelemetry/instrumentation-nestjs-core": ">=0.39.0",
+ "@opentelemetry/instrumentation-undici": ">=0.1.0"
+ },
+ "peerDependenciesMeta": {
+ "@opentelemetry/instrumentation-http": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-undici": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-express": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-fastify": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-koa": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-hapi": {
+ "optional": true
+ },
+ "@opentelemetry/instrumentation-nestjs-core": {
+ "optional": true
+ }
}
}
diff --git a/sdk/typescript/src/config.ts b/sdk/typescript/src/config.ts
index 8a8f00b5..7690451e 100644
--- a/sdk/typescript/src/config.ts
+++ b/sdk/typescript/src/config.ts
@@ -1,4 +1,3 @@
-import OpenLitHelper from './helpers';
import { OpenlitConfigInterface, PricingObject } from './types';
export default class OpenlitConfig {
@@ -9,18 +8,12 @@ export default class OpenlitConfig {
static otlpEndpoint?: OpenlitConfigInterface['otlpEndpoint'];
static otlpHeaders?: OpenlitConfigInterface['otlpHeaders'];
static disableBatch?: OpenlitConfigInterface['disableBatch'];
- static traceContent?: OpenlitConfigInterface['traceContent'];
- static pricing_json?: OpenlitConfigInterface['pricing_json'];
-
- static async updatePricingJson(pricing_json: any) {
- try {
- const response = await OpenLitHelper.fetchPricingInfo(pricing_json);
- this.pricingInfo = response;
- } catch (e) {
- this.pricingInfo = {};
- }
- return this.pricingInfo;
- }
+ static captureMessageContent?: OpenlitConfigInterface['captureMessageContent'];
+ static pricingJson?: OpenlitConfigInterface['pricingJson'];
+ static disableMetrics?: boolean;
+ static disableEvents?: boolean;
+ static maxContentLength?: number | null;
+ static customSpanAttributes?: Record<string, string> | null;
static updateConfig({
environment = 'default',
@@ -28,17 +21,30 @@ export default class OpenlitConfig {
tracer,
otlpEndpoint,
otlpHeaders,
- disableBatch = true,
- traceContent = true,
- pricing_json,
- }: OpenlitConfigInterface) {
+ disableBatch = false,
+ captureMessageContent = true,
+ pricingJson,
+ disableMetrics = false,
+ disableEvents = false,
+ maxContentLength = null,
+ customSpanAttributes = null,
+ }: Partial<OpenlitConfigInterface> & {
+ disableMetrics?: boolean;
+ disableEvents?: boolean;
+ maxContentLength?: number | null;
+ customSpanAttributes?: Record<string, string> | null;
+ }) {
this.environment = environment;
this.applicationName = applicationName;
- this.tracer = tracer;
+ this.tracer = tracer as OpenlitConfigInterface['tracer'];
this.otlpEndpoint = otlpEndpoint;
this.otlpHeaders = otlpHeaders;
this.disableBatch = disableBatch;
- this.traceContent = traceContent;
- this.pricing_json = pricing_json;
+ this.captureMessageContent = captureMessageContent;
+ this.pricingJson = pricingJson;
+ this.disableMetrics = disableMetrics;
+ this.disableEvents = disableEvents;
+ this.maxContentLength = maxContentLength;
+ this.customSpanAttributes = customSpanAttributes;
}
}
diff --git a/sdk/typescript/src/evals/llm/anthropic.ts b/sdk/typescript/src/evals/llm/anthropic.ts
index f31dee50..1af70878 100644
--- a/sdk/typescript/src/evals/llm/anthropic.ts
+++ b/sdk/typescript/src/evals/llm/anthropic.ts
@@ -1,5 +1,3 @@
-import Anthropic from '@anthropic-ai/sdk';
-
export async function llmResponseAnthropic({
prompt,
model,
@@ -9,6 +7,15 @@ export async function llmResponseAnthropic({
model?: string;
apiKey?: string;
}): Promise<string> {
+ let Anthropic: any;
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ Anthropic = require('@anthropic-ai/sdk').default;
+ } catch {
+ throw new Error(
+ "openlit eval features require the '@anthropic-ai/sdk' package. Install it with: npm install @anthropic-ai/sdk"
+ );
+ }
const client = new Anthropic({ apiKey });
const usedModel = model || 'claude-3-opus-20240229';
const response = await client.messages.create({
@@ -32,7 +39,7 @@ export async function llmResponseAnthropic({
// Fallback: join all text blocks that have text
return response.content
.filter((p: { type: string; text?: unknown }) : p is { type: 'text'; text: string } => p.type === 'text' && typeof p.text === 'string')
- .map(p => p.text)
+ .map((p: { text: string }) => p.text)
.join(' ');
}
return '';
diff --git a/sdk/typescript/src/evals/llm/openai.ts b/sdk/typescript/src/evals/llm/openai.ts
index f5c435ec..7ba13f86 100644
--- a/sdk/typescript/src/evals/llm/openai.ts
+++ b/sdk/typescript/src/evals/llm/openai.ts
@@ -1,5 +1,3 @@
-import OpenAI from 'openai';
-
export async function llmResponseOpenAI({
prompt,
model,
@@ -11,6 +9,15 @@ export async function llmResponseOpenAI({
apiKey?: string;
baseUrl?: string;
}): Promise<string> {
+ let OpenAI: any;
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ OpenAI = require('openai').default;
+ } catch {
+ throw new Error(
+ "openlit eval features require the 'openai' package. Install it with: npm install openai"
+ );
+ }
const client = new OpenAI({
apiKey,
baseURL: baseUrl || 'https://api.openai.com/v1',
diff --git a/sdk/typescript/src/features/vault.ts b/sdk/typescript/src/features/vault.ts
index 497a5aef..c289312a 100644
--- a/sdk/typescript/src/features/vault.ts
+++ b/sdk/typescript/src/features/vault.ts
@@ -38,7 +38,7 @@ export default class Vault {
});
const { res = {} } = vaultResponse;
- if (!!options.shouldSetEnv) {
+ if (options.shouldSetEnv) {
Object.entries(res).forEach(([key, value]: [string, unknown]) => {
process.env[key] = value as string;
});
diff --git a/sdk/typescript/src/helpers.ts b/sdk/typescript/src/helpers.ts
index 0434ca39..2f0f0ee5 100644
--- a/sdk/typescript/src/helpers.ts
+++ b/sdk/typescript/src/helpers.ts
@@ -1,5 +1,222 @@
import { encodingForModel, TiktokenModel } from 'js-tiktoken';
-import { Span, SpanStatusCode } from '@opentelemetry/api';
+import { Attributes, Context, Span, SpanStatusCode, context as otelContext, trace } from '@opentelemetry/api';
+import { SeverityNumber } from '@opentelemetry/api-logs';
+import { AsyncLocalStorage } from 'async_hooks';
+import SemanticConvention from './semantic-convention';
+import Events from './otel/events';
+import OpenlitConfig from './config';
+
+/**
+ * AsyncLocalStorage for context-scoped custom span attributes.
+ * Mirrors Python's ContextVar _custom_span_attributes, used by
+ * usingAttributes() and injectAdditionalAttributes().
+ */
+const _customSpanAttributes = new AsyncLocalStorage<Record<string, any>>();
+
+// ---------------------------------------------------------------------------
+// Framework LLM span suppression flags (mirrors Python SDK ContextVars)
+// ---------------------------------------------------------------------------
+
+const _frameworkLlmActive = new AsyncLocalStorage<boolean>();
+
+/**
+ * Returns true when a framework instrumentor (LangChain, LiteLLM, etc.)
+ * owns the current LLM span. Provider-level wrappers (OpenAI, Anthropic, …)
+ * must skip their own span creation when this returns true.
+ */
+export function isFrameworkLlmActive(): boolean {
+ return _frameworkLlmActive.getStore() === true;
+}
+
+/**
+ * Run `fn` with the framework-LLM-active flag set. All provider wrappers
+ * invoked inside `fn` will see `isFrameworkLlmActive() === true`.
+ */
+export function runWithFrameworkLlm<T>(fn: () => T): T {
+ return _frameworkLlmActive.run(true, fn);
+}
+
+/**
+ * Set framework-LLM-active flag in the current execution context.
+ * Used by SpanProcessor-based instrumentations (Strands) where
+ * the processor observes spans rather than controlling execution.
+ * Mirrors Python's ContextVar.set(True) in Strands processor.
+ */
+export function setFrameworkLlmActive(): void {
+ _frameworkLlmActive.enterWith(true);
+}
+
+/**
+ * Reset framework-LLM-active flag in the current execution context.
+ * Mirrors Python's ContextVar.reset(token) in Strands processor.
+ */
+export function resetFrameworkLlmActive(): void {
+ _frameworkLlmActive.enterWith(false);
+}
+
+const _langGraphActive = new AsyncLocalStorage<boolean>();
+
+/**
+ * Returns true when a LangGraph wrapper is controlling execution.
+ * LangChain's callback handler skips its own invoke_workflow span when true.
+ */
+export function isLangGraphActive(): boolean {
+ return _langGraphActive.getStore() === true;
+}
+
+export function runWithLangGraph<T>(fn: () => T): T {
+ return _langGraphActive.run(true, fn);
+}
+
+const _createAgentActive = new AsyncLocalStorage<boolean>();
+
+/**
+ * Returns true when a create_agent span is already being handled
+ * (prevents duplicate spans between LangChain and LangGraph).
+ */
+export function isCreateAgentActive(): boolean {
+ return _createAgentActive.getStore() === true;
+}
+
+export function runWithCreateAgent<T>(fn: () => T): T {
+ return _createAgentActive.run(true, fn);
+}
+
+const _langGraphConversationId = new AsyncLocalStorage<string>();
+
+/**
+ * Propagate conversation ID from invoke_workflow to child node spans.
+ * Mirrors Python's set_langgraph_conversation_id / get_langgraph_conversation_id.
+ */
+export function getLangGraphConversationId(): string | undefined {
+ return _langGraphConversationId.getStore();
+}
+
+export function runWithLangGraphConversationId<T>(conversationId: string, fn: () => T): T {
+ return _langGraphConversationId.run(conversationId, fn);
+}
+
+// ---------------------------------------------------------------------------
+// Framework parent context propagation (mirrors Python context_api.attach)
+// ---------------------------------------------------------------------------
+
+const _frameworkParentContext = new AsyncLocalStorage<Context>();
+
+/**
+ * Returns the OTel context set by a framework processor (OpenAI Agents, etc.)
+ * so that provider wrappers can create spans as children of framework spans.
+ * Mirrors Python's context_api.attach(set_span_in_context(span)).
+ */
+export function getFrameworkParentContext(): Context | undefined {
+ return _frameworkParentContext.getStore() || undefined;
+}
+
+/**
+ * Set the OTel parent context for provider span creation.
+ * Called by processor-based frameworks that cannot use context.with().
+ */
+export function setFrameworkParentContext(ctx: Context): void {
+ _frameworkParentContext.enterWith(ctx);
+}
+
+/**
+ * Clear the framework parent context.
+ */
+export function clearFrameworkParentContext(): void {
+ _frameworkParentContext.enterWith(undefined as any);
+}
+
+// ---------------------------------------------------------------------------
+// Provider default endpoints (mirrors Python PROVIDER_DEFAULT_ENDPOINTS)
+// ---------------------------------------------------------------------------
+
+const PROVIDER_DEFAULT_ENDPOINTS: Record<string, [string, number]> = {
+ openai: ['api.openai.com', 443],
+ anthropic: ['api.anthropic.com', 443],
+ google: ['generativelanguage.googleapis.com', 443],
+ 'gcp.gemini': ['generativelanguage.googleapis.com', 443],
+ 'gcp.vertex_ai': ['aiplatform.googleapis.com', 443],
+ mistral_ai: ['api.mistral.ai', 443],
+ groq: ['api.groq.com', 443],
+ together: ['api.together.xyz', 443],
+ fireworks: ['api.fireworks.ai', 443],
+ perplexity: ['api.perplexity.ai', 443],
+ deepinfra: ['api.deepinfra.com', 443],
+ 'aws.bedrock': ['bedrock-runtime.amazonaws.com', 443],
+ azure: ['openai.azure.com', 443],
+ 'azure.ai.openai': ['openai.azure.com', 443],
+ 'azure.ai.inference': ['inference.ai.azure.com', 443],
+ cohere: ['api.cohere.ai', 443],
+ ollama: ['localhost', 11434],
+ deepseek: ['api.deepseek.com', 443],
+ x_ai: ['api.x.ai', 443],
+ huggingface: ['api-inference.huggingface.co', 443],
+};
+
+export function getServerAddressForProvider(provider: string): [string, number] {
+ return PROVIDER_DEFAULT_ENDPOINTS[provider] || ['', 0];
+}
+
+/**
+ * Apply global (from init) and context-scoped (from usingAttributes /
+ * injectAdditionalAttributes) custom attributes to a span.
+ * Global attributes are applied first; context attributes override on conflict.
+ * Matches Python's _apply_custom_span_attributes().
+ */
+export function applyCustomSpanAttributes(span: Span): void {
+ const globalAttrs = OpenlitConfig.customSpanAttributes;
+ if (globalAttrs) {
+ for (const [key, value] of Object.entries(globalAttrs)) {
+ span.setAttribute(key, value);
+ }
+ }
+ const contextAttrs = _customSpanAttributes.getStore();
+ if (contextAttrs) {
+ for (const [key, value] of Object.entries(contextAttrs)) {
+ span.setAttribute(key, value);
+ }
+ }
+}
+
+/**
+ * Get merged custom attributes (global + context) for use in events.
+ * Returns a flat object; context attributes override global on conflict.
+ */
+export function getMergedCustomAttributes(): Record<string, any> {
+ const merged: Record<string, any> = {};
+ const globalAttrs = OpenlitConfig.customSpanAttributes;
+ if (globalAttrs) {
+ Object.assign(merged, globalAttrs);
+ }
+ const contextAttrs = _customSpanAttributes.getStore();
+ if (contextAttrs) {
+ Object.assign(merged, contextAttrs);
+ }
+ return merged;
+}
+
+/**
+ * Run a function with custom span attributes attached to all
+ * auto-instrumented spans created during its execution.
+ * Matches Python's openlit.inject_additional_attributes().
+ */
+export function injectAdditionalAttributes<T>(fn: () => T, attributes: Record<string, any>): T {
+ return _customSpanAttributes.run(attributes, fn);
+}
+
+/**
+ * Context wrapper that adds custom attributes to all auto-instrumented
+ * spans created within its callback scope.
+ * Matches Python's openlit.using_attributes() context manager.
+ *
+ * Usage:
+ * await usingAttributes({"user.id": "u1", "team": "ml"}, async () => {
+ * await client.chat.completions.create(...);
+ * });
+ */
+export function usingAttributes<T>(attributes: Record<string, any>, fn: () => T): T {
+ return _customSpanAttributes.run(attributes, fn);
+}
export default class OpenLitHelper {
static readonly PROMPT_TOKEN_FACTOR = 1000;
@@ -25,24 +242,34 @@ export default class OpenLitHelper {
completionTokens: number
): number {
try {
- const cost = (
- (promptTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) * pricingInfo.chat[model].promptPrice +
- (completionTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) *
- pricingInfo.chat[model].completionPrice
- );
+ const chatPricing = pricingInfo?.chat;
+ if (!chatPricing) return 0;
+ let modelPricing = chatPricing[model];
+ if (modelPricing == null && model.includes('/')) {
+ modelPricing = chatPricing[model.split('/', 2)[1]];
+ }
+ if (modelPricing == null) return 0;
+ const cost =
+ (promptTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) * modelPricing.promptPrice +
+ (completionTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) * modelPricing.completionPrice;
return isNaN(cost) ? 0 : cost;
- } catch (error) {
- console.error(`Error in getChatModelCost: ${error}`);
+ } catch {
return 0;
}
}
static getEmbedModelCost(model: string, pricingInfo: any, promptTokens: number): number {
try {
- const cost = (promptTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) * pricingInfo.embeddings[model];
+ const embedPricing = pricingInfo?.embeddings;
+ if (!embedPricing) return 0;
+ let unitCost = embedPricing[model];
+ if (unitCost == null && model.includes('/')) {
+ unitCost = embedPricing[model.split('/', 2)[1]];
+ }
+ if (unitCost == null) return 0;
+ const cost = (promptTokens / OpenLitHelper.PROMPT_TOKEN_FACTOR) * unitCost;
return isNaN(cost) ? 0 : cost;
- } catch (error) {
- console.error(`Error in getEmbedModelCost: ${error}`);
+ } catch {
return 0;
}
}
@@ -205,9 +432,52 @@ export default class OpenLitHelper {
}
}
+ /**
+ * Emit an inference event via the LoggerProvider, matching Python SDK's
+ * gen_ai.client.inference.operation.details event.
+ * Falls back to span.addEvent if LoggerProvider is not available.
+ */
+ static emitInferenceEvent(
+ span: Span,
+ attrs: Attributes
+ ): void {
+ const eventAttributes: Attributes = {};
+
+ const customAttrs = getMergedCustomAttributes();
+ for (const [key, value] of Object.entries(customAttrs)) {
+ if (value !== undefined && value !== null) {
+ eventAttributes[key] = value;
+ }
+ }
+
+ for (const [key, value] of Object.entries(attrs)) {
+ if (value !== undefined && value !== null) {
+ eventAttributes[key] = value;
+ }
+ }
+
+ if (Events.logger) {
+ Events.logger.emit({
+ eventName: SemanticConvention.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS,
+ context: trace.setSpan(otelContext.active(), span),
+ severityNumber: SeverityNumber.INFO,
+ severityText: 'INFO',
+ body: SemanticConvention.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS,
+ attributes: {
+ ...eventAttributes,
+ 'event.name': SemanticConvention.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS,
+ },
+ });
+ } else {
+ span.addEvent(SemanticConvention.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS, eventAttributes);
+ }
+ }
+
static handleException(span: Span, error: Error): void {
span.recordException(error);
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
+ const errorType = error.constructor?.name || '_OTHER';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
}
static async createStreamProxy (stream: any, generatorFuncResponse: any): Promise<any> {
diff --git a/sdk/typescript/src/index.ts b/sdk/typescript/src/index.ts
index d6ecafb5..9f04545d 100644
--- a/sdk/typescript/src/index.ts
+++ b/sdk/typescript/src/index.ts
@@ -1,11 +1,14 @@
import { resourceFromAttributes } from '@opentelemetry/resources';
import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
-import { NodeSDK } from '@opentelemetry/sdk-node';
-import { OpenlitOptions } from './types';
+import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
+import { OpenlitOptions, ResolvedOptions } from './types';
import Tracing from './otel/tracing';
+import Events from './otel/events';
import { DEFAULT_APPLICATION_NAME, DEFAULT_ENVIRONMENT, SDK_NAME } from './constant';
-import { SpanExporter } from '@opentelemetry/sdk-trace-base';
import BaseOpenlit from './features/base';
+import OpenlitConfig from './config';
+import OpenLitHelper from './helpers';
+import { usingAttributes, injectAdditionalAttributes } from './helpers';
import { Hallucination, Bias, Toxicity, All } from './evals';
import Metrics from './otel/metrics';
import SemanticConvention from './semantic-convention';
@@ -13,8 +16,8 @@ import { PromptInjection } from './guard/prompt-injection';
import { SensitiveTopic } from './guard/sensitive-topic';
import { TopicRestriction } from './guard/topic-restriction';
import { All as GuardAll } from './guard/all';
+import { parseBoolEnv } from './otel/utils';
-// Factory functions for evals
const evals = {
Hallucination: (options: ConstructorParameters<typeof Hallucination>[0]) =>
new Hallucination(options),
@@ -23,7 +26,6 @@ const evals = {
All: (options: ConstructorParameters<typeof All>[0]) => new All(options),
};
-// Factory functions for guards
const guard = {
PromptInjection: (options: ConstructorParameters<typeof PromptInjection>[0]) => new PromptInjection(options),
SensitiveTopic: (options: ConstructorParameters<typeof SensitiveTopic>[0]) => new SensitiveTopic(options),
@@ -31,77 +33,127 @@ const guard = {
All: (options: ConstructorParameters<typeof GuardAll>[0]) => new GuardAll(options),
};
+/**
+ * Resolve OpenlitOptions into a single ResolvedOptions object.
+ * Precedence: arg > env var > default.
+ */
+function resolveOptions(options?: OpenlitOptions): ResolvedOptions {
+ const o = options || {};
+
+ const environment = o.environment ?? DEFAULT_ENVIRONMENT;
+ const applicationName = o.applicationName ?? DEFAULT_APPLICATION_NAME;
+
+ const rawEndpoint =
+ o.otlpEndpoint ??
+ process.env.OTEL_EXPORTER_OTLP_ENDPOINT ??
+ undefined;
+
+ const otlpEndpoint = rawEndpoint
+ ? rawEndpoint.replace(/\/v1\/traces$/, '')
+ : undefined;
+
+ let otlpHeaders = o.otlpHeaders ?? undefined;
+ if (!otlpHeaders && process.env.OTEL_EXPORTER_OTLP_HEADERS) {
+ otlpHeaders = process.env.OTEL_EXPORTER_OTLP_HEADERS.split(',').reduce(
+ (acc: Record<string, string>, item: string) => {
+ const keyVal = item.split('=');
+ acc[keyVal[0]] = keyVal[1];
+ return acc;
+ },
+ {} as Record<string, string>
+ );
+ }
+ if (!otlpHeaders) otlpHeaders = {};
+
+ let disableBatch = o.disableBatch ?? undefined;
+ const envDisableBatch = parseBoolEnv('OPENLIT_DISABLE_BATCH');
+ if (disableBatch === undefined) {
+ disableBatch = envDisableBatch ?? false;
+ }
+
+ let captureMessageContent = o.captureMessageContent ?? undefined;
+ const envCapture = parseBoolEnv('OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT');
+ if (captureMessageContent === undefined) {
+ captureMessageContent = envCapture ?? true;
+ }
+
+ let disableMetrics = o.disableMetrics ?? undefined;
+ const envDisableMetrics = parseBoolEnv('OPENLIT_DISABLE_METRICS');
+ if (disableMetrics === undefined) {
+ disableMetrics = envDisableMetrics ?? false;
+ }
+
+ let disableEvents = o.disableEvents ?? undefined;
+ const envDisableEvents = parseBoolEnv('OPENLIT_DISABLE_EVENTS');
+ if (disableEvents === undefined) {
+ disableEvents = envDisableEvents ?? false;
+ }
+
+ return {
+ environment,
+ applicationName,
+ tracer: o.tracer,
+ otlpEndpoint,
+ otlpHeaders,
+ disableBatch,
+ captureMessageContent,
+ disabledInstrumentors: o.disabledInstrumentors,
+ instrumentations: o.instrumentations,
+ disableMetrics,
+ disableEvents,
+ pricingJson: o.pricingJson,
+ maxContentLength: o.maxContentLength ?? null,
+ customSpanAttributes: o.customSpanAttributes ?? null,
+ };
+}
+
class Openlit extends BaseOpenlit {
static resource: ReturnType<typeof resourceFromAttributes>;
- static options: OpenlitOptions;
- static _sdk: NodeSDK;
+ static options: ResolvedOptions;
static evals = evals;
static guard = guard;
+
static init(options?: OpenlitOptions) {
try {
- const { environment = DEFAULT_ENVIRONMENT, applicationName = DEFAULT_APPLICATION_NAME } =
- options || {};
-
- const otlpEndpoint =
- (options?.otlpEndpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318").replace(/\/v1\/traces$/, '');
-
- let otlpHeaders = options?.otlpHeaders;
- if (!otlpHeaders) {
- if (process.env.OTEL_EXPORTER_OTLP_HEADERS) {
- otlpHeaders = process.env.OTEL_EXPORTER_OTLP_HEADERS.split(',').reduce(
- (acc: Record<string, string>, items: string) => {
- const keyVal: string[] = items.split('=');
- acc[keyVal[0]] = keyVal[1];
- return acc;
- },
- {} as Record<string, string>
- );
- } else {
- otlpHeaders = {};
- }
- }
+ // Enable OTel diagnostic logging so exporter errors (connection refused,
+ // 404, timeouts) are surfaced to the user — matches Python SDK behavior.
+ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.WARN);
- this.options = options || {};
- this.options.otlpEndpoint = otlpEndpoint;
- this.options.otlpHeaders = otlpHeaders;
- this.options.disableBatch =
- options?.disableBatch === undefined ? true : !!options.disableBatch;
+ const resolved = resolveOptions(options);
+ this.options = resolved;
this.resource = resourceFromAttributes({
- [ATTR_SERVICE_NAME]: applicationName,
- [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: environment,
+ [ATTR_SERVICE_NAME]: resolved.applicationName,
+ [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: resolved.environment,
[ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
});
- Tracing.setup({
- ...this.options,
- environment,
- applicationName,
- otlpEndpoint,
- otlpHeaders,
+ const setupBase = {
+ ...resolved,
resource: this.resource,
- });
- const exportIntervalMillis =
- Number(process.env.OTEL_EXPORTER_OTLP_METRICS_EXPORT_INTERVAL ?? 60000) || 60000;
-
- Metrics.setup({
- ...options,
- environment,
- applicationName,
- otlpEndpoint,
- otlpHeaders,
- resource: this.resource,
- exportIntervalMillis: exportIntervalMillis,
- });
+ };
- this._sdk = new NodeSDK({
- resource: this.resource,
- traceExporter: Tracing.traceExporter as SpanExporter,
- metricReader: Metrics.metricReaders[0],
- });
+ Tracing.setup(setupBase);
+
+ if (!resolved.disableEvents) {
+ Events.setup(setupBase);
+ }
+
+ if (!resolved.disableMetrics) {
+ const exportIntervalMillis =
+ Number(process.env.OTEL_EXPORTER_OTLP_METRICS_EXPORT_INTERVAL ?? 60000) || 60000;
- // This was causing the traceProvider initilization with multiple instances.
- // this._sdk.start();
+ Metrics.setup({
+ ...setupBase,
+ exportIntervalMillis,
+ });
+ }
+
+ // Fetch pricing info once and cache — matches Python SDK behavior.
+ OpenLitHelper.fetchPricingInfo(resolved.pricingJson).then(
+ (info) => { OpenlitConfig.pricingInfo = info; },
+ () => { OpenlitConfig.pricingInfo = {}; }
+ );
} catch (e) {
console.log('Connection time out', e);
}
@@ -111,8 +163,13 @@ class Openlit extends BaseOpenlit {
const openlit = Openlit as typeof Openlit & {
evals: typeof evals;
guard: typeof guard;
+ usingAttributes: typeof usingAttributes;
+ injectAdditionalAttributes: typeof injectAdditionalAttributes;
};
+(openlit as any).usingAttributes = usingAttributes;
+(openlit as any).injectAdditionalAttributes = injectAdditionalAttributes;
+
export default openlit;
-export { Openlit };
+export { Openlit, usingAttributes, injectAdditionalAttributes };
export type { OpenlitOptions } from './types';
diff --git a/sdk/typescript/src/instrumentation/__tests__/anthropic-wrapper.test.ts b/sdk/typescript/src/instrumentation/__tests__/anthropic-wrapper.test.ts
index b948a48d..a88f593e 100644
--- a/sdk/typescript/src/instrumentation/__tests__/anthropic-wrapper.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/anthropic-wrapper.test.ts
@@ -26,89 +26,340 @@ describe('AnthropicWrapper', () => {
describe('_messageCreate', () => {
it('should call recordMetrics after span ends', async () => {
- const mockArgs = [{ message: 'test message' }];
- const mockResponse = { response_id: '123', meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } } };
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [{ role: 'user', content: 'test' }] }];
+ const mockResponse = {
+ id: 'msg_123',
+ model: 'claude-3-5-sonnet-latest',
+ content: [{ type: 'text', text: 'Hello' }],
+ stop_reason: 'end_turn',
+ usage: { input_tokens: 10, output_tokens: 20 },
+ };
jest.spyOn(BaseWrapper, 'recordMetrics').mockImplementation(() => {});
jest.spyOn(AnthropicWrapper, '_messageCreateCommonSetter').mockImplementationOnce(async ({ genAIEndpoint, span }) => {
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, '123');
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, 'msg_123');
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 10);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 30);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
return {
genAIEndpoint,
- model: 'test-model',
- user: 'test-user',
+ model: 'claude-3-5-sonnet-latest',
+ user: undefined,
cost: 0.5,
aiSystem: 'anthropic',
- serverAddress: 'api.anthropic.com',
- serverPort: 443,
};
});
await AnthropicWrapper._messageCreate({
args: mockArgs,
- genAIEndpoint: 'anthropic.endpoint',
+ genAIEndpoint: 'anthropic.resources.messages',
response: mockResponse,
span,
});
expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
- model: 'test-model',
- user: 'test-user',
+ model: 'claude-3-5-sonnet-latest',
+ user: undefined,
cost: 0.5,
aiSystem: 'anthropic',
- genAIEndpoint: 'anthropic.endpoint',
- serverAddress: 'api.anthropic.com',
- serverPort: 443,
+ genAIEndpoint: 'anthropic.resources.messages',
});
});
+
+ it('should re-throw errors from commonSetter', async () => {
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
+ const mockResponse = {};
+
+ jest.spyOn(BaseWrapper, 'recordMetrics').mockImplementation(() => {});
+ jest.spyOn(AnthropicWrapper, '_messageCreateCommonSetter').mockRejectedValueOnce(new Error('test error'));
+
+ await expect(
+ AnthropicWrapper._messageCreate({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ response: mockResponse,
+ span,
+ })
+ ).rejects.toThrow('test error');
+ });
});
- describe('_messageCommonSetter', () => {
+ describe('_messageCreateCommonSetter', () => {
it('should set span attributes and return metric parameters', async () => {
- const mockArgs = [{ message: 'test message', max_tokens: 100, temperature: 0.7 }];
+ const mockArgs = [{
+ model: 'claude-3-5-sonnet-latest',
+ messages: [{ role: 'user', content: 'test message' }],
+ max_tokens: 100,
+ temperature: 0.7,
+ }];
const mockResult = {
- id: '123',
+ id: 'msg_123',
usage: { input_tokens: 10, output_tokens: 20 },
- model: 'claude-3-sonnet-20240229',
- stop_reason: 'stop',
+ model: 'claude-3-5-sonnet-20241022',
+ stop_reason: 'end_turn',
+ content: [{ type: 'text', text: 'Hello' }],
};
- jest.spyOn(OpenlitConfig, 'updatePricingJson').mockResolvedValue({});
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
const setAttributeSpy = jest.spyOn(span, 'setAttribute');
- await AnthropicWrapper._messageCreateCommonSetter({
+ const metricParams = await AnthropicWrapper._messageCreateCommonSetter({
args: mockArgs,
- genAIEndpoint: 'anthropic.endpoint',
+ genAIEndpoint: 'anthropic.resources.messages',
result: mockResult,
span,
});
- expect(setAttributeSpy).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
- expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, '123');
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, 'msg_123');
expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 10);
expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'claude-3-5-sonnet-20241022'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_TYPE,
+ 'text'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
- 30
+ expect.anything()
+ );
+
+ expect(metricParams).toEqual({
+ genAIEndpoint: 'anthropic.resources.messages',
+ model: 'claude-3-5-sonnet-latest',
+ user: undefined,
+ cost: 0.5,
+ aiSystem: 'anthropic',
+ });
+ });
+
+ it('should map Anthropic finish reasons to OTel standard', async () => {
+ const makeResult = (stop_reason: string) => ({
+ id: 'msg_1',
+ usage: { input_tokens: 5, output_tokens: 5 },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason,
+ content: [{ type: 'text', text: 'hi' }],
+ });
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ const testCases = [
+ { anthropic: 'end_turn', otel: 'stop' },
+ { anthropic: 'max_tokens', otel: 'length' },
+ { anthropic: 'stop_sequence', otel: 'stop' },
+ { anthropic: 'tool_use', otel: 'tool_call' },
+ ];
+
+ for (const { anthropic, otel } of testCases) {
+ jest.clearAllMocks();
+ span.setAttribute = jest.fn();
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: [{ model: 'claude-3-5-sonnet-latest', messages: [] }],
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: makeResult(anthropic),
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ [otel]
+ );
+ }
+ });
+
+ it('should not set max_tokens when not provided', async () => {
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [], temperature: 1 }];
+ const mockResult = {
+ id: 'msg_1',
+ usage: { input_tokens: 5, output_tokens: 5 },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason: 'end_turn',
+ content: [{ type: 'text', text: 'hi' }],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: mockResult,
+ span,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
+ expect.anything()
+ );
+ });
+
+ it('should not set seed when not provided', async () => {
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
+ const mockResult = {
+ id: 'msg_1',
+ usage: { input_tokens: 5, output_tokens: 5 },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason: 'end_turn',
+ content: [{ type: 'text', text: 'hi' }],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: mockResult,
+ span,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_SEED,
+ expect.anything()
+ );
+ });
+
+ it('should emit inference event when events are enabled', async () => {
+ const mockArgs = [{
+ model: 'claude-3-5-sonnet-latest',
+ messages: [{ role: 'user', content: 'hello' }],
+ }];
+ const mockResult = {
+ id: 'msg_123',
+ usage: { input_tokens: 10, output_tokens: 20 },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason: 'end_turn',
+ content: [{ type: 'text', text: 'Hi there' }],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: mockResult,
+ span,
+ });
+
+ expect(emitSpy).toHaveBeenCalledWith(span, expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'claude-3-5-sonnet-latest',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'claude-3-5-sonnet-latest',
+ [SemanticConvention.SERVER_ADDRESS]: 'api.anthropic.com',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: 'msg_123',
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: 'text',
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 10,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 20,
+ }));
+ });
+
+ it('should set tool call attributes when tool_use blocks are present', async () => {
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
+ const mockResult = {
+ id: 'msg_1',
+ usage: { input_tokens: 10, output_tokens: 20 },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason: 'tool_use',
+ content: [
+ { type: 'text', text: '' },
+ { type: 'tool_use', id: 'toolu_123', name: 'get_weather', input: { location: 'Paris' } },
+ ],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: mockResult,
+ span,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_TYPE,
+ 'json'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'toolu_123'
);
expect(setAttributeSpy).toHaveBeenCalledWith(
SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
- ['stop']
+ ['tool_call']
+ );
+ });
+
+ it('should set cache token attributes when present', async () => {
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
+ const mockResult = {
+ id: 'msg_1',
+ usage: {
+ input_tokens: 10,
+ output_tokens: 20,
+ cache_creation_input_tokens: 5,
+ cache_read_input_tokens: 3,
+ },
+ model: 'claude-3-5-sonnet-latest',
+ stop_reason: 'end_turn',
+ content: [{ type: 'text', text: 'cached response' }],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ await AnthropicWrapper._messageCreateCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'anthropic.resources.messages',
+ result: mockResult,
+ span,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
+ 5
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
+ 3
);
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/base-wrapper.test.ts b/sdk/typescript/src/instrumentation/__tests__/base-wrapper.test.ts
index 5e20134f..353d6f79 100644
--- a/sdk/typescript/src/instrumentation/__tests__/base-wrapper.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/base-wrapper.test.ts
@@ -10,22 +10,15 @@ describe('BaseWrapper.setBaseSpanAttributes', () => {
attributes?: Record<string, unknown>;
}
let span: TestSpan;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- let addSpy: jest.SpyInstance;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- let recordSpy: jest.SpyInstance;
-
-
beforeEach(() => {
Openlit.init({
applicationName: 'TestApp',
environment: 'TestEnv',
otlpEndpoint: 'http://localhost:4318',
});
- Metrics.setup({ resource: defaultResource(), otlpEndpoint: 'http://localhost:4318' }); // Ensure metrics are initialized with a valid endpoint
- addSpy = jest.spyOn(Metrics.genaiRequests!, 'add').mockImplementation(() => {});
- jest.spyOn(Metrics.genaiPromptTokens!, 'add').mockImplementation(() => {});
- jest.spyOn(Metrics.genaiCompletionTokens!, 'add').mockImplementation(() => {});
+ Metrics.resetForTesting();
+ Metrics.setup({ resource: defaultResource(), otlpEndpoint: 'http://localhost:4318', environment: 'TestEnv', applicationName: 'TestApp', disableBatch: false, captureMessageContent: true, disableMetrics: false, disableEvents: false } as any);
+ jest.spyOn(Metrics.genaiClientUsageTokens!, 'record').mockImplementation(() => {});
jest.spyOn(Metrics.genaiClientOperationDuration!, 'record').mockImplementation(() => {});
jest.spyOn(Metrics.genaiCost!, 'record').mockImplementation(() => {});
span = {
@@ -64,13 +57,12 @@ describe('BaseWrapper.setBaseSpanAttributes', () => {
expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_USER, 'user1');
expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_COST, 0.99);
expect(span.setStatus).toHaveBeenCalled();
- expect(Metrics.genaiRequests!.add).toHaveBeenCalledWith(1, expect.objectContaining({
- [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai',
- [SemanticConvention.GEN_AI_REQUEST_USER]: 'user1',
- [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'gpt-4',
+ expect(Metrics.genaiClientUsageTokens!.record).toHaveBeenCalledWith(10, expect.objectContaining({
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_INPUT,
+ }));
+ expect(Metrics.genaiClientUsageTokens!.record).toHaveBeenCalledWith(20, expect.objectContaining({
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_OUTPUT,
}));
- expect(Metrics.genaiPromptTokens!.add).toHaveBeenCalledWith(10, expect.any(Object));
- expect(Metrics.genaiCompletionTokens!.add).toHaveBeenCalledWith(20, expect.any(Object));
expect(Metrics.genaiClientOperationDuration!.record).toHaveBeenCalledWith(1.5e-9, expect.any(Object));
expect(Metrics.genaiCost!.record).toHaveBeenCalledWith(0.99, expect.any(Object));
});
@@ -92,17 +84,16 @@ describe('BaseWrapper.setBaseSpanAttributes', () => {
BaseWrapper.setBaseSpanAttributes(span as unknown as Span, baseAttributes);
BaseWrapper.recordMetrics(span as unknown as Span, baseAttributes);
- expect(Metrics.genaiPromptTokens!.add).not.toHaveBeenCalled();
- expect(Metrics.genaiCompletionTokens!.add).not.toHaveBeenCalled();
+ expect(Metrics.genaiClientUsageTokens!.record).not.toHaveBeenCalled();
expect(Metrics.genaiClientOperationDuration!.record).not.toHaveBeenCalled();
expect(Metrics.genaiCost!.record).not.toHaveBeenCalled();
});
describe('metrics logic for inputTokens, outputTokens, duration, cost', () => {
beforeEach(() => {
- Metrics.setup({ resource: defaultResource(), otlpEndpoint: 'http://localhost:4318' });
- jest.spyOn(Metrics.genaiPromptTokens!, 'add').mockImplementation(() => {});
- jest.spyOn(Metrics.genaiCompletionTokens!, 'add').mockImplementation(() => {});
+ Metrics.resetForTesting();
+ Metrics.setup({ resource: defaultResource(), otlpEndpoint: 'http://localhost:4318', environment: 'TestEnv', applicationName: 'TestApp', disableBatch: false, captureMessageContent: true, disableMetrics: false, disableEvents: false } as any);
+ jest.spyOn(Metrics.genaiClientUsageTokens!, 'record').mockImplementation(() => {});
jest.spyOn(Metrics.genaiClientOperationDuration!, 'record').mockImplementation(() => {});
jest.spyOn(Metrics.genaiCost!, 'record').mockImplementation(() => {});
});
@@ -128,8 +119,7 @@ describe('BaseWrapper.setBaseSpanAttributes', () => {
BaseWrapper.setBaseSpanAttributes(span as unknown as Span, baseAttributes);
BaseWrapper.recordMetrics(span as unknown as Span, baseAttributes);
- expect(Metrics.genaiPromptTokens!.add).not.toHaveBeenCalled();
- expect(Metrics.genaiCompletionTokens!.add).not.toHaveBeenCalled();
+ expect(Metrics.genaiClientUsageTokens!.record).not.toHaveBeenCalled();
expect(Metrics.genaiClientOperationDuration!.record).not.toHaveBeenCalled();
expect(Metrics.genaiCost!.record).not.toHaveBeenCalled();
});
@@ -155,8 +145,12 @@ describe('BaseWrapper.setBaseSpanAttributes', () => {
BaseWrapper.setBaseSpanAttributes(span as unknown as Span, baseAttributes);
BaseWrapper.recordMetrics(span as unknown as Span, baseAttributes);
- expect(Metrics.genaiPromptTokens!.add).toHaveBeenCalledWith(0, expect.any(Object));
- expect(Metrics.genaiCompletionTokens!.add).toHaveBeenCalledWith(-5, expect.any(Object));
+ expect(Metrics.genaiClientUsageTokens!.record).toHaveBeenCalledWith(0, expect.objectContaining({
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_INPUT,
+ }));
+ expect(Metrics.genaiClientUsageTokens!.record).toHaveBeenCalledWith(-5, expect.objectContaining({
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_OUTPUT,
+ }));
expect(Metrics.genaiClientOperationDuration!.record).toHaveBeenCalledWith(-1.5e-9, expect.any(Object));
expect(Metrics.genaiCost!.record).toHaveBeenCalledWith(0, expect.any(Object));
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/bedrock-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/bedrock-trace-comparison.test.ts
new file mode 100644
index 00000000..bfcc0ecf
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/__tests__/bedrock-trace-comparison.test.ts
@@ -0,0 +1,546 @@
+import { Span, trace } from '@opentelemetry/api';
+import BedrockWrapper from '../bedrock/wrapper';
+import OpenlitConfig from '../../config';
+import OpenLitHelper from '../../helpers';
+import BaseWrapper from '../base-wrapper';
+import SemanticConvention from '../../semantic-convention';
+
+jest.mock('../../../src/config');
+jest.mock('../../../src/helpers');
+jest.mock('../../../src/instrumentation/base-wrapper');
+
+const mockTracer = trace.getTracer('test-tracer');
+
+describe('BedrockWrapper', () => {
+ let span: Span;
+
+ beforeEach(() => {
+ span = mockTracer.startSpan('test-span');
+ span.setAttribute = jest.fn();
+ jest.clearAllMocks();
+ });
+
+ afterEach(() => {
+ span.end();
+ });
+
+ describe('_converseComplete', () => {
+ it('should call recordMetrics after span ends', async () => {
+ const input = {
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ messages: [{ role: 'user', content: [{ text: 'test' }] }],
+ };
+ const mockResponse = {
+ output: { message: { role: 'assistant', content: [{ text: 'Hello' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 10, outputTokens: 20 },
+ $metadata: { requestId: 'req-123' },
+ };
+
+ jest.spyOn(BaseWrapper, 'recordMetrics').mockImplementation(() => {});
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ await BedrockWrapper._converseComplete({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ response: mockResponse,
+ span,
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
+ genAIEndpoint: 'bedrock.converse',
+ model: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ cost: 0.5,
+ aiSystem: 'aws.bedrock',
+ });
+ });
+
+ it('should re-throw errors from commonSetter', async () => {
+ jest.spyOn(BaseWrapper, 'recordMetrics').mockImplementation(() => {});
+ jest.spyOn(BedrockWrapper, '_converseCommonSetter').mockImplementationOnce(() => {
+ throw new Error('test error');
+ });
+
+ await expect(
+ BedrockWrapper._converseComplete({
+ input: {},
+ genAIEndpoint: 'bedrock.converse',
+ response: {},
+ span,
+ modelId: 'test-model',
+ })
+ ).rejects.toThrow('test error');
+ });
+ });
+
+ describe('_converseCommonSetter', () => {
+ it('should set span attributes and return metric parameters', () => {
+ const input = {
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ messages: [{ role: 'user', content: [{ text: 'test message' }] }],
+ inferenceConfig: { temperature: 0.7, maxTokens: 100, topP: 0.9 },
+ };
+ const mockResult = {
+ output: { message: { role: 'assistant', content: [{ text: 'Hello' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 10, outputTokens: 20 },
+ $metadata: { requestId: 'req-123' },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ const metricParams = BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, 'req-123');
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 0.9);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 10);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'us.anthropic.claude-3-5-sonnet-20241022-v2:0'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_TYPE,
+ 'text'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
+ expect.anything()
+ );
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
+ expect.anything()
+ );
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,
+ expect.anything()
+ );
+
+ expect(metricParams).toEqual({
+ genAIEndpoint: 'bedrock.converse',
+ model: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ cost: 0.5,
+ aiSystem: 'aws.bedrock',
+ });
+ });
+
+ it('should map Bedrock finish reasons to OTel standard', () => {
+ const makeResult = (stopReason: string) => ({
+ output: { message: { content: [{ text: 'hi' }] } },
+ stopReason,
+ usage: { inputTokens: 5, outputTokens: 5 },
+ });
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ const testCases = [
+ { bedrock: 'end_turn', otel: 'stop' },
+ { bedrock: 'max_tokens', otel: 'max_tokens' },
+ { bedrock: 'stop_sequence', otel: 'stop' },
+ { bedrock: 'tool_use', otel: 'tool_calls' },
+ { bedrock: 'content_filtered', otel: 'content_filter' },
+ { bedrock: 'guardrail_intervention', otel: 'content_filter' },
+ ];
+
+ for (const { bedrock, otel } of testCases) {
+ jest.clearAllMocks();
+ span.setAttribute = jest.fn();
+
+ BedrockWrapper._converseCommonSetter({
+ input: { messages: [] },
+ genAIEndpoint: 'bedrock.converse',
+ result: makeResult(bedrock),
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ [otel]
+ );
+ }
+ });
+
+ it('should not set max_tokens when not provided', () => {
+ const input = { messages: [], inferenceConfig: { temperature: 1 } };
+ const mockResult = {
+ output: { message: { content: [{ text: 'hi' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
+ expect.anything()
+ );
+ });
+
+ it('should not set frequency/presence penalty when not provided', () => {
+ const input = { messages: [], inferenceConfig: {} };
+ const mockResult = {
+ output: { message: { content: [{ text: 'hi' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ expect.anything()
+ );
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ expect.anything()
+ );
+ });
+
+ it('should emit inference event when events are enabled', () => {
+ const input = {
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ messages: [{ role: 'user', content: [{ text: 'hello' }] }],
+ };
+ const mockResult = {
+ output: { message: { content: [{ text: 'Hi there' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 10, outputTokens: 20 },
+ $metadata: { requestId: 'req-123' },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ isStream: false,
+ });
+
+ expect(emitSpy).toHaveBeenCalledWith(span, expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
+ [SemanticConvention.SERVER_ADDRESS]: 'bedrock-runtime.amazonaws.com',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: 'req-123',
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: 'text',
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 10,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 20,
+ }));
+ });
+
+ it('should not emit event when events are disabled', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'hi' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(emitSpy).not.toHaveBeenCalled();
+ });
+
+ it('should set tool call attributes when toolUse blocks are present', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: {
+ message: {
+ content: [
+ { text: '' },
+ { toolUse: { toolUseId: 'tool_123', name: 'get_weather', input: { location: 'Paris' } } },
+ ],
+ },
+ },
+ stopReason: 'tool_use',
+ usage: { inputTokens: 10, outputTokens: 20 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'tool_123'
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['tool_calls']
+ );
+ });
+
+ it('should set cache token attributes when present', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'cached response' }] } },
+ stopReason: 'end_turn',
+ usage: {
+ inputTokens: 10,
+ outputTokens: 20,
+ cacheReadInputTokens: 3,
+ cacheWriteInputTokens: 5,
+ },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
+ 3
+ );
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
+ 5
+ );
+ });
+
+ it('should not set cache token attributes when zero', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'response' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 10, outputTokens: 20 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
+ expect.anything()
+ );
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
+ expect.anything()
+ );
+ });
+
+ it('should set system instructions when system block is present and captureContent is true', () => {
+ const input = {
+ messages: [{ role: 'user', content: [{ text: 'hello' }] }],
+ system: [{ text: 'You are a helpful assistant.' }],
+ };
+ const mockResult = {
+ output: { message: { content: [{ text: 'Hi!' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[]');
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS,
+ JSON.stringify([{ type: 'text', content: 'You are a helpful assistant.' }])
+ );
+ });
+
+ it('should use OpenlitConfig.pricingInfo for cost calculation', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'response' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 100, outputTokens: 50 },
+ };
+
+ const mockPricingInfo = { chat: { 'test-model': { promptPrice: 0.01, completionPrice: 0.02 } } };
+ (OpenlitConfig as any).pricingInfo = mockPricingInfo;
+ (OpenlitConfig as any).disableEvents = true;
+ const costSpy = jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(1.5);
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(costSpy).toHaveBeenCalledWith('test-model', mockPricingInfo, 100, 50);
+ });
+
+ it('should set TTFT and TBT when provided for streaming', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'response' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse_stream',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: true,
+ ttft: 0.15,
+ tbt: 0.05,
+ });
+
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TTFT, 0.15);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TBT, 0.05);
+ expect(setAttributeSpy).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
+ });
+
+ it('should not set TTFT and TBT when zero', () => {
+ const input = { messages: [] };
+ const mockResult = {
+ output: { message: { content: [{ text: 'response' }] } },
+ stopReason: 'end_turn',
+ usage: { inputTokens: 5, outputTokens: 5 },
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
+
+ BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint: 'bedrock.converse',
+ result: mockResult,
+ span,
+ modelId: 'test-model',
+ isStream: false,
+ });
+
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_SERVER_TTFT,
+ expect.anything()
+ );
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_SERVER_TBT,
+ expect.anything()
+ );
+ });
+ });
+});
diff --git a/sdk/typescript/src/instrumentation/__tests__/chroma-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/chroma-trace-comparison.test.ts
index ff065429..4513c48a 100644
--- a/sdk/typescript/src/instrumentation/__tests__/chroma-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/chroma-trace-comparison.test.ts
@@ -42,7 +42,7 @@ describe('ChromaDB Cross-Language Trace Comparison', () => {
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
+ (OpenlitConfig as any).captureMessageContent = true;
(OpenLitHelper as any).handleException = jest.fn();
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/cohere-wrapper.test.ts b/sdk/typescript/src/instrumentation/__tests__/cohere-wrapper.test.ts
index e5071261..9adb0169 100644
--- a/sdk/typescript/src/instrumentation/__tests__/cohere-wrapper.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/cohere-wrapper.test.ts
@@ -3,6 +3,7 @@ import CohereWrapper from '../cohere/wrapper';
import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
import BaseWrapper from '../base-wrapper';
+import SemanticConvention from '../../semantic-convention';
jest.mock('../../../src/config');
jest.mock('../../../src/helpers');
@@ -16,6 +17,7 @@ describe('CohereWrapper', () => {
beforeEach(() => {
span = mockTracer.startSpan('test-span');
span.setAttribute = jest.fn();
+ span.addEvent = jest.fn();
jest.clearAllMocks();
});
@@ -25,17 +27,28 @@ describe('CohereWrapper', () => {
describe('_chat', () => {
it('should call recordMetrics after span ends', async () => {
- const mockArgs = [{ message: 'test message' }];
- const mockResponse = { response_id: '123', meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } } };
- const mockGenAIEndpoint = 'cohere.endpoint';
+ const mockArgs = [{ model: 'command-r-plus', message: 'test message' }];
+ const mockResponse = {
+ response_id: '123',
+ text: 'response text',
+ finishReason: 'stop',
+ meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } },
+ };
+ const mockGenAIEndpoint = 'cohere.chat';
- jest.spyOn(CohereWrapper, '_chatCommonSetter').mockResolvedValue({
- genAIEndpoint: mockGenAIEndpoint,
- model: 'test-model',
- user: 'test-user',
- cost: 0.5,
- aiSystem: 'cohere',
- });
+ jest
+ .spyOn(CohereWrapper, '_chatCommonSetter')
+ .mockImplementationOnce(async ({ genAIEndpoint, span: s }) => {
+ s.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 1);
+
+ return {
+ genAIEndpoint,
+ model: 'command-r-plus',
+ user: 'test-user',
+ cost: 0.5,
+ aiSystem: 'cohere',
+ };
+ });
await CohereWrapper._chat({
args: mockArgs,
@@ -46,26 +59,53 @@ describe('CohereWrapper', () => {
expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
genAIEndpoint: mockGenAIEndpoint,
- model: 'test-model',
+ model: 'command-r-plus',
user: 'test-user',
cost: 0.5,
aiSystem: 'cohere',
});
});
+
+ it('should rethrow errors from _chatCommonSetter', async () => {
+ const mockArgs = [{ model: 'command-r-plus', message: 'test message' }];
+ const mockResponse = {
+ response_id: '123',
+ meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } },
+ };
+
+ jest.spyOn(CohereWrapper, '_chatCommonSetter').mockRejectedValue(new Error('Test error'));
+
+ await expect(
+ CohereWrapper._chat({
+ args: mockArgs,
+ genAIEndpoint: 'cohere.chat',
+ response: mockResponse,
+ span,
+ })
+ ).rejects.toThrow('Test error');
+ });
});
describe('_chatGenerator', () => {
it('should call recordMetrics after span ends in generator', async () => {
- const mockArgs = [{ message: 'test message' }];
+ const mockArgs = [{ model: 'command-r-plus', message: 'test message' }];
const mockResponse = async function* () {
yield { eventType: 'stream', response: { response_id: '123' } };
- yield { eventType: 'stream-end', response: { response_id: '123', meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } } } };
+ yield {
+ eventType: 'stream-end',
+ response: {
+ response_id: '123',
+ text: 'response text',
+ finishReason: 'stop',
+ meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } },
+ },
+ };
}();
- const mockGenAIEndpoint = 'cohere.endpoint';
+ const mockGenAIEndpoint = 'cohere.chat';
jest.spyOn(CohereWrapper, '_chatCommonSetter').mockResolvedValue({
genAIEndpoint: mockGenAIEndpoint,
- model: 'test-model',
+ model: 'command-r-plus',
user: 'test-user',
cost: 0.5,
aiSystem: 'cohere',
@@ -84,7 +124,7 @@ describe('CohereWrapper', () => {
expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
genAIEndpoint: mockGenAIEndpoint,
- model: 'test-model',
+ model: 'command-r-plus',
user: 'test-user',
cost: 0.5,
aiSystem: 'cohere',
@@ -94,16 +134,31 @@ describe('CohereWrapper', () => {
describe('_chatCommonSetter', () => {
it('should set span attributes and return metric parameters', async () => {
- const mockArgs = [{ message: 'test message', max_tokens: 100, temperature: 0.7 }];
+ const mockArgs = [
+ {
+ model: 'command-r-plus',
+ message: 'test message',
+ max_tokens: 100,
+ temperature: 0.7,
+ p: 0.9,
+ k: 5,
+ frequency_penalty: 0.5,
+ presence_penalty: 0.3,
+ seed: 42,
+ stop_sequences: ['END'],
+ },
+ ];
const mockResult = {
response_id: '123',
meta: { billedUnits: { inputTokens: 10, outputTokens: 20 } },
text: 'response text',
finishReason: 'stop',
};
- const mockGenAIEndpoint = 'cohere.endpoint';
+ const mockGenAIEndpoint = 'cohere.chat';
- jest.spyOn(OpenlitConfig, 'updatePricingJson').mockResolvedValue({});
+ jest.restoreAllMocks();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
const metricParams = await CohereWrapper._chatCommonSetter({
@@ -111,22 +166,159 @@ describe('CohereWrapper', () => {
genAIEndpoint: mockGenAIEndpoint,
result: mockResult,
span,
- stream: false,
});
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_TOP_P,
+ 0.9
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_TOP_K,
+ 5
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
+ 100
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
+ 0.7
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ 0.3
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ 0.5
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_SEED,
+ 42
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
+ false
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ ['END']
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'command-r-plus'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_TYPE,
+ 'text'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
+ 10
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
+ 20
+ );
expect(metricParams).toEqual({
genAIEndpoint: mockGenAIEndpoint,
- model: 'test-model',
- user: "test-user",
+ model: 'command-r-plus',
+ user: undefined,
cost: 0.5,
aiSystem: 'cohere',
});
});
- describe('_chatCommonSetter error handling', () => {
+ it('should handle tool calls properly', async () => {
+ const mockArgs = [
+ {
+ model: 'command-r-plus',
+ message: 'what is the weather?',
+ tools: [{ type: 'function', function: { name: 'get_weather' } }],
+ },
+ ];
+ const mockResult = {
+ response_id: '456',
+ meta: { billedUnits: { inputTokens: 15, outputTokens: 25 } },
+ text: '',
+ finishReason: 'tool_use',
+ toolCalls: [
+ {
+ id: 'call_abc',
+ name: 'get_weather',
+ arguments: '{"location":"SF"}',
+ },
+ ],
+ };
+
+ jest.restoreAllMocks();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.3);
+
+ await CohereWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'cohere.chat',
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_abc'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"SF"}'
+ );
+ });
+
+ it('should not set sentinel values for optional parameters', async () => {
+ const mockArgs = [{ model: 'command-r-plus', message: 'test' }];
+ const mockResult = {
+ response_id: '789',
+ meta: { billedUnits: { inputTokens: 5, outputTokens: 10 } },
+ text: 'ok',
+ finishReason: 'stop',
+ };
+
+ jest.restoreAllMocks();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await CohereWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'cohere.chat',
+ result: mockResult,
+ span,
+ });
+
+ const setAttrCalls = (span.setAttribute as jest.Mock).mock.calls;
+ const attrKeys = setAttrCalls.map((call: any[]) => call[0]);
+
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_SEED);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_TOP_K);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE);
+ });
+
+ describe('error handling', () => {
it('should not call recordMetrics and handle the error properly', async () => {
- const mockArgs = [{ message: 'test message', max_tokens: 100, temperature: 0.7 }];
- const mockGenAIEndpoint = 'cohere.endpoint';
+ const mockArgs = [{ model: 'command-r-plus', message: 'test', max_tokens: 100, temperature: 0.7 }];
+ const mockGenAIEndpoint = 'cohere.chat';
const mockError = new Error('Test error');
jest.spyOn(CohereWrapper, '_chatCommonSetter').mockRejectedValue(mockError);
@@ -137,7 +329,6 @@ describe('CohereWrapper', () => {
genAIEndpoint: mockGenAIEndpoint,
result: {},
span,
- stream: false,
})
).rejects.toThrow('Test error');
diff --git a/sdk/typescript/src/instrumentation/__tests__/google-ai-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/google-ai-trace-comparison.test.ts
index 0f539bad..2f153d76 100644
--- a/sdk/typescript/src/instrumentation/__tests__/google-ai-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/google-ai-trace-comparison.test.ts
@@ -2,6 +2,7 @@
* Cross-Language Trace Comparison Tests for Google AI Studio Integration
*/
+import { trace } from '@opentelemetry/api';
import GoogleAIWrapper from '../google-ai/wrapper';
import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
@@ -12,34 +13,34 @@ jest.mock('../../config');
jest.mock('../../helpers');
jest.mock('../base-wrapper');
+const mockTracer = trace.getTracer('test-tracer');
+
describe('Google AI Studio Cross-Language Trace Comparison', () => {
let mockSpan: any;
beforeEach(() => {
- // Create mock span
- mockSpan = {
- setAttribute: jest.fn(),
- addEvent: jest.fn(),
- end: jest.fn(),
- setStatus: jest.fn(),
- };
-
- // Mock OpenlitConfig
+ mockSpan = mockTracer.startSpan('test-span');
+ mockSpan.setAttribute = jest.fn();
+ mockSpan.addEvent = jest.fn();
+ mockSpan.end = jest.fn();
+ mockSpan.setStatus = jest.fn();
+
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
- // Mock OpenLitHelper
(OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
(OpenLitHelper as any).handleException = jest.fn();
- (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, generator) => stream);
+ (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, _generator) => stream);
+ (OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[{"role":"user","parts":[{"type":"text","content":"What is Gemini?"}]}]');
+ (OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[{"role":"assistant","parts":[{"type":"text","content":"Gemini is Google\'s AI model"}],"finish_reason":"STOP"}]');
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
- // Mock BaseWrapper
(BaseWrapper as any).recordMetrics = jest.fn();
(BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span, attrs) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
if (attrs.cost !== undefined) {
@@ -75,42 +76,191 @@ describe('Google AI Studio Cross-Language Trace Comparison', () => {
];
const mockResponse = {
- model: 'gemini-pro',
- candidates: [
- {
- content: {
- parts: [{ text: 'Gemini is Google\'s AI model' }],
- role: 'model',
+ response: {
+ modelVersion: 'gemini-pro',
+ text: () => "Gemini is Google's AI model",
+ candidates: [
+ {
+ content: {
+ parts: [{ text: "Gemini is Google's AI model" }],
+ role: 'model',
+ },
+ finishReason: 'STOP',
},
- finishReason: 'STOP',
+ ],
+ usageMetadata: {
+ promptTokenCount: 5,
+ candidatesTokenCount: 10,
+ totalTokenCount: 15,
},
- ],
- usageMetadata: {
- promptTokenCount: 5,
- candidatesTokenCount: 10,
- totalTokenCount: 15,
},
};
-
+
await GoogleAIWrapper._generateContent({
args: mockArgs,
genAIEndpoint: 'google.generativeai.models.generate_content',
response: mockResponse,
span: mockSpan,
+ requestModel: 'gemini-pro',
});
- // Verify critical attributes are set (matching Python SDK)
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'google_ai_studio');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ // Provider name: gcp.gemini (matches OTel semconv well-known value for Google AI Studio)
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL,
+ 'gcp.gemini'
+ );
+ // Request model
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MODEL, 'gemini-pro');
+ // Response model
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'gemini-pro');
+ // Token usage
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 5);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 10);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 15);
- // Python SDK parity: server.address, server.port, gen_ai.sdk.version
+ // Server address + port
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_ADDRESS, 'generativelanguage.googleapis.com');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
+ // Request params from config
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 0.95);
+ // is_stream
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ // Finish reason as array
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['STOP']);
+ // Output type
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'text');
+ });
+
+ it('should not set sentinel values for unset params', async () => {
+ const mockArgs = [
+ {
+ contents: 'Hello',
+ config: {},
+ },
+ ];
+
+ const mockResponse = {
+ response: {
+ text: () => 'Hi there!',
+ candidates: [{ content: { parts: [{ text: 'Hi there!' }], role: 'model' }, finishReason: 'STOP' }],
+ usageMetadata: { promptTokenCount: 2, candidatesTokenCount: 3, totalTokenCount: 5 },
+ },
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await GoogleAIWrapper._generateContent({
+ args: mockArgs,
+ genAIEndpoint: 'google.generativeai.models.generate_content',
+ response: mockResponse,
+ span: mockSpan,
+ requestModel: 'gemini-2.0-flash',
+ });
+
+ const setAttrCalls = mockSpan.setAttribute.mock.calls.map((c: any[]) => c[0]);
+ expect(setAttrCalls).not.toContain(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE);
+ expect(setAttrCalls).not.toContain(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS);
+ expect(setAttrCalls).not.toContain(SemanticConvention.GEN_AI_REQUEST_TOP_P);
+ expect(setAttrCalls).not.toContain(SemanticConvention.GEN_AI_REQUEST_TOP_K);
+ expect(setAttrCalls).not.toContain(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES);
+ });
+
+ it('should emit inference event independently of captureMessageContent', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
+ const mockArgs = [{ contents: 'Hello', config: {} }];
+ const mockResponse = {
+ response: {
+ text: () => 'Hi!',
+ candidates: [{ content: { parts: [{ text: 'Hi!' }], role: 'model' }, finishReason: 'STOP' }],
+ usageMetadata: { promptTokenCount: 1, candidatesTokenCount: 1, totalTokenCount: 2 },
+ },
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await GoogleAIWrapper._generateContent({
+ args: mockArgs,
+ genAIEndpoint: 'google.generativeai.models.generate_content',
+ response: mockResponse,
+ span: mockSpan,
+ requestModel: 'gemini-2.0-flash',
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledTimes(1);
+ const eventAttrs = (OpenLitHelper.emitInferenceEvent as jest.Mock).mock.calls[0][1];
+ expect(eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES]).toBeUndefined();
+ expect(eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]).toBeUndefined();
+ });
+
+ it('should call recordMetrics with cost from OpenlitConfig.pricingInfo', async () => {
+ (OpenlitConfig as any).pricingInfo = { chat: { 'gemini-pro': { promptPrice: 0.1, completionPrice: 0.2 } } };
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.0025);
+
+ const mockArgs = [{ contents: 'test', config: {} }];
+ const mockResponse = {
+ response: {
+ modelVersion: 'gemini-pro',
+ text: () => 'response',
+ candidates: [{ content: { parts: [{ text: 'response' }], role: 'model' }, finishReason: 'STOP' }],
+ usageMetadata: { promptTokenCount: 10, candidatesTokenCount: 5, totalTokenCount: 15 },
+ },
+ };
+
+ await GoogleAIWrapper._generateContent({
+ args: mockArgs,
+ genAIEndpoint: 'google.generativeai.models.generate_content',
+ response: mockResponse,
+ span: mockSpan,
+ requestModel: 'gemini-pro',
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ model: 'gemini-pro',
+ cost: 0.0025,
+ aiSystem: 'gcp.gemini',
+ })
+ );
+ });
+
+ it('should handle function calls matching Python tool attributes', async () => {
+ const mockArgs = [{ contents: 'What is the weather?', config: {} }];
+ const mockResponse = {
+ response: {
+ text: () => '',
+ candidates: [{
+ content: {
+ parts: [{
+ functionCall: { name: 'get_weather', args: { location: 'NYC' } },
+ }],
+ role: 'model',
+ },
+ finishReason: 'STOP',
+ }],
+ usageMetadata: { promptTokenCount: 5, candidatesTokenCount: 8, totalTokenCount: 13 },
+ },
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await GoogleAIWrapper._generateContent({
+ args: mockArgs,
+ genAIEndpoint: 'google.generativeai.models.generate_content',
+ response: mockResponse,
+ span: mockSpan,
+ requestModel: 'gemini-2.0-flash',
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"NYC"}'
+ );
});
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/groq-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/groq-trace-comparison.test.ts
index f2118d11..ed9d1219 100644
--- a/sdk/typescript/src/instrumentation/__tests__/groq-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/groq-trace-comparison.test.ts
@@ -1,6 +1,6 @@
/**
* Cross-Language Trace Comparison Tests for Groq Integration
- *
+ *
* These tests verify that TypeScript and Python generate equivalent traces
* for the same operations.
*/
@@ -10,12 +10,6 @@ import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
import BaseWrapper from '../base-wrapper';
import SemanticConvention from '../../semantic-convention';
-import {
- compareTraces,
- compareMetrics,
- createTraceValidator,
- NormalizedTrace,
-} from './trace-comparison-utils';
jest.mock('../../config');
jest.mock('../../helpers');
@@ -23,10 +17,9 @@ jest.mock('../base-wrapper');
describe('Groq Cross-Language Trace Comparison', () => {
let mockSpan: any;
- let mockTracer: any;
+ let _mockTracer: any;
beforeEach(() => {
- // Create mock span
mockSpan = {
setAttribute: jest.fn(),
addEvent: jest.fn(),
@@ -34,29 +27,27 @@ describe('Groq Cross-Language Trace Comparison', () => {
setStatus: jest.fn(),
};
- // Create mock tracer
- mockTracer = {
+ _mockTracer = {
startSpan: jest.fn().mockReturnValue(mockSpan),
};
- // Mock OpenlitConfig
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
- // Mock OpenLitHelper
(OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
(OpenLitHelper as any).openaiTokens = jest.fn().mockReturnValue(5);
(OpenLitHelper as any).handleException = jest.fn();
- (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, generator) => stream);
+ (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, _generator) => stream);
+ (OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[{"role":"user","parts":[{"type":"text","content":"Test"}]}]');
+ (OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[{"role":"assistant","parts":[{"type":"text","content":"Response"}],"finish_reason":"stop"}]');
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
- // Mock BaseWrapper
(BaseWrapper as any).recordMetrics = jest.fn();
(BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span, attrs) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
if (attrs.cost !== undefined) {
span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
@@ -104,7 +95,7 @@ describe('Groq Cross-Language Trace Comparison', () => {
total_tokens: 30,
},
};
-
+
await GroqWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'groq.chat.completions',
@@ -112,26 +103,378 @@ describe('Groq Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- // Verify critical attributes are set (matching Python SDK)
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'groq');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_ENDPOINT, 'groq.chat.completions');
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, 'groq');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MODEL, 'llama-3.1-8b-instant');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'llama-3.1-8b-instant');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, 'test-id-123');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 10);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 30);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
- // Python SDK parity: server.address, server.port, gen_ai.sdk.version
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'text');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_ADDRESS, 'api.groq.com');
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
});
+ it('should NOT set total_tokens or client.token.usage on span', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ const setAttributeCalls = (mockSpan.setAttribute as jest.Mock).mock.calls;
+ const attributeKeys = setAttributeCalls.map(([key]: [string]) => key);
+
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE);
+ });
+
+ it('should not set sentinel values for optional params', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ const setAttributeCalls = (mockSpan.setAttribute as jest.Mock).mock.calls;
+ const attributeKeys = setAttributeCalls.map(([key]: [string]) => key);
+
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_SEED);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT);
+ });
+
+ it('should set conditional params only when explicitly provided', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ max_tokens: 200,
+ seed: 42,
+ frequency_penalty: 0.5,
+ presence_penalty: 0.3,
+ stop: ['END'],
+ n: 2,
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 200);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 42);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0.5);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 0.3);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, ['END']);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, 2);
+ });
+
+ it('should emit inference event via LoggerProvider', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test-id',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'llama-3.1-8b-instant',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'llama-3.1-8b-instant',
+ [SemanticConvention.SERVER_ADDRESS]: 'api.groq.com',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: 'test-id',
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 5,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 10,
+ })
+ );
+ });
+
+ it('should include message content in event when captureMessageContent is true', async () => {
+ (OpenlitConfig as any).captureMessageContent = true;
+
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test-id',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_INPUT_MESSAGES]: expect.any(String),
+ [SemanticConvention.GEN_AI_OUTPUT_MESSAGES]: expect.any(String),
+ })
+ );
+ });
+
+ it('should NOT include message content in event when captureMessageContent is false', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test-id',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ const eventCall = (OpenLitHelper.emitInferenceEvent as jest.Mock).mock.calls[0];
+ const eventAttrs = eventCall[1];
+ expect(eventAttrs).not.toHaveProperty(SemanticConvention.GEN_AI_INPUT_MESSAGES);
+ expect(eventAttrs).not.toHaveProperty(SemanticConvention.GEN_AI_OUTPUT_MESSAGES);
+ });
+
+ it('should handle tool calls properly', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'What is the weather?' }],
+ model: 'llama-3.1-8b-instant',
+ tools: [{ type: 'function', function: { name: 'get_weather' } }],
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test-id',
+ model: 'llama-3.1-8b-instant',
+ choices: [
+ {
+ message: {
+ content: null,
+ role: 'assistant',
+ tool_calls: [
+ {
+ id: 'call_123',
+ type: 'function',
+ function: { name: 'get_weather', arguments: '{"location":"SF"}' },
+ },
+ ],
+ },
+ finish_reason: 'tool_calls',
+ },
+ ],
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_123'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"SF"}'
+ );
+ });
+
+ it('should set system_fingerprint when present', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test-id',
+ model: 'llama-3.1-8b-instant',
+ system_fingerprint: 'fp_groq_test',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ 'fp_groq_test'
+ );
+ });
+
+ it('should record metrics via BaseWrapper.recordMetrics', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ genAIEndpoint: 'groq.chat.completions',
+ model: 'llama-3.1-8b-instant',
+ aiSystem: 'groq',
+ })
+ );
+ });
+
+ it('should use OpenlitConfig.pricingInfo for cost calculation', async () => {
+ (OpenlitConfig as any).pricingInfo = { chat: { 'llama-3.1-8b-instant': { promptPrice: 0.05, completionPrice: 0.08 } } };
+
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Test' }],
+ model: 'llama-3.1-8b-instant',
+ stream: false,
+ },
+ ];
+
+ const mockResponse = {
+ id: 'test',
+ model: 'llama-3.1-8b-instant',
+ choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 100, completion_tokens: 50, total_tokens: 150 },
+ };
+
+ await GroqWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.getChatModelCost).toHaveBeenCalledWith(
+ 'llama-3.1-8b-instant',
+ expect.any(Object),
+ 100,
+ 50
+ );
+ });
+ });
+
+ describe('Streaming Chat Completion', () => {
it('should set streaming attributes matching Python SDK', async () => {
const mockArgs = [
{
@@ -141,7 +484,6 @@ describe('Groq Cross-Language Trace Comparison', () => {
},
];
- // Mock streaming response
async function* mockStream() {
yield {
id: 'test-id',
@@ -156,7 +498,7 @@ describe('Groq Cross-Language Trace Comparison', () => {
choices: [{ delta: { content: ' world' } }],
};
}
-
+
const generator = GroqWrapper._chatCompletionGenerator({
args: mockArgs,
genAIEndpoint: 'groq.chat.completions',
@@ -164,51 +506,133 @@ describe('Groq Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- // Consume the stream
for await (const _ of generator) {
- // Consume chunks
+ // consume
}
- // Verify streaming-specific attributes are set
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'groq');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, 'groq');
});
- });
- describe('Trace Validation', () => {
- it('should set all required attributes matching Python SDK', async () => {
+ it('should handle x_groq usage data in streaming', async () => {
const mockArgs = [
{
messages: [{ role: 'user', content: 'Test' }],
model: 'llama-3.1-8b-instant',
+ stream: true,
},
];
- const mockResponse = {
- id: 'test',
- model: 'llama-3.1-8b-instant',
- choices: [{ message: { content: 'Response' }, finish_reason: 'stop' }],
- usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
- };
-
- await GroqWrapper._chatCompletion({
+ async function* mockStream() {
+ yield {
+ id: 'test-id',
+ created: Date.now(),
+ model: 'llama-3.1-8b-instant',
+ choices: [{ delta: { content: 'Hello' } }],
+ };
+ yield {
+ id: 'test-id',
+ created: Date.now(),
+ model: 'llama-3.1-8b-instant',
+ choices: [{ delta: { content: '' }, finish_reason: 'stop' }],
+ x_groq: {
+ usage: { prompt_tokens: 15, completion_tokens: 25, total_tokens: 40 },
+ },
+ };
+ }
+
+ const generator = GroqWrapper._chatCompletionGenerator({
args: mockArgs,
genAIEndpoint: 'groq.chat.completions',
- response: mockResponse,
+ response: mockStream(),
span: mockSpan,
});
- // Verify all required attributes are set (matching Python expectations)
- const setAttributeCalls = (mockSpan.setAttribute as jest.Mock).mock.calls;
- const attributeMap = new Map(setAttributeCalls.map(([key, value]) => [key, value]));
-
- expect(attributeMap.get(SemanticConvention.GEN_AI_PROVIDER_NAME)).toBe('groq');
- expect(attributeMap.get(SemanticConvention.GEN_AI_OPERATION)).toBe(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- expect(attributeMap.get(SemanticConvention.GEN_AI_REQUEST_MODEL)).toBe('llama-3.1-8b-instant');
- expect(attributeMap.get(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS)).toBe(5);
- expect(attributeMap.get(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS)).toBe(10);
- expect(attributeMap.get(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS)).toBe(15);
+ for await (const _ of generator) {
+ // consume
+ }
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 15);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 25);
+ });
+
+ it('should handle tool calls in streaming', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Get the weather' }],
+ model: 'llama-3.1-8b-instant',
+ stream: true,
+ },
+ ];
+
+ async function* mockStream() {
+ yield {
+ id: 'test-id',
+ created: Date.now(),
+ model: 'llama-3.1-8b-instant',
+ choices: [{
+ delta: {
+ tool_calls: [{
+ index: 0,
+ id: 'call_abc',
+ type: 'function',
+ function: { name: 'get_weather', arguments: '{"loc' },
+ }],
+ },
+ }],
+ };
+ yield {
+ id: 'test-id',
+ created: Date.now(),
+ model: 'llama-3.1-8b-instant',
+ choices: [{
+ delta: {
+ tool_calls: [{
+ index: 0,
+ function: { arguments: 'ation":"SF"}' },
+ }],
+ },
+ }],
+ };
+ yield {
+ id: 'test-id',
+ created: Date.now(),
+ model: 'llama-3.1-8b-instant',
+ choices: [{ delta: {}, finish_reason: 'tool_calls' }],
+ };
+ }
+
+ const generator = GroqWrapper._chatCompletionGenerator({
+ args: mockArgs,
+ genAIEndpoint: 'groq.chat.completions',
+ response: mockStream(),
+ span: mockSpan,
+ });
+
+ for await (const _ of generator) {
+ // consume
+ }
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_abc'
+ );
+ });
+ });
+
+ describe('Span Creation Attributes', () => {
+ it('should use aiSystem from SemanticConvention.GEN_AI_SYSTEM_GROQ', () => {
+ expect(GroqWrapper.aiSystem).toBe(SemanticConvention.GEN_AI_SYSTEM_GROQ);
+ expect(GroqWrapper.aiSystem).toBe('groq');
+ });
+
+ it('should set correct server address and port', () => {
+ expect(GroqWrapper.serverAddress).toBe('api.groq.com');
+ expect(GroqWrapper.serverPort).toBe(443);
});
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/huggingface-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/huggingface-trace-comparison.test.ts
index 7223c5fb..ab888cfc 100644
--- a/sdk/typescript/src/instrumentation/__tests__/huggingface-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/huggingface-trace-comparison.test.ts
@@ -1,8 +1,8 @@
/**
* Cross-Language Trace Comparison Tests for HuggingFace Inference Integration
*
- * Verifies that the TypeScript SDK generates traces consistent with the Python SDK
- * for HuggingFace Inference API chatCompletion and textGeneration.
+ * Verifies that the TypeScript SDK generates traces consistent with
+ * OTel GenAI semantic conventions and the OpenAI reference wrapper pattern.
*/
import HuggingFaceWrapper from '../huggingface/wrapper';
@@ -33,26 +33,25 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
(OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.0005);
(OpenLitHelper as any).generalTokens = jest.fn().mockReturnValue(8);
(OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[]');
(OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[]');
(OpenLitHelper as any).handleException = jest.fn();
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
(OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, _gen) => stream);
(BaseWrapper as any).recordMetrics = jest.fn();
(BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span: any, attrs: any) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
if (attrs.cost !== undefined) span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
if (attrs.serverAddress) span.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
if (attrs.serverPort !== undefined) span.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
- span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
});
});
@@ -60,6 +59,55 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
jest.clearAllMocks();
});
+ // ── Span Creation ──────────────────────────────────────────────────────────
+
+ describe('Span Creation', () => {
+ it('should create span with name "{operation} {model}"', () => {
+ const patchedFn = HuggingFaceWrapper._patchChatCompletion(mockTracer);
+ const originalMethod = jest.fn().mockResolvedValue({
+ id: 'test', model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ choices: [{ message: { content: 'hi' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 3, total_tokens: 8 },
+ });
+ const wrapped = patchedFn(originalMethod);
+ wrapped.call({}, { model: 'meta-llama/Meta-Llama-3-8B-Instruct', messages: [] });
+
+ expect(mockTracer.startSpan).toHaveBeenCalledWith(
+ 'chat meta-llama/Meta-Llama-3-8B-Instruct',
+ expect.objectContaining({
+ kind: expect.any(Number),
+ attributes: expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: 'chat',
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: 'huggingface',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ [SemanticConvention.SERVER_ADDRESS]: 'api-inference.huggingface.co',
+ [SemanticConvention.SERVER_PORT]: 443,
+ }),
+ }),
+ expect.anything()
+ );
+ });
+
+ it('should create text generation span with name "text_completion {model}"', () => {
+ const patchedFn = HuggingFaceWrapper._patchTextGeneration(mockTracer);
+ const originalMethod = jest.fn().mockResolvedValue({ generated_text: 'result' });
+ const wrapped = patchedFn(originalMethod);
+ wrapped.call({}, { model: 'gpt2', inputs: 'test' });
+
+ expect(mockTracer.startSpan).toHaveBeenCalledWith(
+ 'text_completion gpt2',
+ expect.objectContaining({
+ attributes: expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: 'text_completion',
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: 'huggingface',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'gpt2',
+ }),
+ }),
+ expect.anything()
+ );
+ });
+ });
+
// ── Chat Completion ───────────────────────────────────────────────────────
describe('Chat Completion', () => {
@@ -87,7 +135,7 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
usage: { prompt_tokens: 12, completion_tokens: 25, total_tokens: 37 },
};
- it('should set gen_ai.system = "huggingface" matching Python GEN_AI_SYSTEM_HUGGING_FACE', async () => {
+ it('should set gen_ai.provider.name = "huggingface" via setBaseSpanAttributes', async () => {
await HuggingFaceWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'huggingface.chat.completions',
@@ -95,13 +143,13 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_PROVIDER_NAME,
- 'huggingface'
+ expect(BaseWrapper.setBaseSpanAttributes).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({ aiSystem: 'huggingface' })
);
});
- it('should set gen_ai.operation.name = "chat" matching Python', async () => {
+ it('should set token usage attributes without sentinel total_tokens', async () => {
await HuggingFaceWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'huggingface.chat.completions',
@@ -109,13 +157,17 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 12);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 25);
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, expect.anything()
+ );
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, expect.anything()
);
});
- it('should set token usage attributes matching Python SDK', async () => {
+ it('should set server.address and server.port via setBaseSpanAttributes', async () => {
await HuggingFaceWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'huggingface.chat.completions',
@@ -123,12 +175,16 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 12);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 25);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 37);
+ expect(BaseWrapper.setBaseSpanAttributes).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ serverAddress: 'api-inference.huggingface.co',
+ serverPort: 443,
+ })
+ );
});
- it('should set server.address and server.port matching Python', async () => {
+ it('should set request params: temperature, max_tokens, top_p, is_stream', async () => {
await HuggingFaceWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'huggingface.chat.completions',
@@ -136,24 +192,52 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.SERVER_ADDRESS,
- 'api-inference.huggingface.co'
- );
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 1);
});
- it('should set request params: temperature, max_tokens, is_stream', async () => {
+ it('should conditionally set frequency_penalty, presence_penalty, seed, stop', async () => {
+ const argsWithExtras = [
+ {
+ ...mockArgs[0],
+ frequency_penalty: 0.5,
+ presence_penalty: 0.3,
+ seed: 42,
+ stop: ['\n'],
+ n: 2,
+ },
+ ];
+
await HuggingFaceWrapper._chatCompletion({
- args: mockArgs,
+ args: argsWithExtras,
genAIEndpoint: 'huggingface.chat.completions',
response: mockResponse,
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0.5);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 0.3);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 42);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, ['\n']);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, 2);
+ });
+
+ it('should NOT set frequency_penalty or presence_penalty when 0', async () => {
+ await HuggingFaceWrapper._chatCompletion({
+ args: [{ ...mockArgs[0], frequency_penalty: 0, presence_penalty: 0 }],
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, expect.anything()
+ );
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, expect.anything()
+ );
});
it('should set finish_reason and output_type', async () => {
@@ -174,6 +258,41 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
);
});
+ it('should emit inference event via emitInferenceEvent', async () => {
+ await HuggingFaceWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: 'chat',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ [SemanticConvention.SERVER_ADDRESS]: 'api-inference.huggingface.co',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 12,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 25,
+ })
+ );
+ });
+
+ it('should not emit event when disableEvents=true', async () => {
+ (OpenlitConfig as any).disableEvents = true;
+
+ await HuggingFaceWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).not.toHaveBeenCalled();
+ });
+
it('should call recordMetrics after span ends', async () => {
await HuggingFaceWrapper._chatCompletion({
args: mockArgs,
@@ -183,7 +302,80 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
});
expect(mockSpan.end).toHaveBeenCalled();
- expect(BaseWrapper.recordMetrics).toHaveBeenCalled();
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ genAIEndpoint: 'huggingface.chat.completions',
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ aiSystem: 'huggingface',
+ })
+ );
+ });
+
+ it('should use OpenlitConfig.pricingInfo for cost calculation', async () => {
+ (OpenlitConfig as any).pricingInfo = { chat: {} };
+
+ await HuggingFaceWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.getChatModelCost).toHaveBeenCalledWith(
+ 'meta-llama/Meta-Llama-3-8B-Instruct',
+ { chat: {} },
+ 12,
+ 25
+ );
+ });
+ });
+
+ // ── Error Handling ─────────────────────────────────────────────────────────
+
+ describe('Error Handling', () => {
+ it('should record metrics with errorType on catch path', async () => {
+ const patchedFn = HuggingFaceWrapper._patchChatCompletion(mockTracer);
+ const error = new TypeError('network failure');
+ const originalMethod = jest.fn().mockRejectedValue(error);
+ const wrapped = patchedFn(originalMethod);
+
+ await expect(
+ wrapped.call({}, { model: 'test-model', messages: [] })
+ ).rejects.toThrow('network failure');
+
+ expect(OpenLitHelper.handleException).toHaveBeenCalledWith(mockSpan, error);
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ errorType: 'TypeError',
+ model: 'test-model',
+ aiSystem: 'huggingface',
+ serverAddress: 'api-inference.huggingface.co',
+ serverPort: 443,
+ })
+ );
+ expect(mockSpan.end).toHaveBeenCalled();
+ });
+
+ it('should record metrics with errorType on text generation error', async () => {
+ const patchedFn = HuggingFaceWrapper._patchTextGeneration(mockTracer);
+ const error = new RangeError('out of bounds');
+ const originalMethod = jest.fn().mockRejectedValue(error);
+ const wrapped = patchedFn(originalMethod);
+
+ await expect(
+ wrapped.call({}, { model: 'gpt2', inputs: 'test' })
+ ).rejects.toThrow('out of bounds');
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ errorType: 'RangeError',
+ model: 'gpt2',
+ aiSystem: 'huggingface',
+ })
+ );
});
});
@@ -224,11 +416,65 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
for await (const _ of generator) { /* consume */ }
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
+ expect(mockSpan.end).toHaveBeenCalled();
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalled();
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalled();
+ });
+
+ it('should handle tool call deltas across streaming chunks', async () => {
+ const mockArgs = [
+ {
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ messages: [{ role: 'user', content: 'Weather?' }],
+ stream: true,
+ },
+ ];
+
+ async function* mockStream() {
+ yield {
+ id: 'hf-stream-tc',
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ choices: [{
+ delta: {
+ tool_calls: [{
+ index: 0,
+ id: 'call_1',
+ type: 'function',
+ function: { name: 'get_weather', arguments: '{"loc' },
+ }],
+ },
+ }],
+ };
+ yield {
+ id: 'hf-stream-tc',
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ choices: [{
+ delta: {
+ tool_calls: [{
+ index: 0,
+ function: { arguments: '":"SF"}' },
+ }],
+ },
+ finish_reason: 'tool_calls',
+ }],
+ };
+ }
+
+ const generator = HuggingFaceWrapper._chatCompletionGenerator({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockStream(),
+ span: mockSpan,
+ });
+
+ for await (const _ of generator) { /* consume */ }
+
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_PROVIDER_NAME,
- 'huggingface'
+ SemanticConvention.GEN_AI_TOOL_NAME, 'get_weather'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID, 'call_1'
);
- expect(mockSpan.end).toHaveBeenCalled();
});
});
@@ -253,13 +499,9 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION
- );
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_PROVIDER_NAME,
- 'huggingface'
+ expect(BaseWrapper.setBaseSpanAttributes).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({ aiSystem: 'huggingface' })
);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 50);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.9);
@@ -268,10 +510,14 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
SemanticConvention.GEN_AI_OUTPUT_TYPE,
SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
expect(mockSpan.end).toHaveBeenCalled();
});
- it('should capture prompt and completion content when traceContent=true', async () => {
+ it('should use OTel message format for input/output content', async () => {
const mockArgs = [
{
model: 'gpt2',
@@ -288,14 +534,163 @@ describe('HuggingFace Cross-Language Trace Comparison', () => {
span: mockSpan,
});
+ expect(OpenLitHelper.buildInputMessages).toHaveBeenCalledWith(
+ [{ role: 'user', content: 'The meaning of life is' }]
+ );
+ expect(OpenLitHelper.buildOutputMessages).toHaveBeenCalledWith('42.', 'stop');
+
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
- 'The meaning of life is'
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ expect.any(String)
);
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ expect.any(String)
+ );
+ });
+
+ it('should emit inference event for text generation', async () => {
+ const mockArgs = [
+ {
+ model: 'gpt2',
+ inputs: 'test',
+ parameters: {},
+ },
+ ];
+ const mockResponse = { generated_text: 'result' };
+
+ await HuggingFaceWrapper._textGeneration({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.text.generation',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: 'text_completion',
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'gpt2',
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ })
+ );
+ });
+
+ it('should not set legacy content attributes', async () => {
+ const mockArgs = [
+ {
+ model: 'gpt2',
+ inputs: 'The meaning of life is',
+ parameters: {},
+ },
+ ];
+ const mockResponse = { generated_text: '42.' };
+
+ await HuggingFaceWrapper._textGeneration({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.text.generation',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
+ expect.anything()
+ );
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
- '42.'
+ expect.anything()
+ );
+ });
+
+ it('should not set total_tokens or client.token.usage (legacy)', async () => {
+ const mockArgs = [
+ {
+ model: 'gpt2',
+ inputs: 'test',
+ parameters: {},
+ },
+ ];
+ const mockResponse = { generated_text: 'result' };
+
+ await HuggingFaceWrapper._textGeneration({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.text.generation',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
+ expect.anything()
);
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
+ expect.anything()
+ );
+ });
+ });
+
+ // ── Content Gating ─────────────────────────────────────────────────────────
+
+ describe('Content capture gating', () => {
+ it('should not set input/output messages when captureMessageContent=false', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
+ const mockArgs = [
+ {
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ messages: [{ role: 'user', content: 'Secret' }],
+ stream: false,
+ },
+ ];
+ const mockResponse = {
+ id: 'hf-123',
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ choices: [{ message: { content: 'Reply' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 3, total_tokens: 8 },
+ };
+
+ await HuggingFaceWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES, expect.anything()
+ );
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES, expect.anything()
+ );
+ });
+
+ it('should still emit event even when captureMessageContent=false', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
+ const mockArgs = [
+ {
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ messages: [{ role: 'user', content: 'Secret' }],
+ stream: false,
+ },
+ ];
+ const mockResponse = {
+ id: 'hf-123',
+ model: 'meta-llama/Meta-Llama-3-8B-Instruct',
+ choices: [{ message: { content: 'Reply' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 3, total_tokens: 8 },
+ };
+
+ await HuggingFaceWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'huggingface.chat.completions',
+ response: mockResponse,
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalled();
});
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/milvus-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/milvus-trace-comparison.test.ts
index eb857150..25cfd283 100644
--- a/sdk/typescript/src/instrumentation/__tests__/milvus-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/milvus-trace-comparison.test.ts
@@ -41,7 +41,7 @@ describe('Milvus Cross-Language Trace Comparison', () => {
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
+ (OpenlitConfig as any).captureMessageContent = true;
(OpenLitHelper as any).handleException = jest.fn();
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/mistral-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/mistral-trace-comparison.test.ts
index 03d329f2..d7f5933e 100644
--- a/sdk/typescript/src/instrumentation/__tests__/mistral-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/mistral-trace-comparison.test.ts
@@ -1,68 +1,337 @@
-/**
- * Cross-Language Trace Comparison Tests for Mistral Integration
- */
-
+import { Span, trace } from '@opentelemetry/api';
import MistralWrapper from '../mistral/wrapper';
import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
import BaseWrapper from '../base-wrapper';
import SemanticConvention from '../../semantic-convention';
-jest.mock('../../config');
-jest.mock('../../helpers');
-jest.mock('../base-wrapper');
+jest.mock('../../../src/config');
+jest.mock('../../../src/helpers');
+jest.mock('../../../src/instrumentation/base-wrapper');
+
+const mockTracer = trace.getTracer('test-tracer');
-describe('Mistral Cross-Language Trace Comparison', () => {
- let mockSpan: any;
+describe('MistralWrapper', () => {
+ let span: Span;
beforeEach(() => {
- // Create mock span
- mockSpan = {
- setAttribute: jest.fn(),
- addEvent: jest.fn(),
- end: jest.fn(),
- setStatus: jest.fn(),
- };
-
- // Mock OpenlitConfig
- (OpenlitConfig as any).environment = 'openlit-testing';
- (OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
-
- // Mock OpenLitHelper
- (OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
- (OpenLitHelper as any).getEmbedModelCost = jest.fn().mockReturnValue(0.0001);
- (OpenLitHelper as any).openaiTokens = jest.fn().mockReturnValue(5);
- (OpenLitHelper as any).handleException = jest.fn();
- (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, generator) => stream);
-
- // Mock BaseWrapper
- (BaseWrapper as any).recordMetrics = jest.fn();
- (BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span, attrs) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
- if (attrs.cost !== undefined) {
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
- }
- if (attrs.serverAddress) {
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
- }
- if (attrs.serverPort !== undefined) {
- span.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
- }
- span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
- });
+ span = mockTracer.startSpan('test-span');
+ span.setAttribute = jest.fn();
+ span.addEvent = jest.fn();
+ jest.clearAllMocks();
});
afterEach(() => {
- jest.clearAllMocks();
+ span.end();
+ });
+
+ describe('_chatCompletion', () => {
+ it('should call recordMetrics after span ends', async () => {
+ const mockArgs = [{ messages: [{ role: 'user', content: 'test message' }] }];
+ const mockResponse = {
+ id: '123',
+ model: 'mistral-small-latest',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: { content: 'response text', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+ const mockGenAIEndpoint = 'mistral.chat.completions';
+ jest
+ .spyOn(MistralWrapper, '_chatCompletionCommonSetter')
+ .mockImplementationOnce(async ({ genAIEndpoint, span }) => {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, 1);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+
+ return {
+ genAIEndpoint,
+ model: 'mistral-small-latest',
+ user: 'test-user',
+ cost: 0.5,
+ aiSystem: SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
+ };
+ });
+
+ await MistralWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: mockGenAIEndpoint,
+ response: mockResponse,
+ span,
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
+ genAIEndpoint: mockGenAIEndpoint,
+ model: 'mistral-small-latest',
+ user: 'test-user',
+ cost: 0.5,
+ aiSystem: SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
+ });
+ });
+ });
+
+ describe('_chatCompletionCommonSetter', () => {
+ it('should set span attributes and return metric parameters', async () => {
+ const mockArgs = [
+ {
+ model: 'mistral-small-latest',
+ messages: [{ role: 'user', content: 'test message' }],
+ max_tokens: 100,
+ temperature: 0.7,
+ top_p: 1,
+ user: 'test-user',
+ presence_penalty: 2,
+ frequency_penalty: 3,
+ seed: 3,
+ stream: false,
+ stop: ['STOP'],
+ },
+ ];
+
+ const mockResult = {
+ id: '123',
+ model: 'mistral-small-latest',
+ usage: {
+ prompt_tokens: 10,
+ completion_tokens: 20,
+ total_tokens: 30,
+ },
+ choices: [
+ {
+ message: { content: 'response text', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+ const mockGenAIEndpoint = 'mistral.chat.completions';
+
+ jest.restoreAllMocks();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ const metricParams = await MistralWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: mockGenAIEndpoint,
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 1);
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
+ 100
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
+ 0.7
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ 2
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ 3
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 3);
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
+ false
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ ['STOP']
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'mistral-small-latest'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
+ 10
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
+ 20
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
+
+ expect(metricParams).toEqual({
+ genAIEndpoint: mockGenAIEndpoint,
+ model: 'mistral-small-latest',
+ user: 'test-user',
+ cost: 0.5,
+ aiSystem: SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
+ });
+ });
+
+ it('should NOT set sentinel values for optional request params', async () => {
+ const mockArgs = [
+ {
+ model: 'mistral-small-latest',
+ messages: [{ role: 'user', content: 'test' }],
+ stream: false,
+ },
+ ];
+
+ const mockResult = {
+ id: '456',
+ model: 'mistral-small-latest',
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ choices: [
+ {
+ message: { content: 'test response', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest.restoreAllMocks();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await MistralWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'mistral.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ const setAttrCalls = (span.setAttribute as jest.Mock).mock.calls;
+ const attrKeys = setAttrCalls.map((c: any[]) => c[0]);
+
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_SEED);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT);
+ });
+
+ it('should handle tool calls properly', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'test message' }],
+ tools: [{ type: 'function', function: { name: 'get_weather' } }],
+ },
+ ];
+
+ const mockResult = {
+ id: '123',
+ model: 'mistral-small-latest',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: {
+ content: null,
+ role: 'assistant',
+ tool_calls: [
+ {
+ id: 'call_123',
+ type: 'function',
+ function: { name: 'get_weather', arguments: '{"location":"SF"}' },
+ },
+ ],
+ },
+ finish_reason: 'tool_calls',
+ },
+ ],
+ };
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ await MistralWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'mistral.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_123'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"SF"}'
+ );
+ });
+
+ it('should emit inference event when events not disabled', async () => {
+ const mockArgs = [
+ {
+ model: 'mistral-small-latest',
+ messages: [{ role: 'user', content: 'test message' }],
+ stream: false,
+ },
+ ];
+
+ const mockResult = {
+ id: '789',
+ model: 'mistral-small-latest',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: { content: 'response text', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest.restoreAllMocks();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ await MistralWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'mistral.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ span,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'mistral-small-latest',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'mistral-small-latest',
+ [SemanticConvention.SERVER_ADDRESS]: 'api.mistral.ai',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: '789',
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 10,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 20,
+ })
+ );
+ });
});
- describe('Chat Completion Trace Consistency', () => {
- it('should set same attributes as Python SDK', async () => {
+ describe('Cross-Language Trace Comparison', () => {
+ it('should use mistral_ai as provider name (matching Python SDK)', () => {
+ expect(MistralWrapper.aiSystem).toBe('mistral_ai');
+ expect(MistralWrapper.aiSystem).toBe(SemanticConvention.GEN_AI_SYSTEM_MISTRAL);
+ });
+
+ it('should set same attributes as Python SDK for chat completion', async () => {
const mockArgs = [
{
messages: [{ role: 'user', content: 'What is Mistral AI?' }],
@@ -90,30 +359,34 @@ describe('Mistral Cross-Language Trace Comparison', () => {
total_tokens: 23,
},
};
-
+
+ jest.restoreAllMocks();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.001);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[]');
+
await MistralWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'mistral.chat.completions',
response: mockResponse,
- span: mockSpan,
+ span,
});
- // Verify critical attributes are set (matching Python SDK)
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'mistral');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MODEL, 'mistral-small-latest');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'mistral-small-latest');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 8);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 15);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 23);
- // Python SDK parity: server.address, server.port, gen_ai.sdk.version
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_ADDRESS, 'api.mistral.ai');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 8);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 15);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'mistral-small-latest');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+
+ const setAttrCalls = (span.setAttribute as jest.Mock).mock.calls;
+ const attrKeys = setAttrCalls.map((c: any[]) => c[0]);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE);
});
- });
- describe('Embedding Trace Consistency', () => {
it('should set embedding attributes matching Python SDK', async () => {
const mockArgs = [
{
@@ -131,20 +404,29 @@ describe('Mistral Cross-Language Trace Comparison', () => {
},
};
+ jest.restoreAllMocks();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ jest.spyOn(OpenLitHelper, 'getEmbedModelCost').mockReturnValue(0.0001);
+
const mockTracer: any = {
- startSpan: jest.fn().mockReturnValue(mockSpan),
+ startSpan: jest.fn().mockReturnValue(span),
};
-
+
const patchMethod = MistralWrapper._patchEmbedding(mockTracer);
const wrappedMethod = patchMethod(async () => mockResponse);
-
+
await wrappedMethod.call({}, ...mockArgs);
- // Verify embedding-specific attributes
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'mistral');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MODEL, 'mistral-embed');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 3);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 3);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, ['float']);
+
+ const setAttrCalls = (span.setAttribute as jest.Mock).mock.calls;
+ const attrKeys = setAttrCalls.map((c: any[]) => c[0]);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_SERVER_TTFT);
+ expect(attrKeys).not.toContain(SemanticConvention.GEN_AI_SERVER_TBT);
});
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/openai-wrapper.test.ts b/sdk/typescript/src/instrumentation/__tests__/openai-wrapper.test.ts
index 3648d5ce..f38cf812 100644
--- a/sdk/typescript/src/instrumentation/__tests__/openai-wrapper.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/openai-wrapper.test.ts
@@ -77,6 +77,7 @@ describe('OpenAIWrapper', () => {
it('should set span attributes and return metric parameters', async () => {
const mockArgs = [
{
+ model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: 'test message' }],
max_tokens: 100,
temperature: 0.7,
@@ -112,7 +113,7 @@ describe('OpenAIWrapper', () => {
jest.restoreAllMocks();
- jest.spyOn(OpenlitConfig, 'updatePricingJson').mockResolvedValue({});
+ (OpenlitConfig as any).pricingInfo = {};
jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
const metricParams = await OpenAIWrapper._chatCompletionCommonSetter({
@@ -140,7 +141,7 @@ describe('OpenAIWrapper', () => {
SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
3
);
- expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, '3');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 3);
expect(span.setAttribute).toHaveBeenCalledWith(
SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
false
@@ -156,22 +157,13 @@ describe('OpenAIWrapper', () => {
'gpt-3.5-turbo'
);
expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ SemanticConvention.OPENAI_RESPONSE_SYSTEM_FINGERPRINT,
'fp_test'
);
expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
+ SemanticConvention.OPENAI_RESPONSE_SERVICE_TIER,
'default'
);
- expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
- 30
- );
- expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_USAGE_COMPLETION_TOKENS_DETAILS_REASONING,
- 5
- );
-
expect(metricParams).toEqual({
genAIEndpoint: mockGenAIEndpoint,
model: 'gpt-3.5-turbo',
@@ -211,7 +203,7 @@ describe('OpenAIWrapper', () => {
],
};
- jest.spyOn(OpenlitConfig, 'updatePricingJson').mockResolvedValue({});
+ (OpenlitConfig as any).pricingInfo = {};
jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
await OpenAIWrapper._chatCompletionCommonSetter({
@@ -230,12 +222,8 @@ describe('OpenAIWrapper', () => {
'call_123'
);
expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS,
- ['{"location":"SF"}']
- );
- expect(span.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_TOOL_TYPE,
- 'function'
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"SF"}'
);
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/qdrant-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/qdrant-trace-comparison.test.ts
index 44dd8f24..5be6dfca 100644
--- a/sdk/typescript/src/instrumentation/__tests__/qdrant-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/qdrant-trace-comparison.test.ts
@@ -41,7 +41,7 @@ describe('Qdrant Cross-Language Trace Comparison', () => {
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
+ (OpenlitConfig as any).captureMessageContent = true;
(OpenLitHelper as any).handleException = jest.fn();
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/replicate-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/replicate-trace-comparison.test.ts
index 9b7f08b5..b55ab192 100644
--- a/sdk/typescript/src/instrumentation/__tests__/replicate-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/replicate-trace-comparison.test.ts
@@ -2,7 +2,8 @@
* Trace Comparison Tests for Replicate Integration
*
* Verifies that the TypeScript SDK generates consistent traces for
- * Replicate model runs.
+ * Replicate model runs, aligned with OTel semantic conventions and
+ * the OpenAI reference implementation pattern.
*/
import ReplicateWrapper from '../replicate/wrapper';
@@ -28,22 +29,30 @@ describe('Replicate Trace Comparison', () => {
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
(OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
(OpenLitHelper as any).generalTokens = jest.fn().mockReturnValue(10);
(OpenLitHelper as any).handleException = jest.fn();
+ (OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[{"role":"user","parts":[{"type":"text","content":"What is the capital of France?"}]}]');
+ (OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[{"role":"assistant","parts":[{"type":"text","content":"Paris."}],"finish_reason":"stop"}]');
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
(BaseWrapper as any).recordMetrics = jest.fn();
(BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span: any, attrs: any) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
- if (attrs.cost !== undefined) span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
- if (attrs.serverAddress) span.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
- if (attrs.serverPort !== undefined) span.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
+ if (attrs.cost !== undefined) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
+ }
+ if (attrs.serverAddress) {
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
+ }
+ if (attrs.serverPort !== undefined) {
+ span.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
+ }
span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
});
});
@@ -52,14 +61,14 @@ describe('Replicate Trace Comparison', () => {
jest.clearAllMocks();
});
- describe('run() — text output', () => {
+ describe('run() — core attributes', () => {
const identifier = 'meta/llama-2-70b-chat';
const mockArgs = [
identifier,
{ input: { prompt: 'What is the capital of France?' } },
];
- it('should set gen_ai.system = "replicate"', async () => {
+ it('should set gen_ai.provider.name = "replicate"', async () => {
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
@@ -68,7 +77,7 @@ describe('Replicate Trace Comparison', () => {
});
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_PROVIDER_NAME,
+ SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL,
'replicate'
);
});
@@ -106,7 +115,7 @@ describe('Replicate Trace Comparison', () => {
);
});
- it('should set text_completion operation', async () => {
+ it('should set gen_ai.response.model', async () => {
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
@@ -115,11 +124,82 @@ describe('Replicate Trace Comparison', () => {
});
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'meta/llama-2-70b-chat'
+ );
+ });
+
+ it('should set gen_ai.request.is_stream = false', async () => {
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Paris.',
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
+ false
);
});
+ it('should set gen_ai.response.finish_reasons = ["stop"]', async () => {
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Paris.',
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ ['stop']
+ );
+ });
+
+ it('should set server.address and server.port', async () => {
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Paris.',
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.SERVER_ADDRESS,
+ 'api.replicate.com'
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.SERVER_PORT,
+ 443
+ );
+ });
+
+ it('should set token usage attributes', async () => {
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Paris.',
+ span: mockSpan,
+ });
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
+ 10
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
+ 10
+ );
+ });
+ });
+
+ describe('run() — output types', () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'What is the capital of France?' } },
+ ];
+
it('should set output_type=text for string responses', async () => {
await ReplicateWrapper._run({
args: mockArgs,
@@ -134,7 +214,7 @@ describe('Replicate Trace Comparison', () => {
);
});
- it('should set output_type=text for array responses (streaming text chunks)', async () => {
+ it('should set output_type=text for array responses (text chunks)', async () => {
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
@@ -161,8 +241,39 @@ describe('Replicate Trace Comparison', () => {
SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON
);
});
+ });
+
+ describe('run() — no sentinel values', () => {
+ it('should NOT set total_tokens or client.token.usage on span', async () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'Test' } },
+ ];
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ const setAttributeCalls = (mockSpan.setAttribute as jest.Mock).mock.calls;
+ const attributeKeys = setAttributeCalls.map(([key]: [string]) => key);
+
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE);
+ });
+ });
+
+ describe('run() — content capture', () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'What is the capital of France?' } },
+ ];
+
+ it('should capture input/output messages when captureMessageContent=true', async () => {
+ (OpenlitConfig as any).captureMessageContent = true;
- it('should set server.address = api.replicate.com and port 443', async () => {
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
@@ -170,14 +281,21 @@ describe('Replicate Trace Comparison', () => {
span: mockSpan,
});
+ expect(OpenLitHelper.buildInputMessages).toHaveBeenCalled();
+ expect(OpenLitHelper.buildOutputMessages).toHaveBeenCalled();
expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.SERVER_ADDRESS,
- 'api.replicate.com'
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ expect.any(String)
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ expect.any(String)
);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
});
- it('should capture prompt content when traceContent=true', async () => {
+ it('should NOT capture messages when captureMessageContent=false', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
@@ -185,17 +303,149 @@ describe('Replicate Trace Comparison', () => {
span: mockSpan,
});
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(
- SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
- 'What is the capital of France?'
+ const setAttributeCalls = (mockSpan.setAttribute as jest.Mock).mock.calls;
+ const attributeKeys = setAttributeCalls.map(([key]: [string]) => key);
+
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_INPUT_MESSAGES);
+ expect(attributeKeys).not.toContain(SemanticConvention.GEN_AI_OUTPUT_MESSAGES);
+ });
+ });
+
+ describe('run() — events', () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'Test' } },
+ ];
+
+ it('should emit inference event via LoggerProvider', async () => {
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'meta/llama-2-70b-chat',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'meta/llama-2-70b-chat',
+ [SemanticConvention.SERVER_ADDRESS]: 'api.replicate.com',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 10,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 10,
+ })
+ );
+ });
+
+ it('should include message content in event when captureMessageContent=true', async () => {
+ (OpenlitConfig as any).captureMessageContent = true;
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_INPUT_MESSAGES]: expect.any(String),
+ [SemanticConvention.GEN_AI_OUTPUT_MESSAGES]: expect.any(String),
+ })
+ );
+ });
+
+ it('should NOT include message content in event when captureMessageContent=false', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ const eventCall = (OpenLitHelper.emitInferenceEvent as jest.Mock).mock.calls[0];
+ const eventAttrs = eventCall[1];
+ expect(eventAttrs).not.toHaveProperty(SemanticConvention.GEN_AI_INPUT_MESSAGES);
+ expect(eventAttrs).not.toHaveProperty(SemanticConvention.GEN_AI_OUTPUT_MESSAGES);
+ });
+
+ it('should NOT emit events when disableEvents=true', async () => {
+ (OpenlitConfig as any).disableEvents = true;
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.emitInferenceEvent).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('run() — metrics', () => {
+ it('should record metrics via BaseWrapper.recordMetrics', async () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'Test' } },
+ ];
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ genAIEndpoint: 'replicate.run',
+ model: 'meta/llama-2-70b-chat',
+ aiSystem: 'replicate',
+ })
+ );
+ });
+
+ it('should use OpenlitConfig.pricingInfo for cost calculation', async () => {
+ (OpenlitConfig as any).pricingInfo = { chat: { 'meta/llama-2-70b-chat': { promptPrice: 0.05, completionPrice: 0.08 } } };
+
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'Test' } },
+ ];
+
+ await ReplicateWrapper._run({
+ args: mockArgs,
+ genAIEndpoint: 'replicate.run',
+ response: 'Response',
+ span: mockSpan,
+ });
+
+ expect(OpenLitHelper.getChatModelCost).toHaveBeenCalledWith(
+ 'meta/llama-2-70b-chat',
+ expect.any(Object),
+ 10,
+ 10
);
});
it('should end span and record metrics', async () => {
+ const mockArgs = [
+ 'meta/llama-2-70b-chat',
+ { input: { prompt: 'Test' } },
+ ];
+
await ReplicateWrapper._run({
args: mockArgs,
genAIEndpoint: 'replicate.run',
- response: 'Paris.',
+ response: 'Response',
span: mockSpan,
});
@@ -203,4 +453,16 @@ describe('Replicate Trace Comparison', () => {
expect(BaseWrapper.recordMetrics).toHaveBeenCalled();
});
});
+
+ describe('Span Creation Attributes', () => {
+ it('should use aiSystem from SemanticConvention.GEN_AI_SYSTEM_REPLICATE', () => {
+ expect(ReplicateWrapper.aiSystem).toBe(SemanticConvention.GEN_AI_SYSTEM_REPLICATE);
+ expect(ReplicateWrapper.aiSystem).toBe('replicate');
+ });
+
+ it('should set correct server address and port', () => {
+ expect(ReplicateWrapper.serverAddress).toBe('api.replicate.com');
+ expect(ReplicateWrapper.serverPort).toBe(443);
+ });
+ });
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/together-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/together-trace-comparison.test.ts
index 6c6bc067..86e2b778 100644
--- a/sdk/typescript/src/instrumentation/__tests__/together-trace-comparison.test.ts
+++ b/sdk/typescript/src/instrumentation/__tests__/together-trace-comparison.test.ts
@@ -2,62 +2,37 @@
* Cross-Language Trace Comparison Tests for Together AI Integration
*/
+import { Span, trace } from '@opentelemetry/api';
import TogetherWrapper from '../together/wrapper';
import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
import BaseWrapper from '../base-wrapper';
import SemanticConvention from '../../semantic-convention';
-jest.mock('../../config');
-jest.mock('../../helpers');
-jest.mock('../base-wrapper');
+jest.mock('../../../src/config');
+jest.mock('../../../src/helpers');
+jest.mock('../../../src/instrumentation/base-wrapper');
+
+const mockTracer = trace.getTracer('test-tracer');
describe('Together AI Cross-Language Trace Comparison', () => {
- let mockSpan: any;
+ let span: Span;
beforeEach(() => {
- // Create mock span
- mockSpan = {
- setAttribute: jest.fn(),
- addEvent: jest.fn(),
- end: jest.fn(),
- setStatus: jest.fn(),
- };
-
- // Mock OpenlitConfig
+ span = mockTracer.startSpan('test-span');
+ span.setAttribute = jest.fn();
+ span.addEvent = jest.fn();
+ jest.clearAllMocks();
+
(OpenlitConfig as any).environment = 'openlit-testing';
(OpenlitConfig as any).applicationName = 'openlit-test';
- (OpenlitConfig as any).traceContent = true;
- (OpenlitConfig as any).pricing_json = {};
- (OpenlitConfig as any).updatePricingJson = jest.fn().mockResolvedValue({});
-
- // Mock OpenLitHelper
- (OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
- (OpenLitHelper as any).openaiTokens = jest.fn().mockReturnValue(5);
- (OpenLitHelper as any).handleException = jest.fn();
- (OpenLitHelper as any).createStreamProxy = jest.fn().mockImplementation((stream, generator) => stream);
-
- // Mock BaseWrapper
- (BaseWrapper as any).recordMetrics = jest.fn();
- (BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span, attrs) => {
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
- if (attrs.cost !== undefined) {
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
- }
- if (attrs.serverAddress) {
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
- }
- if (attrs.serverPort !== undefined) {
- span.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
- }
- span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
- });
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
});
afterEach(() => {
- jest.clearAllMocks();
+ span.end();
});
describe('Chat Completion Trace Consistency', () => {
@@ -90,26 +65,267 @@ describe('Together AI Cross-Language Trace Comparison', () => {
total_tokens: 21,
},
};
-
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.001);
+
await TogetherWrapper._chatCompletion({
args: mockArgs,
genAIEndpoint: 'together.chat.completions',
response: mockResponse,
- span: mockSpan,
+ span,
});
- // Verify critical attributes are set (matching Python SDK)
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'together');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MODEL, 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 9);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 12);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, 21);
- // Python SDK parity: server.address, server.port, gen_ai.sdk.version
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_ADDRESS, 'api.together.xyz');
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.SERVER_PORT, 443);
- expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SDK_VERSION, '1.9.0');
+ // setBaseSpanAttributes is mocked; verify it was called with Together-specific params
+ expect(BaseWrapper.setBaseSpanAttributes).toHaveBeenCalledWith(span, expect.objectContaining({
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ aiSystem: 'together',
+ serverAddress: 'api.together.xyz',
+ serverPort: 443,
+ }));
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 9);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 12);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, 'together-test-id');
+
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, expect.anything());
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, expect.anything());
+ });
+
+ it('should set request parameters correctly with no sentinel values', async () => {
+ const mockArgs = [
+ {
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ messages: [{ role: 'user', content: 'test message' }],
+ max_tokens: 100,
+ temperature: 0.7,
+ top_p: 0.9,
+ presence_penalty: 0.5,
+ frequency_penalty: 0.3,
+ seed: 42,
+ stream: false,
+ stop: ['STOP'],
+ n: 2,
+ },
+ ];
+
+ const mockResult = {
+ id: 'test-123',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: { content: 'response text', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ const metricParams = await TogetherWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'together.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 0.9);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 0.5);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0.3);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 42);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, ['STOP']);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, 2);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'text');
+
+ expect(metricParams).toEqual({
+ genAIEndpoint: 'together.chat.completions',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ user: undefined,
+ cost: 0.5,
+ aiSystem: 'together',
+ });
+ });
+
+ it('should not set sentinel values for optional attributes', async () => {
+ const mockArgs = [
+ {
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ messages: [{ role: 'user', content: 'test' }],
+ stream: false,
+ },
+ ];
+
+ const mockResult = {
+ id: 'test-123',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ choices: [
+ {
+ message: { content: 'response', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await TogetherWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'together.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, -1);
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 0);
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 0);
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, '');
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 0);
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0);
+ expect(span.setAttribute).not.toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, 1);
+ });
+
+ it('should handle tool calls properly', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'test message' }],
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ tools: [{ type: 'function', function: { name: 'get_weather' } }],
+ stream: false,
+ },
+ ];
+
+ const mockResult = {
+ id: '123',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: {
+ content: null,
+ role: 'assistant',
+ tool_calls: [
+ {
+ id: 'call_123',
+ type: 'function',
+ function: { name: 'get_weather', arguments: '{"location":"SF"}' },
+ },
+ ],
+ },
+ finish_reason: 'tool_calls',
+ },
+ ],
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.5);
+
+ await TogetherWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'together.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'get_weather'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_123'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"location":"SF"}'
+ );
+ });
+
+ it('should emit inference event via LoggerProvider', async () => {
+ const mockArgs = [
+ {
+ messages: [{ role: 'user', content: 'Hello' }],
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ stream: false,
+ },
+ ];
+
+ const mockResult = {
+ id: 'test-event-id',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
+ choices: [
+ {
+ message: { content: 'Hi there', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation();
+
+ await TogetherWrapper._chatCompletionCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'together.chat.completions',
+ result: mockResult,
+ span,
+ });
+
+ expect(emitSpy).toHaveBeenCalledWith(span, expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ [SemanticConvention.SERVER_ADDRESS]: 'api.together.xyz',
+ [SemanticConvention.SERVER_PORT]: 443,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: 'test-event-id',
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: 5,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: 10,
+ }));
+ });
+
+ it('should call recordMetrics after span ends', async () => {
+ const mockArgs = [{ messages: [{ role: 'user', content: 'test message' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' }];
+ const mockResponse = {
+ id: '123',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
+ choices: [
+ {
+ message: { content: 'response text', role: 'assistant' },
+ finish_reason: 'stop',
+ },
+ ],
+ };
+
+ jest
+ .spyOn(TogetherWrapper, '_chatCompletionCommonSetter')
+ .mockImplementationOnce(async () => ({
+ genAIEndpoint: 'together.chat.completions',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ user: undefined,
+ cost: 0.5,
+ aiSystem: 'together',
+ }));
+
+ await TogetherWrapper._chatCompletion({
+ args: mockArgs,
+ genAIEndpoint: 'together.chat.completions',
+ response: mockResponse,
+ span,
+ });
+
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(span, {
+ genAIEndpoint: 'together.chat.completions',
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
+ user: undefined,
+ cost: 0.5,
+ aiSystem: 'together',
+ });
});
});
});
diff --git a/sdk/typescript/src/instrumentation/__tests__/vercel-ai-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/vercel-ai-trace-comparison.test.ts
new file mode 100644
index 00000000..81b081c5
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/__tests__/vercel-ai-trace-comparison.test.ts
@@ -0,0 +1,523 @@
+/**
+ * Cross-Language Trace Comparison Tests for Vercel AI Integration
+ *
+ * Vercel AI is JS-only (no Python equivalent). These tests verify that the
+ * Vercel AI instrumentation follows the same OTel conventions and patterns
+ * as the OpenAI reference wrapper.
+ */
+
+import { Span, trace } from '@opentelemetry/api';
+import VercelAIWrapper from '../vercel-ai/wrapper';
+import OpenlitConfig from '../../config';
+import OpenLitHelper from '../../helpers';
+import BaseWrapper from '../base-wrapper';
+import SemanticConvention from '../../semantic-convention';
+
+jest.mock('../../../src/config');
+jest.mock('../../../src/helpers');
+jest.mock('../../../src/instrumentation/base-wrapper');
+
+const mockTracer = trace.getTracer('test-tracer');
+
+describe('VercelAIWrapper', () => {
+ let span: Span;
+
+ beforeEach(() => {
+ span = mockTracer.startSpan('test-span');
+ span.setAttribute = jest.fn();
+ span.addEvent = jest.fn();
+ jest.clearAllMocks();
+
+ (OpenlitConfig as any).environment = 'openlit-testing';
+ (OpenlitConfig as any).applicationName = 'openlit-test';
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
+
+ (OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.001);
+ (OpenLitHelper as any).getEmbedModelCost = jest.fn().mockReturnValue(0.0001);
+ (OpenLitHelper as any).handleException = jest.fn();
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
+ (OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[{"role":"user","parts":[{"type":"text","content":"Hello"}]}]');
+ (OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[{"role":"assistant","parts":[{"type":"text","content":"Hi"}],"finish_reason":"stop"}]');
+
+ (BaseWrapper as any).recordMetrics = jest.fn();
+ (BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((s, attrs) => {
+ s.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, attrs.aiSystem);
+ s.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, attrs.genAIEndpoint);
+ s.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
+ if (attrs.cost !== undefined) {
+ s.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
+ }
+ if (attrs.serverAddress) {
+ s.setAttribute(SemanticConvention.SERVER_ADDRESS, attrs.serverAddress);
+ }
+ if (attrs.serverPort !== undefined) {
+ s.setAttribute(SemanticConvention.SERVER_PORT, attrs.serverPort);
+ }
+ });
+ });
+
+ afterEach(() => {
+ span.end();
+ });
+
+ describe('static fields', () => {
+ it('should have correct aiSystem', () => {
+ expect(VercelAIWrapper.aiSystem).toBe('vercel_ai');
+ });
+
+ it('should have serverAddress and serverPort', () => {
+ expect(VercelAIWrapper.serverAddress).toBe('vercel.ai');
+ expect(VercelAIWrapper.serverPort).toBe(443);
+ });
+ });
+
+ describe('_chatComplete (non-streaming)', () => {
+ it('should call _chatCommonSetter and recordMetrics', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ temperature: 0.7,
+ },
+ ];
+
+ const mockResponse = {
+ text: 'Hi there!',
+ finishReason: 'stop',
+ usage: { promptTokens: 10, completionTokens: 5 },
+ toolCalls: [],
+ response: { id: 'resp-123', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ span.addEvent = jest.fn();
+ span.end = jest.fn();
+
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.001);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ const result = await VercelAIWrapper._chatComplete({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ response: mockResponse,
+ span,
+ outputType: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ });
+
+ expect(result).toBe(mockResponse);
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalled();
+ });
+ });
+
+ describe('_chatCommonSetter', () => {
+ it('should set all required span attributes', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ temperature: 0.7,
+ topP: 0.9,
+ maxTokens: 100,
+ seed: 42,
+ frequencyPenalty: 0.5,
+ presencePenalty: 0.3,
+ stopSequences: ['END'],
+ topK: 50,
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi there!',
+ finishReason: 'stop',
+ usage: { promptTokens: 10, completionTokens: 5 },
+ toolCalls: [],
+ response: { id: 'resp-123', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.001);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ const metricParams = await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.7);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 0.9);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 100);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_SEED, 42);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0.5);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 0.3);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, ['END']);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_K, 50);
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_MODEL, 'gpt-4o-mini');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_ID, 'resp-123');
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 10);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 5);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'text');
+
+ expect(metricParams).toEqual({
+ genAIEndpoint: 'vercel_ai.generateText',
+ model: 'gpt-4o-mini',
+ cost: 0.001,
+ aiSystem: 'vercel_ai',
+ serverAddress: 'vercel.ai',
+ serverPort: 443,
+ });
+ });
+
+ it('should not set sentinel values', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi',
+ finishReason: 'stop',
+ usage: { promptTokens: 10, completionTokens: 5 },
+ toolCalls: [],
+ response: { id: 'resp-123', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ const calls = (span.setAttribute as jest.Mock).mock.calls;
+ const attrMap = new Map(calls.map(([k, v]) => [k, v]));
+
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS)).toBe(false);
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_SEED)).toBe(false);
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY)).toBe(false);
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY)).toBe(false);
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES)).toBe(false);
+ expect(attrMap.has(SemanticConvention.GEN_AI_REQUEST_TOP_K)).toBe(false);
+ });
+
+ it('should set response model from provider response, distinct from request model', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi',
+ finishReason: 'stop',
+ usage: { promptTokens: 5, completionTokens: 3 },
+ toolCalls: [],
+ response: { id: 'resp-456', modelId: 'gpt-4o-2024-08-06' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_MODEL,
+ 'gpt-4o-2024-08-06'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_ID,
+ 'resp-456'
+ );
+ });
+
+ it('should handle tool calls', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Weather?' }],
+ },
+ ];
+
+ const mockResult = {
+ text: '',
+ finishReason: 'tool_calls',
+ usage: { promptTokens: 15, completionTokens: 10 },
+ toolCalls: [
+ { toolCallId: 'call_abc', toolName: 'getWeather', args: { city: 'SF' } },
+ ],
+ response: { id: 'resp-789', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.002);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[]');
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_NAME,
+ 'getWeather'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_CALL_ID,
+ 'call_abc'
+ );
+ expect(span.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_TOOL_ARGS,
+ '{"city":"SF"}'
+ );
+ });
+
+ it('should emit inference event with all required attributes', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi',
+ finishReason: 'stop',
+ usage: { promptTokens: 10, completionTokens: 5 },
+ toolCalls: [],
+ response: { id: 'resp-evt', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.001);
+ jest.spyOn(OpenLitHelper, 'buildInputMessages').mockReturnValue('[{"role":"user"}]');
+ jest.spyOn(OpenLitHelper, 'buildOutputMessages').mockReturnValue('[{"role":"assistant"}]');
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ expect(emitSpy).toHaveBeenCalledTimes(1);
+ const eventAttrs = emitSpy.mock.calls[0][1];
+ expect(eventAttrs[SemanticConvention.GEN_AI_OPERATION]).toBe('chat');
+ expect(eventAttrs[SemanticConvention.GEN_AI_REQUEST_MODEL]).toBe('gpt-4o-mini');
+ expect(eventAttrs[SemanticConvention.GEN_AI_RESPONSE_MODEL]).toBe('gpt-4o-mini');
+ expect(eventAttrs[SemanticConvention.SERVER_ADDRESS]).toBe('vercel.ai');
+ expect(eventAttrs[SemanticConvention.SERVER_PORT]).toBe(443);
+ expect(eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID]).toBe('resp-evt');
+ expect(eventAttrs[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]).toEqual(['stop']);
+ expect(eventAttrs[SemanticConvention.GEN_AI_OUTPUT_TYPE]).toBe('text');
+ expect(eventAttrs[SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]).toBe(10);
+ expect(eventAttrs[SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]).toBe(5);
+ expect(eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES]).toBe('[{"role":"user"}]');
+ expect(eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]).toBe('[{"role":"assistant"}]');
+ });
+
+ it('should not include message content in event when captureMessageContent is false', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'secret' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'reply',
+ finishReason: 'stop',
+ usage: { promptTokens: 5, completionTokens: 3 },
+ toolCalls: [],
+ response: { id: 'resp-no-content', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = false;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+ const emitSpy = jest.spyOn(OpenLitHelper, 'emitInferenceEvent').mockImplementation(() => {});
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ expect(emitSpy).toHaveBeenCalledTimes(1);
+ const eventAttrs = emitSpy.mock.calls[0][1];
+ expect(eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES]).toBeUndefined();
+ expect(eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]).toBeUndefined();
+ });
+
+ it('should set TTFT and TBT for streaming', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi',
+ finishReason: 'stop',
+ usage: { promptTokens: 10, completionTokens: 5 },
+ toolCalls: [],
+ response: { id: 'resp-stream', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0);
+
+ await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.streamText',
+ result: mockResult,
+ span,
+ isStream: true,
+ outputType: 'text',
+ ttft: 0.15,
+ tbt: 0.025,
+ });
+
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TTFT, 0.15);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TBT, 0.025);
+ expect(span.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
+ });
+
+ it('should use pricing from OpenlitConfig.pricingInfo', async () => {
+ const mockArgs = [
+ {
+ model: { modelId: 'gpt-4o-mini' },
+ messages: [{ role: 'user', content: 'Hello' }],
+ },
+ ];
+
+ const mockResult = {
+ text: 'Hi',
+ finishReason: 'stop',
+ usage: { promptTokens: 100, completionTokens: 50 },
+ toolCalls: [],
+ response: { id: 'resp-price', modelId: 'gpt-4o-mini' },
+ };
+
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ const pricingInfo = { chat: { 'gpt-4o-mini': { promptPrice: 0.15, completionPrice: 0.6 } } };
+ (OpenlitConfig as any).pricingInfo = pricingInfo;
+ (OpenlitConfig as any).captureMessageContent = false;
+ (OpenlitConfig as any).disableEvents = true;
+ jest.spyOn(OpenLitHelper, 'getChatModelCost').mockReturnValue(0.045);
+
+ const metricParams = await VercelAIWrapper._chatCommonSetter({
+ args: mockArgs,
+ genAIEndpoint: 'vercel_ai.generateText',
+ result: mockResult,
+ span,
+ isStream: false,
+ outputType: 'text',
+ });
+
+ expect(OpenLitHelper.getChatModelCost).toHaveBeenCalledWith(
+ 'gpt-4o-mini',
+ pricingInfo,
+ 100,
+ 50
+ );
+ expect(metricParams?.cost).toBe(0.045);
+ });
+ });
+
+ describe('serverAddress and serverPort in error path', () => {
+ it('should include serverAddress and serverPort in recordMetrics on error', async () => {
+ jest.restoreAllMocks();
+ span.setAttribute = jest.fn();
+ span.end = jest.fn();
+ (OpenLitHelper as any).handleException = jest.fn();
+ (BaseWrapper as any).recordMetrics = jest.fn();
+
+ jest.spyOn(VercelAIWrapper, '_chatCommonSetter').mockRejectedValue(new TypeError('fail'));
+
+ try {
+ await VercelAIWrapper._chatComplete({
+ args: [{ model: { modelId: 'gpt-4o-mini' } }],
+ genAIEndpoint: 'vercel_ai.generateText',
+ response: {},
+ span,
+ outputType: 'text',
+ });
+ } catch {
+ // expected
+ }
+
+ expect(OpenLitHelper.handleException).toHaveBeenCalledWith(span, expect.any(TypeError));
+ });
+ });
+});
diff --git a/sdk/typescript/src/instrumentation/anthropic/index.ts b/sdk/typescript/src/instrumentation/anthropic/index.ts
index c5e40a97..24dbe0c4 100644
--- a/sdk/typescript/src/instrumentation/anthropic/index.ts
+++ b/sdk/typescript/src/instrumentation/anthropic/index.ts
@@ -6,7 +6,6 @@ import {
} from '@opentelemetry/instrumentation';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { INSTRUMENTATION_PREFIX } from '../../constant';
-import Anthropic from '@anthropic-ai/sdk';
import AnthropicWrapper from './wrapper';
export interface AnthropicInstrumentationConfig extends InstrumentationConfig {}
@@ -37,7 +36,7 @@ export default class OpenlitAnthropicInstrumentation extends InstrumentationBase
this._patch(anthropic);
}
- protected _patch(moduleExports: typeof Anthropic) {
+ protected _patch(moduleExports: any) {
try {
const AnthropicClass = (moduleExports as any).Anthropic ?? moduleExports;
if (isWrapped(AnthropicClass.Messages.prototype.create)) {
@@ -54,7 +53,7 @@ export default class OpenlitAnthropicInstrumentation extends InstrumentationBase
}
}
- protected _unpatch(moduleExports: typeof Anthropic) {
+ protected _unpatch(moduleExports: any) {
const AnthropicClass = (moduleExports as any).Anthropic ?? moduleExports;
this._unwrap(AnthropicClass.Messages.prototype, 'create');
}
diff --git a/sdk/typescript/src/instrumentation/anthropic/wrapper.ts b/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
index aa72e6fe..44b3dbfd 100644
--- a/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
@@ -1,8 +1,32 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
-import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+import BaseWrapper from '../base-wrapper';
+
+const FINISH_REASON_MAP: Record<string, string> = {
+ end_turn: 'stop',
+ max_tokens: 'length',
+ stop_sequence: 'stop',
+ tool_use: 'tool_call',
+};
+
+function mapFinishReason(reason: string): string {
+ return FINISH_REASON_MAP[reason] || reason || 'stop';
+}
+
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: AnthropicWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: AnthropicWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: AnthropicWrapper.serverPort,
+ };
+}
export default class AnthropicWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC;
@@ -13,14 +37,22 @@ export default class AnthropicWrapper extends BaseWrapper {
const genAIEndpoint = 'anthropic.resources.messages';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- const { stream = false } = args[0];
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'claude-3-5-sonnet-latest';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
- if (!!stream) {
+ const { stream = false } = args[0];
+
+ if (stream) {
return OpenLitHelper.createStreamProxy(
response,
AnthropicWrapper._messageCreateGenerator({
@@ -36,6 +68,14 @@ export default class AnthropicWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: AnthropicWrapper.aiSystem,
+ serverAddress: AnthropicWrapper.serverAddress,
+ serverPort: AnthropicWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -53,14 +93,8 @@ export default class AnthropicWrapper extends BaseWrapper {
genAIEndpoint: string;
response: any;
span: Span;
- }) {
- let metricParams: BaseSpanAttributes = {
- genAIEndpoint,
- model: '',
- user: '',
- cost: 0,
- aiSystem: AnthropicWrapper.aiSystem,
- };
+ }): Promise<any> {
+ let metricParams;
try {
metricParams = await AnthropicWrapper._messageCreateCommonSetter({
args,
@@ -71,9 +105,12 @@ export default class AnthropicWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- BaseWrapper.recordMetrics(span, metricParams);
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
}
}
@@ -87,75 +124,102 @@ export default class AnthropicWrapper extends BaseWrapper {
genAIEndpoint: string;
response: any;
span: Span;
- }) {
- let metricParams: BaseSpanAttributes | undefined;
+ }): AsyncGenerator<unknown, any, unknown> {
+ let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
+
try {
const result = {
- id: '0',
+ id: '',
model: '',
stop_reason: '',
- content: [
- {
- text: '',
- role: '',
- },
- ],
+ content: [] as any[],
usage: {
input_tokens: 0,
output_tokens: 0,
- total_tokens: 0,
cache_creation_input_tokens: 0,
cache_read_input_tokens: 0,
},
};
+
+ let llmResponse = '';
+ let toolId = '';
+ let toolName = '';
+ let toolArguments = '';
+
for await (const chunk of response) {
timestamps.push(Date.now());
- switch (chunk.type) {
- case 'content_block_delta':
- result.content[0].text += chunk.delta?.text ?? '';
- break;
- case 'message_stop':
- break;
-
- case 'content_block_stop':
- break;
+ switch (chunk.type) {
case 'message_start':
if (chunk.message) {
result.id = chunk.message.id;
result.model = chunk.message.model;
- result.content[0].role = chunk.message.role;
- result.usage.input_tokens += Number(chunk.message.usage?.input_tokens) ?? 0;
- result.usage.output_tokens += Number(chunk.message.usage?.output_tokens) ?? 0;
- result.usage.cache_creation_input_tokens = Number(chunk.message.usage?.cache_creation_input_tokens) || 0;
- result.usage.cache_read_input_tokens = Number(chunk.message.usage?.cache_read_input_tokens) || 0;
- result.stop_reason = chunk.message?.stop_reason ?? '';
+ result.usage.input_tokens = Number(chunk.message.usage?.input_tokens) || 0;
+ result.usage.output_tokens += Number(chunk.message.usage?.output_tokens) || 0;
+ result.usage.cache_creation_input_tokens =
+ Number(chunk.message.usage?.cache_creation_input_tokens) || 0;
+ result.usage.cache_read_input_tokens =
+ Number(chunk.message.usage?.cache_read_input_tokens) || 0;
+ result.stop_reason = chunk.message.stop_reason || '';
}
break;
case 'content_block_start':
- result.content[0].text = chunk.content_block?.text ?? '';
+ if (chunk.content_block?.type === 'tool_use') {
+ toolId = chunk.content_block.id || '';
+ toolName = chunk.content_block.name || '';
+ toolArguments = '';
+ }
break;
+
+ case 'content_block_delta':
+ if (chunk.delta?.text) {
+ llmResponse += chunk.delta.text;
+ }
+ if (chunk.delta?.partial_json) {
+ toolArguments += chunk.delta.partial_json;
+ }
+ break;
+
+ case 'content_block_stop':
+ break;
+
case 'message_delta':
- result.stop_reason = chunk.delta?.stop_reason ?? '';
- result.usage.output_tokens += Number(chunk.usage?.output_tokens) ?? 0;
- if (chunk.usage?.cache_creation_input_tokens) {
- result.usage.cache_creation_input_tokens = Number(chunk.usage.cache_creation_input_tokens) || 0;
+ result.stop_reason = chunk.delta?.stop_reason || result.stop_reason;
+ result.usage.output_tokens += Number(chunk.usage?.output_tokens) || 0;
+ if (chunk.usage?.cache_creation_input_tokens != null) {
+ result.usage.cache_creation_input_tokens =
+ Number(chunk.usage.cache_creation_input_tokens) || 0;
}
- if (chunk.usage?.cache_read_input_tokens) {
- result.usage.cache_read_input_tokens = Number(chunk.usage.cache_read_input_tokens) || 0;
+ if (chunk.usage?.cache_read_input_tokens != null) {
+ result.usage.cache_read_input_tokens =
+ Number(chunk.usage.cache_read_input_tokens) || 0;
}
break;
+
+ case 'message_stop':
+ break;
}
yield chunk;
}
- result.usage.total_tokens = result.usage.output_tokens + result.usage.input_tokens;
+ if (llmResponse) {
+ result.content.push({ type: 'text', text: llmResponse });
+ }
+ if (toolId) {
+ let parsedInput = {};
+ try { parsedInput = JSON.parse(toolArguments); } catch { /* keep empty */ }
+ result.content.push({
+ type: 'tool_use',
+ id: toolId,
+ name: toolName,
+ input: parsedInput,
+ });
+ }
- // Calculate TTFT and TBT
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -171,9 +235,11 @@ export default class AnthropicWrapper extends BaseWrapper {
ttft,
tbt,
});
- return response;
+
+ return result;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -197,7 +263,8 @@ export default class AnthropicWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'claude-3-5-sonnet-latest';
const {
messages,
system,
@@ -206,23 +273,46 @@ export default class AnthropicWrapper extends BaseWrapper {
temperature = 1,
top_p,
top_k,
- user,
+ stop_sequences = null,
stream = false,
+ user,
} = args[0];
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
+ if (top_k != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, top_k);
+ }
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
+ if (stop_sequences && Array.isArray(stop_sequences) && stop_sequences.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, stop_sequences);
+ }
+
+ if (captureContent) {
+ const systemStr = typeof system === 'string' ? system : undefined;
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages(messages || [], systemStr)
+ );
+ if (system) {
+ const sysAttr = typeof system === 'string' ? system : JSON.stringify(system);
+ span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, sysAttr);
+ }
+ }
- const model = result.model || 'claude-3-sonnet-20240229';
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const responseModel = result.model || requestModel;
- // Calculate cost of the operation
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
result.usage.input_tokens,
result.usage.output_tokens
@@ -230,7 +320,7 @@ export default class AnthropicWrapper extends BaseWrapper {
AnthropicWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: AnthropicWrapper.aiSystem,
@@ -238,39 +328,13 @@ export default class AnthropicWrapper extends BaseWrapper {
serverPort: AnthropicWrapper.serverPort,
});
- // Response model
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, model);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- // Request Params attributes : Start
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, top_k);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
-
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, seed);
-
- // System instructions
- if (system) {
- const systemStr = typeof system === 'string' ? system : JSON.stringify(system);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, systemStr);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS_OTEL, systemStr);
- }
+ const inputTokens = result.usage.input_tokens;
+ const outputTokens = result.usage.output_tokens;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
- }
- // Request Params attributes : End
-
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, result.usage.input_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, result.usage.output_tokens);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
- result.usage.input_tokens + result.usage.output_tokens
- );
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.usage.input_tokens + result.usage.output_tokens);
-
- // Cache token attributes (Anthropic prompt caching)
if (result.usage.cache_creation_input_tokens) {
span.setAttribute(
SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
@@ -284,7 +348,6 @@ export default class AnthropicWrapper extends BaseWrapper {
);
}
- // TTFT and TBT streaming metrics
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -292,40 +355,74 @@ export default class AnthropicWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- if (result.stop_reason) {
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.stop_reason]);
- }
+ const finishReason = mapFinishReason(result.stop_reason);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- // Tool calls from content blocks of type 'tool_use'
const toolUseBlocks = (result.content || []).filter((b: any) => b.type === 'tool_use');
+ const outputType = toolUseBlocks.length > 0
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
if (toolUseBlocks.length > 0) {
const toolNames = toolUseBlocks.map((b: any) => b.name || '').filter(Boolean);
const toolIds = toolUseBlocks.map((b: any) => b.id || '').filter(Boolean);
const toolArgs = toolUseBlocks.map((b: any) => JSON.stringify(b.input || {}));
if (toolNames.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
if (toolIds.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
- if (toolArgs.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON);
- } else {
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ if (toolArgs.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
- if (traceContent) {
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
const textContent = (result.content || [])
.filter((b: any) => b.type === 'text')
.map((b: any) => b.text || '')
.join('');
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(textContent, result.stop_reason || 'stop', toolUseBlocks.length > 0 ? toolUseBlocks : undefined));
+ const toolCallsForOutput = toolUseBlocks.length > 0
+ ? toolUseBlocks.map((b: any) => ({
+ id: b.id || '',
+ name: b.name || '',
+ arguments: b.input || {},
+ }))
+ : undefined;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ textContent,
+ finishReason,
+ toolCallsForOutput
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ const systemStr = typeof system === 'string' ? system : undefined;
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || [], systemStr);
}
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: AnthropicWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: AnthropicWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: AnthropicWrapper.aiSystem,
- serverAddress: AnthropicWrapper.serverAddress,
- serverPort: AnthropicWrapper.serverPort,
};
}
}
diff --git a/sdk/typescript/src/instrumentation/azure-ai-inference/index.ts b/sdk/typescript/src/instrumentation/azure-ai-inference/index.ts
new file mode 100644
index 00000000..36edcc48
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/azure-ai-inference/index.ts
@@ -0,0 +1,106 @@
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+ isWrapped,
+} from '@opentelemetry/instrumentation';
+import { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import AzureAIInferenceWrapper from './wrapper';
+
+export interface AzureAIInferenceInstrumentationConfig extends InstrumentationConfig {}
+
+export default class OpenlitAzureAIInferenceInstrumentation extends InstrumentationBase {
+ constructor(config: AzureAIInferenceInstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-azure-ai-inference`, '1.0.0', config);
+ }
+
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
+ const module = new InstrumentationNodeModuleDefinition(
+ '@azure-rest/ai-inference',
+ ['>=1.0.0-beta.1'],
+ (moduleExports) => {
+ this._patch(moduleExports);
+ return moduleExports;
+ },
+ (moduleExports) => {
+ if (moduleExports !== undefined) {
+ this._unpatch(moduleExports);
+ }
+ }
+ );
+ return [module];
+ }
+
+ public manualPatch(azureAIInference: any): void {
+ this._patch(azureAIInference);
+ }
+
+ protected _patch(moduleExports: any) {
+ try {
+ if (!moduleExports.default || typeof moduleExports.default !== 'function') {
+ return;
+ }
+
+ if (isWrapped(moduleExports.default)) {
+ this._unwrap(moduleExports, 'default');
+ }
+
+ const tracer = this.tracer;
+
+ this._wrap(moduleExports, 'default', (original: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const client = original.apply(this, args);
+
+ const endpoint = typeof args[0] === 'string' ? args[0] : '';
+ const { serverAddress, serverPort } =
+ AzureAIInferenceWrapper.parseEndpoint(endpoint);
+
+ if (client && typeof client.path === 'function') {
+ const originalPath = client.path;
+ client.path = function (...pathArgs: any[]) {
+ const route: string = pathArgs[0];
+ const handler = originalPath.apply(client, pathArgs);
+
+ if (
+ route === '/chat/completions' &&
+ handler &&
+ typeof handler.post === 'function'
+ ) {
+ const origPost = handler.post;
+ handler.post = AzureAIInferenceWrapper._patchChatComplete(
+ tracer,
+ serverAddress,
+ serverPort
+ )(origPost);
+ } else if (
+ route === '/embeddings' &&
+ handler &&
+ typeof handler.post === 'function'
+ ) {
+ const origPost = handler.post;
+ handler.post = AzureAIInferenceWrapper._patchEmbeddings(
+ tracer,
+ serverAddress,
+ serverPort
+ )(origPost);
+ }
+
+ return handler;
+ };
+ }
+
+ return client;
+ };
+ });
+ } catch (e) {
+ console.error('Error in _patch method:', e);
+ }
+ }
+
+ protected _unpatch(moduleExports: any) {
+ if (moduleExports.default) {
+ this._unwrap(moduleExports, 'default');
+ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/azure-ai-inference/wrapper.ts b/sdk/typescript/src/instrumentation/azure-ai-inference/wrapper.ts
new file mode 100644
index 00000000..7def5722
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/azure-ai-inference/wrapper.ts
@@ -0,0 +1,610 @@
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
+import SemanticConvention from '../../semantic-convention';
+import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string,
+ serverAddress: string,
+ serverPort: number
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+ };
+}
+
+class AzureAIInferenceWrapper extends BaseWrapper {
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE;
+ static defaultServerAddress = 'models.github.ai';
+ static defaultServerPort = 443;
+
+ /**
+ * Extracts server address and port from an endpoint URL string.
+ */
+ static parseEndpoint(endpoint: string): { serverAddress: string; serverPort: number } {
+ let serverAddress = AzureAIInferenceWrapper.defaultServerAddress;
+ let serverPort = AzureAIInferenceWrapper.defaultServerPort;
+ try {
+ const url = new URL(endpoint);
+ serverAddress = url.hostname;
+ serverPort = parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80);
+ } catch { /* use defaults */ }
+ return { serverAddress, serverPort };
+ }
+
+ // ──────────────────── Chat Completions ────────────────────
+
+ static _patchChatComplete(
+ tracer: Tracer,
+ serverAddress: string,
+ serverPort: number
+ ): any {
+ const genAIEndpoint = 'az.ai.inference.chat.completions';
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const body = args[0]?.body || {};
+ const requestModel = body.model || 'gpt-4o';
+ const isStream = body.stream === true;
+
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ requestModel,
+ serverAddress,
+ serverPort
+ ),
+ }, effectiveCtx);
+
+ if (isStream) {
+ if (args[0]?.body) {
+ args[0].body.stream_options = { include_usage: true };
+ }
+ const pipelineRequest = context.with(
+ trace.setSpan(effectiveCtx, span),
+ () => originalMethod.apply(this, args)
+ );
+ const origAsNodeStream = pipelineRequest.asNodeStream?.bind(pipelineRequest);
+ if (origAsNodeStream) {
+ pipelineRequest.asNodeStream = async function (...streamArgs: any[]) {
+ try {
+ const streamResp = await origAsNodeStream(...streamArgs);
+ const origBody = streamResp.body;
+ if (!origBody) {
+ span.end();
+ return streamResp;
+ }
+ streamResp.body = AzureAIInferenceWrapper._wrapSseStream(
+ origBody,
+ body,
+ genAIEndpoint,
+ span,
+ serverAddress,
+ serverPort
+ );
+ return streamResp;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ }
+ };
+ }
+ return pipelineRequest;
+ }
+
+ return context
+ .with(trace.setSpan(effectiveCtx, span), async () => {
+ return originalMethod.apply(this, args);
+ })
+ .then((httpResponse: any) => {
+ return AzureAIInferenceWrapper._chatCompletion({
+ body,
+ genAIEndpoint,
+ httpResponse,
+ span,
+ serverAddress,
+ serverPort,
+ });
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ });
+ };
+ };
+ }
+
+ static async _chatCompletion({
+ body,
+ genAIEndpoint,
+ httpResponse,
+ span,
+ serverAddress,
+ serverPort,
+ }: {
+ body: any;
+ genAIEndpoint: string;
+ httpResponse: any;
+ span: Span;
+ serverAddress: string;
+ serverPort: number;
+ }): Promise<any> {
+ let metricParams;
+ try {
+ const result = httpResponse?.body ?? httpResponse;
+ if (result && typeof result === 'object' && result.choices) {
+ metricParams = AzureAIInferenceWrapper._chatCompletionCommonSetter({
+ body,
+ genAIEndpoint,
+ result,
+ span,
+ serverAddress,
+ serverPort,
+ });
+ }
+ return httpResponse;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ }
+
+ /**
+ * Wraps an SSE body stream (Node.js IncomingMessage / ReadableStream) to
+ * aggregate telemetry while passing through chunks to the caller.
+ * Returns an async-iterable that yields the raw SSE buffers/strings so
+ * downstream consumers (e.g. createSseStream) keep working.
+ */
+ static _wrapSseStream(
+ body: any,
+ requestBody: any,
+ genAIEndpoint: string,
+ span: Span,
+ serverAddress: string,
+ serverPort: number
+ ): any {
+ const requestModel = requestBody.model || 'gpt-4o';
+ const startTime = Date.now();
+ const timestamps: number[] = [];
+
+ const aggregated = {
+ id: '',
+ model: '',
+ content: '',
+ finishReason: 'stop',
+ inputTokens: 0,
+ outputTokens: 0,
+ toolCalls: [] as any[],
+ };
+
+ function processSseLine(line: string) {
+ if (!line.startsWith('data: ')) return;
+ const data = line.slice(6).trim();
+ if (data === '[DONE]') return;
+ try {
+ const parsed = JSON.parse(data);
+ if (parsed.id) aggregated.id = parsed.id;
+ if (parsed.model) aggregated.model = parsed.model;
+ const choice = parsed.choices?.[0];
+ if (choice) {
+ if (choice.delta?.content) aggregated.content += choice.delta.content;
+ if (choice.finish_reason) aggregated.finishReason = choice.finish_reason;
+ if (choice.delta?.tool_calls) {
+ for (const tc of choice.delta.tool_calls) {
+ const idx = tc.index ?? 0;
+ while (aggregated.toolCalls.length <= idx) {
+ aggregated.toolCalls.push({ id: '', type: 'function', function: { name: '', arguments: '' } });
+ }
+ if (tc.id) {
+ aggregated.toolCalls[idx].id = tc.id;
+ aggregated.toolCalls[idx].type = tc.type || 'function';
+ if (tc.function?.name) aggregated.toolCalls[idx].function.name = tc.function.name;
+ if (tc.function?.arguments) aggregated.toolCalls[idx].function.arguments = tc.function.arguments;
+ } else if (tc.function?.arguments) {
+ aggregated.toolCalls[idx].function.arguments += tc.function.arguments;
+ }
+ }
+ }
+ }
+ if (parsed.usage) {
+ aggregated.inputTokens = parsed.usage.prompt_tokens ?? 0;
+ aggregated.outputTokens = parsed.usage.completion_tokens ?? 0;
+ }
+ } catch { /* ignore parse errors */ }
+ }
+
+ let pending = '';
+
+ const readable = body;
+ const _originalPipe = readable.pipe?.bind(readable);
+ const _originalOn = readable.on?.bind(readable);
+
+ const self = AzureAIInferenceWrapper;
+ let finalized = false;
+
+ function finalize() {
+ if (finalized) return;
+ finalized = true;
+ const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
+ let tbt = 0;
+ if (timestamps.length > 1) {
+ const diffs = timestamps.slice(1).map((t, i) => t - timestamps[i]);
+ tbt = diffs.reduce((a, b) => a + b, 0) / diffs.length / 1000;
+ }
+
+ let inputTokens = aggregated.inputTokens;
+ let outputTokens = aggregated.outputTokens;
+ if (!inputTokens && !outputTokens) {
+ const prompt = JSON.stringify(requestBody.messages || []);
+ inputTokens = Math.ceil(prompt.length / 2);
+ outputTokens = Math.ceil(aggregated.content.length / 2);
+ }
+
+ const result = {
+ id: aggregated.id,
+ model: aggregated.model || requestModel,
+ choices: [{
+ finish_reason: aggregated.finishReason,
+ message: {
+ role: 'assistant',
+ content: aggregated.content,
+ ...(aggregated.toolCalls.length > 0 ? { tool_calls: aggregated.toolCalls } : {}),
+ },
+ }],
+ usage: {
+ prompt_tokens: inputTokens,
+ completion_tokens: outputTokens,
+ },
+ };
+
+ const metricParams = self._chatCompletionCommonSetter({
+ body: requestBody,
+ genAIEndpoint,
+ result,
+ span,
+ serverAddress,
+ serverPort,
+ ttft,
+ tbt,
+ });
+ span.end();
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+
+ if (typeof readable.on === 'function') {
+ readable.on('data', (chunk: Buffer | string) => {
+ timestamps.push(Date.now());
+ const text = typeof chunk === 'string' ? chunk : chunk.toString();
+ pending += text;
+ const lines = pending.split('\n');
+ pending = lines.pop() || '';
+ for (const line of lines) {
+ processSseLine(line.trim());
+ }
+ });
+ readable.on('end', () => {
+ if (pending.trim()) processSseLine(pending.trim());
+ finalize();
+ });
+ readable.on('close', () => {
+ if (pending.trim()) processSseLine(pending.trim());
+ finalize();
+ });
+ readable.on('error', (err: Error) => {
+ OpenLitHelper.handleException(span, err);
+ finalize();
+ });
+ }
+
+ return readable;
+ }
+
+ static _chatCompletionCommonSetter({
+ body,
+ genAIEndpoint,
+ result,
+ span,
+ serverAddress,
+ serverPort,
+ ttft = 0,
+ tbt = 0,
+ }: {
+ body: any;
+ genAIEndpoint: string;
+ result: any;
+ span: Span;
+ serverAddress: string;
+ serverPort: number;
+ ttft?: number;
+ tbt?: number;
+ }): BaseSpanAttributes {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = body.model || 'gpt-4o';
+ const {
+ messages,
+ frequency_penalty = 0,
+ max_tokens = null,
+ n = 1,
+ presence_penalty = 0,
+ seed = null,
+ stop = null,
+ temperature = 1,
+ top_p,
+ user,
+ stream = false,
+ } = body;
+
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
+ if (stop) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(stop) ? stop : [stop]
+ );
+ }
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
+ }
+
+ if (captureContent) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages(messages || [])
+ );
+ }
+
+ if (result.id) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
+ }
+
+ const responseModel = result.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = result.usage?.prompt_tokens || 0;
+ const outputTokens = result.usage?.completion_tokens || 0;
+ const cost = OpenLitHelper.getChatModelCost(
+ requestModel,
+ pricingInfo,
+ inputTokens,
+ outputTokens
+ );
+
+ AzureAIInferenceWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: requestModel,
+ user,
+ cost,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
+ if (result.usage?.prompt_tokens_details?.cached_tokens) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
+ result.usage.prompt_tokens_details.cached_tokens
+ );
+ }
+ if (result.usage?.input_tokens_details?.cache_creation_tokens) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
+ result.usage.input_tokens_details.cache_creation_tokens
+ );
+ }
+
+ if (ttft > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ }
+ if (tbt > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ }
+
+ const choices = result.choices || [];
+ if (choices[0]?.finish_reason) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ [choices[0].finish_reason]
+ );
+ }
+
+ const outputType =
+ typeof choices[0]?.message?.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ if (choices[0]?.message?.tool_calls) {
+ const toolCalls = choices[0].message.tool_calls;
+ const toolNames = toolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
+ const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
+ const toolArgs = toolCalls.map((t: any) => t.function?.arguments || '').filter(Boolean);
+
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
+ }
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const toolCalls = choices[0]?.message?.tool_calls;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ choices[0]?.message?.content || '',
+ choices[0]?.finish_reason || 'stop',
+ toolCalls
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [choices[0]?.finish_reason || 'stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
+ return {
+ genAIEndpoint,
+ model: requestModel,
+ user,
+ cost,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ };
+ }
+
+ // ──────────────────── Embeddings ────────────────────
+
+ static _patchEmbeddings(
+ tracer: Tracer,
+ serverAddress: string,
+ serverPort: number
+ ): any {
+ const genAIEndpoint = 'az.ai.inference.embeddings';
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const body = args[0]?.body || {};
+ const requestModel = body.model || 'text-embedding-3-small';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ requestModel,
+ serverAddress,
+ serverPort
+ ),
+ }, effectiveCtx);
+
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ let metricParams: BaseSpanAttributes | undefined;
+ try {
+ const httpResponse = await originalMethod.apply(this, args);
+ const responseBody = httpResponse?.body ?? httpResponse;
+
+ if (responseBody && typeof responseBody === 'object') {
+ const _responseModel = responseBody.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = responseBody.usage?.prompt_tokens || 0;
+ const cost = OpenLitHelper.getEmbedModelCost(requestModel, pricingInfo, inputTokens);
+
+ const { encoding_format = 'float', input, dimensions, user } = body;
+
+ AzureAIInferenceWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: requestModel,
+ user,
+ cost,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, [encoding_format]);
+ if (dimensions) {
+ span.setAttribute(SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT, dimensions);
+ }
+ if (captureContent) {
+ const formattedInput = typeof input === 'string' ? input : JSON.stringify(input);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, formattedInput);
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+
+ metricParams = {
+ genAIEndpoint,
+ model: requestModel,
+ user,
+ cost,
+ aiSystem: AzureAIInferenceWrapper.aiSystem,
+ };
+ }
+
+ return httpResponse;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ });
+ };
+ };
+ }
+}
+
+export default AzureAIInferenceWrapper;
diff --git a/sdk/typescript/src/instrumentation/base-wrapper.ts b/sdk/typescript/src/instrumentation/base-wrapper.ts
index 4aca2324..0c5ac159 100644
--- a/sdk/typescript/src/instrumentation/base-wrapper.ts
+++ b/sdk/typescript/src/instrumentation/base-wrapper.ts
@@ -1,9 +1,10 @@
import OpenlitConfig from '../config';
import { SDK_NAME, SDK_VERSION } from '../constant';
-import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
import SemanticConvention from '../semantic-convention';
-import { Span, SpanStatusCode } from '@opentelemetry/api';
+import { Attributes, Span, SpanStatusCode } from '@opentelemetry/api';
import Metrics from '../otel/metrics';
+import { applyCustomSpanAttributes } from '../helpers';
export type BaseSpanAttributes = {
genAIEndpoint: string;
@@ -13,12 +14,13 @@ export type BaseSpanAttributes = {
aiSystem: string;
serverAddress?: string;
serverPort?: number;
+ errorType?: string;
};
export default class BaseWrapper {
static setBaseSpanAttributes(
span: Span,
- { genAIEndpoint, model, user, cost, aiSystem, serverAddress, serverPort }: BaseSpanAttributes
+ { genAIEndpoint: _genAIEndpoint, model, user, cost, aiSystem, serverAddress, serverPort }: BaseSpanAttributes
) {
const applicationName = OpenlitConfig.applicationName;
const environment = OpenlitConfig.environment;
@@ -31,11 +33,10 @@ export default class BaseWrapper {
}
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, aiSystem);
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, aiSystem);
- span.setAttribute(SemanticConvention.GEN_AI_ENDPOINT, genAIEndpoint);
- span.setAttribute(SemanticConvention.GEN_AI_ENVIRONMENT, environment);
- span.setAttribute(SemanticConvention.GEN_AI_APPLICATION_NAME, applicationName);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, environment);
+ span.setAttribute(ATTR_SERVICE_NAME, applicationName);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, model);
span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
if (serverAddress) {
@@ -50,47 +51,59 @@ export default class BaseWrapper {
if (cost !== undefined) {
span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, cost);
}
+ applyCustomSpanAttributes(span);
span.setStatus({ code: SpanStatusCode.OK });
}
static recordMetrics(span: Span, baseAttributes: BaseSpanAttributes) {
const applicationName = OpenlitConfig.applicationName!;
const environment = OpenlitConfig.environment!;
- const { genAIEndpoint, model, user, aiSystem, cost } = baseAttributes;
+ const { model, aiSystem, cost, errorType } = baseAttributes;
const inputTokens = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS);
const outputTokens = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS);
const duration = BaseWrapper.getSpanAttribute(span, 'duration') ?? BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_DURATION_LEGACY);
- const attributes = {
+ const operationName = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_OPERATION) as unknown as string;
+ const responseModel = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_RESPONSE_MODEL) as unknown as string;
+ const serverAddress = BaseWrapper.getSpanAttribute(span, SemanticConvention.SERVER_ADDRESS) as unknown as string;
+ const serverPort = BaseWrapper.getSpanAttribute(span, SemanticConvention.SERVER_PORT) as unknown as number;
+ const attributes: Attributes = {
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
[ATTR_SERVICE_NAME]: applicationName,
- [SemanticConvention.GEN_AI_PROVIDER_NAME]: aiSystem,
- [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: aiSystem,
- [SemanticConvention.GEN_AI_ENDPOINT]: genAIEndpoint,
[SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: environment,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: aiSystem,
[SemanticConvention.GEN_AI_REQUEST_MODEL]: model,
- [SemanticConvention.GEN_AI_REQUEST_USER]: typeof user === 'string' || typeof user === 'number' ? user : String(user ?? ''),
};
- Metrics.genaiRequests?.add(1, attributes);
- if (Number.isFinite(inputTokens)) Metrics.genaiPromptTokens?.add(inputTokens as number, attributes);
- if (Number.isFinite(outputTokens)) Metrics.genaiCompletionTokens?.add(outputTokens as number, attributes);
+ if (operationName) attributes[SemanticConvention.GEN_AI_OPERATION] = operationName;
+ if (responseModel) attributes[SemanticConvention.GEN_AI_RESPONSE_MODEL] = responseModel;
+ if (serverAddress) attributes[SemanticConvention.SERVER_ADDRESS] = serverAddress;
+ if (serverPort !== undefined) attributes[SemanticConvention.SERVER_PORT] = serverPort;
+ if (errorType) attributes[SemanticConvention.ERROR_TYPE] = errorType;
+
+ if (Number.isFinite(inputTokens)) {
+ Metrics.genaiClientUsageTokens?.record(inputTokens as number, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_INPUT,
+ });
+ }
+ if (Number.isFinite(outputTokens)) {
+ Metrics.genaiClientUsageTokens?.record(outputTokens as number, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_OUTPUT,
+ });
+ }
if (Number.isFinite(duration)) {
Metrics.genaiClientOperationDuration?.record((duration as number) / 1e9, attributes);
}
- const totalTokens = (Number.isFinite(inputTokens) ? inputTokens as number : 0) + (Number.isFinite(outputTokens) ? outputTokens as number : 0);
- if (totalTokens > 0) Metrics.genaiClientUsageTokens?.record(totalTokens, attributes);
- const reasoningTokens = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_USAGE_REASONING_TOKENS);
- if (Number.isFinite(reasoningTokens)) Metrics.genaiReasoningTokens?.add(reasoningTokens as number, attributes);
const tbt = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_SERVER_TBT);
if (Number.isFinite(tbt)) Metrics.genaiServerTbt?.record(tbt as number, attributes);
const ttft = BaseWrapper.getSpanAttribute(span, SemanticConvention.GEN_AI_SERVER_TTFT);
if (Number.isFinite(ttft)) Metrics.genaiServerTtft?.record(ttft as number, attributes);
- // Client-perspective streaming metrics (OTel semconv v1.29+)
if (Number.isFinite(ttft) && (ttft as number) > 0) {
Metrics.genaiClientTimeToFirstChunk?.record(ttft as number, attributes);
}
if (Number.isFinite(tbt) && (tbt as number) > 0) {
Metrics.genaiClientTimePerOutputChunk?.record(tbt as number, attributes);
- // Server request duration = TTFT + TBT * max(output_tokens - 1, 0)
const outputTokensVal = Number.isFinite(outputTokens) ? (outputTokens as number) : 0;
const serverRequestDuration = (ttft as number) + (tbt as number) * Math.max(outputTokensVal - 1, 0);
Metrics.genaiServerRequestDuration?.record(serverRequestDuration, attributes);
diff --git a/sdk/typescript/src/instrumentation/bedrock/wrapper.ts b/sdk/typescript/src/instrumentation/bedrock/wrapper.ts
index 63825a43..a1945b73 100644
--- a/sdk/typescript/src/instrumentation/bedrock/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/bedrock/wrapper.ts
@@ -1,12 +1,9 @@
-import { SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
-const BEDROCK_SERVER_ADDRESS = 'bedrock-runtime.amazonaws.com';
-const BEDROCK_SERVER_PORT = 443;
-
function mapFinishReason(stopReason: string): string {
const map: Record<string, string> = {
end_turn: 'stop',
@@ -19,25 +16,65 @@ function mapFinishReason(stopReason: string): string {
return map[stopReason] || stopReason;
}
-function applyInferenceConfigAttributes(span: any, inferenceConfig: any) {
- if (inferenceConfig.maxTokens !== undefined)
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, inferenceConfig.maxTokens);
- if (inferenceConfig.temperature !== undefined)
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, inferenceConfig.temperature);
- if (inferenceConfig.topP !== undefined)
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, inferenceConfig.topP);
- if (inferenceConfig.topK !== undefined)
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, inferenceConfig.topK);
- if (inferenceConfig.stopSequences !== undefined)
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, inferenceConfig.stopSequences);
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: BedrockWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: BedrockWrapper.serverPort,
+ };
+}
+
+/**
+ * Convert Bedrock message content blocks ({text: "..."}) to the format
+ * expected by OpenLitHelper.buildInputMessages ({type: "text", text: "..."}).
+ */
+function convertBedrockMessages(messages: any[]): any[] {
+ return (messages || []).map((m: any) => {
+ const role = m.role || 'user';
+ const content = m.content;
+ if (!Array.isArray(content)) {
+ return { role, content: typeof content === 'string' ? content : '' };
+ }
+ return {
+ role,
+ content: content.map((c: any) => {
+ if (c.text !== undefined) return { type: 'text', text: c.text };
+ if (c.toolUse) {
+ return {
+ type: 'tool_use',
+ id: c.toolUse.toolUseId || '',
+ name: c.toolUse.name || '',
+ input: c.toolUse.input || {},
+ };
+ }
+ if (c.toolResult) {
+ const rc = c.toolResult.content;
+ return {
+ type: 'tool_result',
+ tool_use_id: c.toolResult.toolUseId || '',
+ content: typeof rc === 'string' ? rc : JSON.stringify(rc || ''),
+ };
+ }
+ return c;
+ }),
+ };
+ });
}
class BedrockWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK;
+ static serverAddress = 'bedrock-runtime.amazonaws.com';
+ static serverPort = 443;
static _patchSend(tracer: Tracer): any {
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
const command = args[0];
if (!command) return originalMethod.apply(this, args);
@@ -49,9 +86,6 @@ class BedrockWrapper extends BaseWrapper {
if (commandName === 'ConverseStreamCommand') {
return BedrockWrapper._handleConverseStreamCommand(tracer, originalMethod, this, args);
}
- if (commandName === 'InvokeModelCommand' || commandName === 'InvokeModelWithResponseStreamCommand') {
- return BedrockWrapper._handleInvokeModelCommand(tracer, originalMethod, this, args, commandName);
- }
return originalMethod.apply(this, args);
};
@@ -66,95 +100,71 @@ class BedrockWrapper extends BaseWrapper {
): Promise<any> {
const command = args[0];
const input = command.input || {};
- const modelId = input.modelId || 'unknown';
+ const modelId = input.modelId || 'amazon.titan-text-express-v1';
const genAIEndpoint = 'bedrock.converse';
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- const startTime = Date.now();
- let metricParams: BaseSpanAttributes | undefined;
- try {
- const response = await originalMethod.apply(instance, args);
- const duration = (Date.now() - startTime) / 1000;
-
- const usage = response.usage || {};
- const promptTokens = usage.inputTokens || 0;
- const completionTokens = usage.outputTokens || 0;
- const totalTokens = usage.totalTokens || promptTokens + completionTokens;
- const cacheReadTokens = usage.cacheReadInputTokens || 0;
- const cacheWriteTokens = usage.cacheWriteInputTokens || 0;
-
- const finishReason = mapFinishReason(response.stopReason || 'stop');
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, promptTokens, completionTokens);
-
- BedrockWrapper.setBaseSpanAttributes(span, {
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, modelId),
+ }, effectiveCtx);
+
+ return context
+ .with(trace.setSpan(effectiveCtx, span), async () => {
+ return originalMethod.apply(instance, args);
+ })
+ .then((response: any) => {
+ return BedrockWrapper._converseComplete({ input, genAIEndpoint, response, span, modelId });
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
genAIEndpoint,
model: modelId,
- cost,
aiSystem: BedrockWrapper.aiSystem,
- serverAddress: BEDROCK_SERVER_ADDRESS,
- serverPort: BEDROCK_SERVER_PORT,
+ serverAddress: BedrockWrapper.serverAddress,
+ serverPort: BedrockWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
});
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, BEDROCK_SERVER_ADDRESS);
- span.setAttribute(SemanticConvention.SERVER_PORT, BEDROCK_SERVER_PORT);
-
- if (cacheReadTokens > 0)
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cacheReadTokens);
- if (cacheWriteTokens > 0)
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, cacheWriteTokens);
-
- const requestId = response.$metadata?.requestId;
- if (requestId)
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, requestId);
-
- applyInferenceConfigAttributes(span, input.inferenceConfig || {});
-
- if (OpenlitConfig.traceContent) {
- const messages = (input.messages || []).map((m: any) => ({
- role: m.role,
- content: m.content?.map((c: any) => c.text || '').join('') || '',
- }));
- const systemText = input.system?.[0]?.text;
- span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages(messages, systemText)
- );
- if (systemText) {
- const systemStr = JSON.stringify([{ type: 'text', content: systemText }]);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, systemStr);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS_OTEL, systemStr);
- }
- const outputText =
- response.output?.message?.content?.map((c: any) => c.text || '').join('') || '';
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(outputText, finishReason)
- );
- }
-
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem: BedrockWrapper.aiSystem };
- return response;
- } catch (e: any) {
- OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ throw e;
+ });
+ }
+
+ static async _converseComplete({
+ input,
+ genAIEndpoint,
+ response,
+ span,
+ modelId,
+ }: {
+ input: any;
+ genAIEndpoint: string;
+ response: any;
+ span: Span;
+ modelId: string;
+ }): Promise<any> {
+ let metricParams;
+ try {
+ metricParams = BedrockWrapper._converseCommonSetter({
+ input,
+ genAIEndpoint,
+ result: response,
+ span,
+ modelId,
+ isStream: false,
+ });
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
}
- });
+ }
}
static async _handleConverseStreamCommand(
@@ -165,35 +175,50 @@ class BedrockWrapper extends BaseWrapper {
): Promise<any> {
const command = args[0];
const input = command.input || {};
- const modelId = input.modelId || 'unknown';
+ const modelId = input.modelId || 'amazon.titan-text-express-v1';
const genAIEndpoint = 'bedrock.converse_stream';
const startTime = Date.now();
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
-
- // Call the original method to get the response object (with .stream async iterable)
- const response = await context.with(trace.setSpan(context.active(), span), () =>
- originalMethod.apply(instance, args)
- );
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, modelId),
+ }, effectiveCtx);
+
+ let response: any;
+ try {
+ response = await context.with(trace.setSpan(effectiveCtx, span), () =>
+ originalMethod.apply(instance, args)
+ );
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: BedrockWrapper.aiSystem,
+ serverAddress: BedrockWrapper.serverAddress,
+ serverPort: BedrockWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ }
- // Accumulated state from stream events
let llmResponse = '';
let finishReason = 'stop';
let inputTokens = 0;
let outputTokens = 0;
let cacheReadTokens = 0;
let cacheWriteTokens = 0;
- let firstChunkTime: number | null = null;
- const chunkTimestamps: number[] = [];
+ const timestamps: number[] = [];
const originalStream: AsyncIterable<any> = response.stream;
async function* wrappedStream() {
try {
for await (const event of originalStream) {
- const now = Date.now();
- if (firstChunkTime === null) firstChunkTime = now;
- chunkTimestamps.push(now);
+ timestamps.push(Date.now());
if (event.contentBlockDelta?.delta?.text)
llmResponse += event.contentBlockDelta.delta.text;
@@ -205,78 +230,41 @@ class BedrockWrapper extends BaseWrapper {
cacheReadTokens = event.metadata.usage.cacheReadInputTokens || 0;
cacheWriteTokens = event.metadata.usage.cacheWriteInputTokens || 0;
}
+
yield event;
}
} finally {
- // Record telemetry once the stream is fully consumed
try {
- const duration = (Date.now() - startTime) / 1000;
- const ttft = firstChunkTime !== null ? (firstChunkTime - startTime) / 1000 : 0;
+ const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
- if (chunkTimestamps.length > 1) {
- const timeDiffs = chunkTimestamps.slice(1).map((t, i) => t - chunkTimestamps[i]);
+ if (timestamps.length > 1) {
+ const timeDiffs = timestamps.slice(1).map((t, i) => t - timestamps[i]);
tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
}
- const totalTokens = inputTokens + outputTokens;
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, inputTokens, outputTokens);
- BedrockWrapper.setBaseSpanAttributes(span, {
+ const result = {
+ output: { message: { content: [{ text: llmResponse }] } },
+ stopReason: finishReason,
+ usage: {
+ inputTokens,
+ outputTokens,
+ cacheReadInputTokens: cacheReadTokens,
+ cacheWriteInputTokens: cacheWriteTokens,
+ },
+ $metadata: response.$metadata,
+ };
+
+ const metricParams = BedrockWrapper._converseCommonSetter({
+ input,
genAIEndpoint,
- model: modelId,
- cost,
- aiSystem: BedrockWrapper.aiSystem,
+ result,
+ span,
+ modelId,
+ isStream: true,
+ ttft,
+ tbt,
});
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- if (ttft > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
- if (tbt > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, BEDROCK_SERVER_ADDRESS);
- span.setAttribute(SemanticConvention.SERVER_PORT, BEDROCK_SERVER_PORT);
-
- if (cacheReadTokens > 0)
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cacheReadTokens);
- if (cacheWriteTokens > 0)
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, cacheWriteTokens);
-
- const requestId = response.$metadata?.requestId;
- if (requestId)
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, requestId);
-
- applyInferenceConfigAttributes(span, input.inferenceConfig || {});
-
- if (OpenlitConfig.traceContent) {
- const messages = (input.messages || []).map((m: any) => ({
- role: m.role,
- content: m.content?.map((c: any) => c.text || '').join('') || '',
- }));
- const systemText = input.system?.[0]?.text;
- span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages(messages, systemText)
- );
- if (systemText) {
- const systemStr = JSON.stringify([{ type: 'text', content: systemText }]);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, systemStr);
- span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS_OTEL, systemStr);
- }
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(llmResponse, finishReason)
- );
- }
-
- const metricParams: BaseSpanAttributes = { genAIEndpoint, model: modelId, cost, aiSystem: BedrockWrapper.aiSystem };
BaseWrapper.recordMetrics(span, metricParams);
} catch { /* ignore telemetry errors in finally */ } finally {
span.end();
@@ -287,137 +275,193 @@ class BedrockWrapper extends BaseWrapper {
return { ...response, stream: wrappedStream() };
}
- static async _handleInvokeModelCommand(
- tracer: Tracer,
- originalMethod: any,
- instance: any,
- args: any[],
- commandName: string
- ): Promise<any> {
- const command = args[0];
- const input = command.input || {};
- const modelId = input.modelId || 'unknown';
- const isStream = commandName === 'InvokeModelWithResponseStreamCommand';
- const genAIEndpoint = isStream ? 'bedrock.invoke_model_stream' : 'bedrock.invoke_model';
-
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- const startTime = Date.now();
- let metricParams: BaseSpanAttributes | undefined;
- try {
- const response = await originalMethod.apply(instance, args);
- const duration = (Date.now() - startTime) / 1000;
+ static _converseCommonSetter({
+ input,
+ genAIEndpoint,
+ result,
+ span,
+ modelId,
+ isStream,
+ ttft = 0,
+ tbt = 0,
+ }: {
+ input: any;
+ genAIEndpoint: string;
+ result: any;
+ span: Span;
+ modelId: string;
+ isStream: boolean;
+ ttft?: number;
+ tbt?: number;
+ }): BaseSpanAttributes {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const inferenceConfig = input.inferenceConfig || {};
+
+ if (inferenceConfig.temperature !== undefined) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, inferenceConfig.temperature);
+ }
+ if (inferenceConfig.topP !== undefined) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, inferenceConfig.topP);
+ }
+ if (inferenceConfig.topK !== undefined) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, inferenceConfig.topK);
+ }
+ if (inferenceConfig.maxTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, inferenceConfig.maxTokens);
+ }
+ if (inferenceConfig.stopSequences) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, inferenceConfig.stopSequences);
+ }
+ if (inferenceConfig.frequencyPenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, inferenceConfig.frequencyPenalty);
+ }
+ if (inferenceConfig.presencePenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, inferenceConfig.presencePenalty);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStream);
+
+ const usage = result.usage || {};
+ const inputTokens = usage.inputTokens || 0;
+ const outputTokens = usage.outputTokens || 0;
+ const cacheReadTokens = usage.cacheReadInputTokens || 0;
+ const cacheWriteTokens = usage.cacheWriteInputTokens || 0;
+
+ const responseModel = modelId;
+ const finishReason = mapFinishReason(result.stopReason || 'stop');
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, inputTokens, outputTokens);
+
+ BedrockWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: BedrockWrapper.aiSystem,
+ serverAddress: BedrockWrapper.serverAddress,
+ serverPort: BedrockWrapper.serverPort,
+ });
- // Parse response body
- let parsedBody: any = {};
- let promptTokens = 0;
- let completionTokens = 0;
- let outputText = '';
- let rawFinishReason = 'stop';
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- try {
- const bodyBytes = response.body;
- if (bodyBytes) {
- const bodyStr = typeof bodyBytes === 'string'
- ? bodyBytes
- : Buffer.from(bodyBytes).toString('utf-8');
- parsedBody = JSON.parse(bodyStr);
- }
- } catch { /* ignore parse errors */ }
-
- // Handle different provider response formats
- if (modelId.startsWith('anthropic')) {
- promptTokens = parsedBody.usage?.input_tokens || 0;
- completionTokens = parsedBody.usage?.output_tokens || 0;
- outputText = parsedBody.content?.[0]?.text || '';
- rawFinishReason = parsedBody.stop_reason || 'stop';
- } else if (modelId.startsWith('amazon')) {
- promptTokens = parsedBody.inputTextTokenCount || 0;
- completionTokens = parsedBody.results?.[0]?.tokenCount || 0;
- outputText = parsedBody.results?.[0]?.outputText || '';
- rawFinishReason = parsedBody.results?.[0]?.completionReason || 'stop';
- } else if (modelId.startsWith('meta')) {
- promptTokens = parsedBody.prompt_token_count || 0;
- completionTokens = parsedBody.generation_token_count || 0;
- outputText = parsedBody.generation || '';
- rawFinishReason = parsedBody.stop_reason || 'stop';
- } else if (modelId.startsWith('mistral') || modelId.startsWith('mixtral')) {
- promptTokens = parsedBody.usage?.prompt_tokens || 0;
- completionTokens = parsedBody.usage?.completion_tokens || 0;
- outputText = parsedBody.outputs?.[0]?.text || '';
- rawFinishReason = parsedBody.outputs?.[0]?.stop_reason || 'stop';
- } else if (modelId.startsWith('ai21')) {
- promptTokens = parsedBody.prompt?.tokens?.length || 0;
- completionTokens = parsedBody.completions?.[0]?.data?.tokens?.length || 0;
- outputText = parsedBody.completions?.[0]?.data?.text || '';
- rawFinishReason = parsedBody.completions?.[0]?.finishReason?.reason || 'stop';
- } else {
- outputText = parsedBody.output || parsedBody.generation || parsedBody.text || '';
- }
+ const requestId = result.$metadata?.requestId;
+ if (requestId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, requestId);
+ }
- const finishReason = mapFinishReason(rawFinishReason);
- const totalTokens = promptTokens + completionTokens;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, promptTokens, completionTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- BedrockWrapper.setBaseSpanAttributes(span, {
- genAIEndpoint,
- model: modelId,
- cost,
- aiSystem: BedrockWrapper.aiSystem,
- serverAddress: BEDROCK_SERVER_ADDRESS,
- serverPort: BEDROCK_SERVER_PORT,
- });
+ if (cacheReadTokens > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cacheReadTokens);
+ }
+ if (cacheWriteTokens > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, cacheWriteTokens);
+ }
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStream);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, BEDROCK_SERVER_ADDRESS);
- span.setAttribute(SemanticConvention.SERVER_PORT, BEDROCK_SERVER_PORT);
-
- const requestId = response.$metadata?.requestId;
- if (requestId)
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, requestId);
-
- if (OpenlitConfig.traceContent) {
- try {
- const reqBody = input.body
- ? JSON.parse(typeof input.body === 'string' ? input.body : Buffer.from(input.body).toString())
- : {};
- const prompt = reqBody.prompt || reqBody.inputText || '';
- if (prompt) {
- span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages([{ role: 'user', content: prompt }])
- );
- }
- } catch { /* ignore */ }
-
- if (outputText) {
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(outputText, finishReason)
- );
- }
+ if (ttft > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ }
+ if (tbt > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
+
+ const outputText =
+ result.output?.message?.content?.map((c: any) => c.text || '').join('') || '';
+ const outputType = typeof outputText === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ const contentBlocks = result.output?.message?.content || [];
+ const toolCalls = contentBlocks
+ .filter((c: any) => c.toolUse)
+ .map((c: any) => ({
+ id: c.toolUse.toolUseId || '',
+ name: c.toolUse.name || '',
+ arguments: c.toolUse.input || {},
+ }));
+
+ if (toolCalls.length > 0) {
+ const toolNames = toolCalls.map((t: any) => t.name).filter(Boolean);
+ const toolIds = toolCalls.map((t: any) => t.id).filter(Boolean);
+ const toolArgs = toolCalls
+ .map((t: any) => (typeof t.arguments === 'string' ? t.arguments : JSON.stringify(t.arguments)))
+ .filter(Boolean);
+
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
+ }
+
+ const messages = convertBedrockMessages(input.messages || []);
+ const systemBlock = input.system || [];
+ const systemParts: any[] = [];
+ if (Array.isArray(systemBlock)) {
+ for (const item of systemBlock) {
+ if (item?.text) {
+ systemParts.push({ type: 'text', content: item.text });
}
+ }
+ }
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem: BedrockWrapper.aiSystem };
- return response;
- } catch (e: any) {
- OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
- span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+
+ if (captureContent) {
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+
+ if (systemParts.length > 0) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS,
+ JSON.stringify(systemParts)
+ );
}
- });
+
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ outputText,
+ finishReason,
+ toolCalls.length > 0 ? toolCalls : undefined
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: modelId,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: BedrockWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: BedrockWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (requestId) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID] = requestId;
+ }
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
+ return {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: BedrockWrapper.aiSystem,
+ };
}
}
diff --git a/sdk/typescript/src/instrumentation/chroma/wrapper.ts b/sdk/typescript/src/instrumentation/chroma/wrapper.ts
index bf785d4c..19d6662b 100644
--- a/sdk/typescript/src/instrumentation/chroma/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/chroma/wrapper.ts
@@ -49,7 +49,7 @@ class ChromaWrapper extends BaseWrapper {
if (params.whereDocument) span.setAttribute(SemanticConvention.DB_WHERE_DOCUMENT, JSON.stringify(params.whereDocument));
const returnedCount = response?.ids?.[0]?.length || 0;
span.setAttribute(SemanticConvention.DB_N_RESULTS, returnedCount);
- if (OpenlitConfig.traceContent && params.queryTexts) {
+ if (OpenlitConfig.captureMessageContent && params.queryTexts) {
span.setAttribute(SemanticConvention.DB_QUERY_TEXT, JSON.stringify(params.queryTexts));
}
span.setAttribute(SemanticConvention.DB_QUERY_SUMMARY,
diff --git a/sdk/typescript/src/instrumentation/claude-agent-sdk/index.ts b/sdk/typescript/src/instrumentation/claude-agent-sdk/index.ts
new file mode 100644
index 00000000..d97264a1
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/claude-agent-sdk/index.ts
@@ -0,0 +1,95 @@
+/**
+ * OpenLIT Claude Agent SDK Instrumentation
+ *
+ * Provides auto-instrumentation for @anthropic-ai/claude-agent-sdk including:
+ * - query() wrapping (invoke_agent spans)
+ * - Tool execution spans via hooks (execute_tool)
+ * - Chat child spans with usage (chat)
+ * - Subagent spans (TaskStarted / TaskNotification)
+ *
+ * Mirrors the Python SDK instrumentation in
+ * sdk/python/src/openlit/instrumentation/claude_agent_sdk/.
+ */
+
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+} from '@opentelemetry/instrumentation';
+import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
+
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import { patchQuery } from './wrapper';
+
+const SUPPORTED_VERSIONS = ['>=0.1.0'];
+
+export default class ClaudeAgentSDKInstrumentation extends InstrumentationBase {
+ private _originalQuery: any = null;
+ private _wrappedQuery: any = null;
+
+ constructor(config: InstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-claude-agent-sdk`, '1.0.0', config);
+ }
+
+ protected init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void {
+ const module = new InstrumentationNodeModuleDefinition(
+ '@anthropic-ai/claude-agent-sdk',
+ SUPPORTED_VERSIONS,
+ (moduleExports: any) => {
+ return this._patch(moduleExports);
+ },
+ (moduleExports: any) => {
+ this._unpatch(moduleExports);
+ return moduleExports;
+ },
+ );
+ return module;
+ }
+
+ public manualPatch(moduleExports: any): any {
+ return this._patch(moduleExports);
+ }
+
+ private _patch(moduleExports: any): any {
+ try {
+ const tracer = this.tracer;
+
+ if (typeof moduleExports.query === 'function') {
+ this._originalQuery = moduleExports.query;
+ const patcher = patchQuery(tracer);
+ this._wrappedQuery = patcher(this._originalQuery);
+
+ // Try Object.defineProperty, then direct assignment.
+ // Both may fail for ESM Module Namespace objects (sealed + strict mode).
+ try {
+ Object.defineProperty(moduleExports, 'query', {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: this._wrappedQuery,
+ });
+ } catch {
+ try { moduleExports.query = this._wrappedQuery; } catch { /* strict mode throws */ }
+ }
+
+ // ESM Module Namespace objects are immutable — assignments silently fail.
+ // If the patch didn't take, return a Proxy that intercepts 'query' access.
+ if (moduleExports.query !== this._wrappedQuery) {
+ const wrappedQuery = this._wrappedQuery;
+ return new Proxy(moduleExports, {
+ get(target, prop, receiver) {
+ if (prop === 'query') return wrappedQuery;
+ return Reflect.get(target, prop, receiver);
+ },
+ });
+ }
+ }
+ } catch { /* graceful degradation */ }
+ return moduleExports;
+ }
+
+ private _unpatch(_moduleExports: any): void {
+ this._originalQuery = null;
+ this._wrappedQuery = null;
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/claude-agent-sdk/wrapper.ts b/sdk/typescript/src/instrumentation/claude-agent-sdk/wrapper.ts
new file mode 100644
index 00000000..4cbdf07d
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/claude-agent-sdk/wrapper.ts
@@ -0,0 +1,1190 @@
+/**
+ * Claude Agent SDK wrapper — OTel GenAI semantic convention compliant.
+ *
+ * Wraps the `query()` async generator to produce `invoke_agent`, `execute_tool`,
+ * and `chat` child spans. Tool spans are created via SDK hooks (PreToolUse /
+ * PostToolUse / PostToolUseFailure). A message-based fallback handles cases
+ * where hooks cannot be injected.
+ *
+ * Mirrors the Python SDK instrumentation in
+ * sdk/python/src/openlit/instrumentation/claude_agent_sdk/.
+ */
+
+import {
+ Tracer,
+ Span,
+ SpanKind,
+ SpanStatusCode,
+ context as otelContext,
+ trace,
+} from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, {
+ applyCustomSpanAttributes,
+ getServerAddressForProvider,
+ setFrameworkLlmActive,
+ resetFrameworkLlmActive,
+} from '../../helpers';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
+import Metrics from '../../otel/metrics';
+
+// ---------------------------------------------------------------------------
+// Constants
+// ---------------------------------------------------------------------------
+
+const [SERVER_ADDRESS, SERVER_PORT] = getServerAddressForProvider('anthropic');
+const GEN_AI_SYSTEM_ATTR = 'gen_ai.system';
+const GEN_AI_SYSTEM_VALUE = 'anthropic';
+
+const ANTHROPIC_FINISH_REASON_MAP: Record<string, string> = {
+ end_turn: 'stop',
+ max_tokens: 'length',
+ stop_sequence: 'stop',
+ tool_use: 'tool_call',
+};
+
+const OPERATION_MAP: Record<string, string> = {
+ query: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ execute_tool: SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ subagent: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ chat: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ create_agent: SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+};
+
+// ---------------------------------------------------------------------------
+// Helpers
+// ---------------------------------------------------------------------------
+
+function truncateContent(content: string): string {
+ const maxLen = OpenlitConfig.maxContentLength;
+ if (maxLen != null && maxLen > 0 && content.length > maxLen) {
+ return content.slice(0, maxLen);
+ }
+ return content;
+}
+
+function mapFinishReason(rawReason: string | null | undefined): string {
+ if (!rawReason) return 'stop';
+ return ANTHROPIC_FINISH_REASON_MAP[rawReason] || rawReason;
+}
+
+function resolveAgentName(options: any): string | null {
+ if (!options) return null;
+ for (const key of ['agent_name', 'agentName', 'name']) {
+ const val = options[key];
+ if (val && typeof val === 'string' && val.trim()) return val.trim();
+ }
+ return null;
+}
+
+function generateSpanName(endpoint: string, entityName?: string | null): string {
+ const operation = OPERATION_MAP[endpoint] || SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT;
+ if (entityName) return `${operation} ${entityName}`;
+ return operation;
+}
+
+// ---------------------------------------------------------------------------
+// Usage extraction from Anthropic BetaMessage.usage or ResultMessage.usage
+// ---------------------------------------------------------------------------
+
+interface UsageAttrs {
+ [key: string]: number;
+}
+
+function extractUsage(usage: any): UsageAttrs {
+ const attrs: UsageAttrs = {};
+ if (!usage) return attrs;
+
+ const rawInput = parseInt(usage.input_tokens, 10) || 0;
+ const outputTokens = parseInt(usage.output_tokens, 10);
+ if (!isNaN(outputTokens)) {
+ attrs[SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS] = outputTokens;
+ }
+
+ let cacheReadInt = 0;
+ const cacheRead = usage.cache_read_input_tokens;
+ if (cacheRead != null) {
+ cacheReadInt = parseInt(cacheRead, 10) || 0;
+ if (cacheReadInt) {
+ attrs[SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] = cacheReadInt;
+ }
+ }
+
+ let cacheCreationInt = 0;
+ const cacheCreation = usage.cache_creation_input_tokens ?? usage.cache_write_input_tokens;
+ if (cacheCreation != null) {
+ cacheCreationInt = parseInt(cacheCreation, 10) || 0;
+ if (cacheCreationInt) {
+ attrs[SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] = cacheCreationInt;
+ }
+ }
+
+ attrs[SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS] = rawInput + cacheReadInt + cacheCreationInt;
+ return attrs;
+}
+
+// ---------------------------------------------------------------------------
+// ToolSpanTracker — manages in-flight tool spans created by SDK hooks
+// ---------------------------------------------------------------------------
+
+class ToolSpanTracker {
+ private _tracer: Tracer;
+ private _parentSpan: Span;
+ _inFlight = new Map<string, Span>();
+ _completed = new Set<string>();
+ private _captureContent: boolean;
+
+ constructor(tracer: Tracer, parentSpan: Span, captureContent: boolean) {
+ this._tracer = tracer;
+ this._parentSpan = parentSpan;
+ this._captureContent = captureContent;
+ }
+
+ startTool(toolName: string, toolInput: any, toolUseId: string): void {
+ const spanName = generateSpanName('execute_tool', toolName);
+ const parentCtx = trace.setSpan(otelContext.active(), this._parentSpan);
+
+ const span = this._tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK,
+ },
+ }, parentCtx);
+
+ setToolSpanAttributes(span, toolName, toolInput, toolUseId, this._captureContent);
+ this._inFlight.set(toolUseId, span);
+ }
+
+ endTool(toolUseId: string, toolResponse?: any): void {
+ const span = this._inFlight.get(toolUseId);
+ if (!span) return;
+ this._inFlight.delete(toolUseId);
+ finalizeToolSpan(span, toolResponse, this._captureContent);
+ span.end();
+ this._completed.add(toolUseId);
+ }
+
+ endToolError(toolUseId: string, error?: string): void {
+ const span = this._inFlight.get(toolUseId);
+ if (!span) return;
+ this._inFlight.delete(toolUseId);
+ finalizeToolSpan(span, null, this._captureContent, true, error);
+ span.end();
+ this._completed.add(toolUseId);
+ }
+
+ endAll(): void {
+ for (const [_toolUseId, span] of this._inFlight) {
+ finalizeToolSpan(span, null, this._captureContent, true, 'abandoned');
+ span.end();
+ }
+ this._inFlight.clear();
+ }
+}
+
+// ---------------------------------------------------------------------------
+// SubagentSpanTracker — manages subagent spans for Task tool
+// ---------------------------------------------------------------------------
+
+class SubagentSpanTracker {
+ private _tracer: Tracer;
+ private _toolTracker: ToolSpanTracker;
+ private _inFlight = new Map<string, Span>();
+ private _toolUseToTask = new Map<string, string>();
+
+ constructor(tracer: Tracer, toolTracker: ToolSpanTracker) {
+ this._tracer = tracer;
+ this._toolTracker = toolTracker;
+ }
+
+ startSubagent(taskId: string, description: string | null, toolUseId?: string): void {
+ const name = description || taskId || 'subagent';
+ const spanName = generateSpanName('subagent', name);
+
+ if (toolUseId) {
+ this._toolUseToTask.set(toolUseId, taskId);
+ }
+
+ let parentSpan: Span | undefined;
+ if (toolUseId) {
+ parentSpan = this._toolTracker._inFlight.get(toolUseId);
+ }
+
+ const ctx = parentSpan ? trace.setSpan(otelContext.active(), parentSpan) : undefined;
+
+ const span = this._tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK,
+ },
+ }, ctx);
+
+ span.setAttribute(GEN_AI_SYSTEM_ATTR, GEN_AI_SYSTEM_VALUE);
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment ?? 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+
+ this._inFlight.set(taskId, span);
+ }
+
+ endSubagent(taskId: string, isError = false, errorMessage?: string | null, usage?: any): void {
+ const span = this._inFlight.get(taskId);
+ if (!span) return;
+ this._inFlight.delete(taskId);
+
+ if (usage) {
+ if (usage.total_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, Number(usage.total_tokens) || 0);
+ }
+ if (usage.tool_uses != null) {
+ span.setAttribute('gen_ai.agent.tool_uses', Number(usage.tool_uses) || 0);
+ }
+ if (usage.duration_ms != null) {
+ span.setAttribute('gen_ai.agent.duration_ms', Number(usage.duration_ms) || 0);
+ }
+ }
+
+ if (isError) {
+ const err = errorMessage ? String(errorMessage) : 'task failed';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, 'SubagentError');
+ span.setStatus({ code: SpanStatusCode.ERROR, message: err });
+ } else {
+ span.setStatus({ code: SpanStatusCode.OK });
+ }
+ span.end();
+ }
+
+ getSpanForToolUseId(toolUseId: string): Span | undefined {
+ const taskId = this._toolUseToTask.get(toolUseId);
+ return taskId ? this._inFlight.get(taskId) : undefined;
+ }
+
+ endAll(): void {
+ for (const taskId of this._inFlight.keys()) {
+ this.endSubagent(taskId, true, 'abandoned');
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Tool span attributes
+// ---------------------------------------------------------------------------
+
+function setToolSpanAttributes(
+ span: Span,
+ toolName: string,
+ toolInput: any,
+ toolUseId: string,
+ captureContent: boolean,
+): void {
+ span.setAttribute(GEN_AI_SYSTEM_ATTR, GEN_AI_SYSTEM_VALUE);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, String(toolName));
+ const toolType = String(toolName).startsWith('mcp__') ? 'extension' : 'function';
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolType);
+
+ if (toolUseId) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, String(toolUseId));
+ }
+
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, SERVER_PORT);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment ?? 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+
+ if (captureContent && toolInput != null) {
+ try {
+ const argsStr = typeof toolInput === 'string' ? toolInput : JSON.stringify(toolInput);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, truncateContent(argsStr));
+ } catch { /* ignore */ }
+ }
+
+ applyCustomSpanAttributes(span);
+}
+
+function finalizeToolSpan(
+ span: Span,
+ toolResponse: any,
+ captureContent: boolean,
+ isError = false,
+ errorMessage?: string | null,
+): void {
+ if (isError) {
+ const errMsg = errorMessage ? String(errorMessage) : 'tool execution failed';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, 'ToolExecutionError');
+ span.setStatus({ code: SpanStatusCode.ERROR, message: errMsg });
+ } else {
+ if (captureContent && toolResponse != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, truncateContent(String(toolResponse)));
+ }
+ span.setStatus({ code: SpanStatusCode.OK });
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Hook injection — merges OpenLIT hooks into user-provided options
+// ---------------------------------------------------------------------------
+
+function injectHooks(
+ options: any,
+ toolTracker: ToolSpanTracker,
+ subagentTracker: SubagentSpanTracker,
+): void {
+ if (!options.hooks) {
+ options.hooks = {};
+ }
+
+ const preToolUse = async (input: any, toolUseId: string | undefined) => {
+ try {
+ const toolName = input.tool_name || 'unknown';
+ const toolInput = input.tool_input;
+ const id = toolUseId || input.tool_use_id;
+ if (id) toolTracker.startTool(toolName, toolInput, id);
+ } catch { /* swallow */ }
+ return {};
+ };
+
+ const postToolUse = async (input: any, toolUseId: string | undefined) => {
+ try {
+ const toolResponse = input.tool_response;
+ const id = toolUseId || input.tool_use_id;
+ if (id) toolTracker.endTool(id, toolResponse);
+ } catch { /* swallow */ }
+ return {};
+ };
+
+ const postToolUseFailure = async (input: any, toolUseId: string | undefined) => {
+ try {
+ const error = input.error || 'unknown error';
+ const id = toolUseId || input.tool_use_id;
+ if (id) toolTracker.endToolError(id, error);
+ } catch { /* swallow */ }
+ return {};
+ };
+
+ const subagentStart = async (input: any, toolUseId: string | undefined) => {
+ try {
+ const agentId = input.agent_id;
+ if (agentId) {
+ const description = input.description || agentId;
+ subagentTracker.startSubagent(agentId, description, toolUseId ?? undefined);
+ }
+ } catch { /* swallow */ }
+ return {};
+ };
+
+ const subagentStop = async (input: any) => {
+ try {
+ const agentId = input.agent_id;
+ if (!agentId) return {};
+ const error = input.error;
+ subagentTracker.endSubagent(agentId, !!error, error);
+ } catch { /* swallow */ }
+ return {};
+ };
+
+ const hookPairs: [string, (...args: any[]) => any][] = [
+ ['PreToolUse', preToolUse],
+ ['PostToolUse', postToolUse],
+ ['PostToolUseFailure', postToolUseFailure],
+ ['SubagentStart', subagentStart],
+ ['SubagentStop', subagentStop],
+ ];
+
+ for (const [event, callback] of hookPairs) {
+ const matcher = { hooks: [callback] };
+ if (options.hooks[event]) {
+ options.hooks[event].push(matcher);
+ } else {
+ options.hooks[event] = [matcher];
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Chat child span — deferred creation for correct content & ordering
+// ---------------------------------------------------------------------------
+
+interface ChatState {
+ pendingChatMsg?: any;
+ pendingChatMsgId?: string;
+ pendingStartMs?: number;
+ pendingEndMs?: number;
+ pendingInput?: any[];
+ lastBoundaryMs: number;
+}
+
+function hasLlmCallData(msg: any): boolean {
+ return msg.message?.model != null && msg.message?.usage != null;
+}
+
+function bufferChatMessage(sdkMsg: any, chatState: ChatState): void {
+ if (!hasLlmCallData(sdkMsg)) return;
+ chatState.pendingChatMsg = sdkMsg;
+ chatState.pendingChatMsgId = sdkMsg.message?.id;
+ chatState.pendingStartMs = chatState.lastBoundaryMs;
+ chatState.pendingEndMs = Date.now();
+}
+
+function flushPendingChat(
+ tracer: Tracer,
+ parentSpan: Span,
+ chatState: ChatState,
+ captureContent: boolean,
+ subagentTracker: SubagentSpanTracker,
+): void {
+ const sdkMsg = chatState.pendingChatMsg;
+ if (!sdkMsg) return;
+
+ delete chatState.pendingChatMsg;
+ delete chatState.pendingChatMsgId;
+ const endMs = chatState.pendingEndMs ?? Date.now();
+ const savedStartMs = chatState.pendingStartMs;
+ delete chatState.pendingStartMs;
+ delete chatState.pendingEndMs;
+
+ const betaMessage = sdkMsg.message;
+ const model = String(betaMessage?.model || 'unknown');
+ const spanName = generateSpanName('chat', model);
+
+ let effectiveParent = parentSpan;
+ const parentToolUseId = sdkMsg.parent_tool_use_id;
+ if (parentToolUseId) {
+ const subagentSpan = subagentTracker.getSpanForToolUseId(parentToolUseId);
+ if (subagentSpan) effectiveParent = subagentSpan;
+ }
+
+ const parentCtx = trace.setSpan(otelContext.active(), effectiveParent);
+ const startMs = savedStartMs ?? chatState.lastBoundaryMs ?? endMs;
+
+ const chatSpan = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC,
+ },
+ startTime: new Date(startMs),
+ }, parentCtx);
+
+ const inputMessages = chatState.pendingInput;
+ delete chatState.pendingInput;
+
+ setChatSpanAttributes(chatSpan, sdkMsg, captureContent, inputMessages);
+ chatSpan.end(new Date(endMs));
+ chatState.lastBoundaryMs = endMs;
+}
+
+// ---------------------------------------------------------------------------
+// Chat span attributes
+// ---------------------------------------------------------------------------
+
+function setChatSpanAttributes(
+ span: Span,
+ sdkMsg: any,
+ captureContent: boolean,
+ inputMessages?: any[] | null,
+): void {
+ try {
+ const betaMessage = sdkMsg.message;
+ const model = betaMessage?.model ? String(betaMessage.model) : null;
+
+ span.setAttribute(GEN_AI_SYSTEM_ATTR, GEN_AI_SYSTEM_VALUE);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, SERVER_PORT);
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment ?? 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, model);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, model);
+ }
+
+ const usage = betaMessage?.usage;
+ const usageAttrs = usage ? extractUsage(usage) : {};
+ for (const [key, value] of Object.entries(usageAttrs)) {
+ span.setAttribute(key, value);
+ }
+
+ let stopReason = betaMessage?.stop_reason;
+ if (!stopReason) {
+ const content = betaMessage?.content;
+ if (Array.isArray(content)) {
+ for (const block of content) {
+ if (block.type === 'tool_use') {
+ stopReason = 'tool_use';
+ break;
+ }
+ }
+ }
+ }
+ const mappedReason = mapFinishReason(stopReason);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [mappedReason]);
+
+ const messageId = betaMessage?.id;
+ if (messageId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, String(messageId));
+ }
+
+ const sessionId = sdkMsg.session_id;
+ if (sessionId) {
+ span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sessionId));
+ }
+
+ const inputTokens = usageAttrs[SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS] ?? 0;
+ const outputTokens = usageAttrs[SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS] ?? 0;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = model ? OpenLitHelper.getChatModelCost(model, pricingInfo, inputTokens, outputTokens) : 0;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, cost);
+
+ let outputMessages: any[] | null = null;
+ if (captureContent) {
+ if (inputMessages) {
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(inputMessages));
+ }
+ outputMessages = buildOutputMessages(betaMessage, mappedReason);
+ if (outputMessages) {
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, JSON.stringify(outputMessages));
+ }
+ }
+
+ applyCustomSpanAttributes(span);
+ span.setStatus({ code: SpanStatusCode.OK });
+
+ if (captureContent) {
+ emitChatInferenceEvent(span, model, messageId, sessionId, mappedReason, usageAttrs, inputMessages, outputMessages);
+ }
+
+ if (!OpenlitConfig.disableMetrics) {
+ recordChatMetrics(model, inputTokens, outputTokens, cost);
+ }
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// Build OTel-compliant output messages from BetaMessage content blocks
+// ---------------------------------------------------------------------------
+
+function buildOutputMessages(betaMessage: any, mappedFinishReason: string): any[] | null {
+ try {
+ const content = betaMessage?.content;
+ if (!content || !Array.isArray(content)) return null;
+
+ const parts: any[] = [];
+ for (const block of content) {
+ if (block.type === 'text') {
+ if (block.text) {
+ parts.push({ type: 'text', content: truncateContent(String(block.text)) });
+ }
+ } else if (block.type === 'thinking') {
+ if (block.thinking) {
+ parts.push({ type: 'reasoning', content: truncateContent(String(block.thinking)) });
+ }
+ } else if (block.type === 'tool_use') {
+ let toolInput = block.input || {};
+ if (typeof toolInput !== 'object') {
+ try { toolInput = JSON.parse(String(toolInput)); } catch { toolInput = {}; }
+ }
+ parts.push({
+ type: 'tool_call',
+ id: String(block.id || ''),
+ name: String(block.name || 'unknown'),
+ arguments: toolInput,
+ });
+ }
+ }
+
+ if (parts.length === 0) return null;
+ return [{ role: 'assistant', parts, finish_reason: mappedFinishReason }];
+ } catch {
+ return null;
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Build OTel input from UserMessage tool results
+// ---------------------------------------------------------------------------
+
+function buildInputFromToolResults(sdkMsg: any): any[] | null {
+ try {
+ const messageParam = sdkMsg.message;
+ const content = messageParam?.content;
+ if (!content || !Array.isArray(content)) return null;
+
+ const parts: any[] = [];
+ for (const block of content) {
+ if (block.type === 'tool_result') {
+ const toolUseId = block.tool_use_id;
+ let resultContent = block.content;
+ if (Array.isArray(resultContent)) {
+ resultContent = resultContent.map((c: any) => c.text || JSON.stringify(c)).join('');
+ }
+ parts.push({
+ type: 'tool_call_response',
+ id: toolUseId ? String(toolUseId) : '',
+ response: resultContent ? truncateContent(String(resultContent)) : '',
+ });
+ }
+ }
+
+ if (parts.length === 0) return null;
+ return [{ role: 'user', parts }];
+ } catch {
+ return null;
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Emit gen_ai.client.inference.operation.details event for chat spans
+// ---------------------------------------------------------------------------
+
+function emitChatInferenceEvent(
+ span: Span,
+ model: string | null,
+ messageId: string | null,
+ sessionId: string | null,
+ mappedReason: string,
+ usageAttrs: UsageAttrs,
+ inputMessages?: any[] | null,
+ outputMessages?: any[] | null,
+): void {
+ if (OpenlitConfig.disableEvents) return;
+
+ try {
+ const attributes: Record<string, any> = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.SERVER_ADDRESS]: SERVER_ADDRESS,
+ [SemanticConvention.SERVER_PORT]: SERVER_PORT,
+ };
+
+ if (model) {
+ attributes[SemanticConvention.GEN_AI_REQUEST_MODEL] = model;
+ attributes[SemanticConvention.GEN_AI_RESPONSE_MODEL] = model;
+ }
+ if (messageId) {
+ attributes[SemanticConvention.GEN_AI_RESPONSE_ID] = String(messageId);
+ }
+ if (sessionId) {
+ attributes[SemanticConvention.GEN_AI_CONVERSATION_ID] = String(sessionId);
+ }
+ if (mappedReason) {
+ attributes[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = [mappedReason];
+ }
+
+ for (const [key, value] of Object.entries(usageAttrs)) {
+ attributes[key] = value;
+ }
+
+ if (inputMessages != null) {
+ attributes[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessages;
+ }
+ if (outputMessages != null) {
+ attributes[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessages;
+ }
+
+ OpenLitHelper.emitInferenceEvent(span, attributes);
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// Chat metrics
+// ---------------------------------------------------------------------------
+
+function recordChatMetrics(
+ model: string | null,
+ inputTokens: number,
+ outputTokens: number,
+ cost: number,
+): void {
+ try {
+ const attributes: Record<string, any> = {
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
+ [ATTR_SERVICE_NAME]: OpenlitConfig.applicationName ?? 'default',
+ [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: OpenlitConfig.environment ?? 'default',
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC,
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.SERVER_ADDRESS]: SERVER_ADDRESS,
+ [SemanticConvention.SERVER_PORT]: SERVER_PORT,
+ };
+ if (model) {
+ attributes[SemanticConvention.GEN_AI_REQUEST_MODEL] = model;
+ }
+
+ if (inputTokens && Metrics.genaiClientUsageTokens) {
+ Metrics.genaiClientUsageTokens.record(inputTokens, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_INPUT,
+ });
+ }
+ if (outputTokens && Metrics.genaiClientUsageTokens) {
+ Metrics.genaiClientUsageTokens.record(outputTokens, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_OUTPUT,
+ });
+ }
+ if (cost && Metrics.genaiCost) {
+ Metrics.genaiCost.record(cost, attributes);
+ }
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// Process result message — finalize root span with usage/cost data
+// ---------------------------------------------------------------------------
+
+function processResultMessage(span: Span, sdkMsg: any, captureContent: boolean): { inputTokens: number; outputTokens: number } {
+ const resultUsage = { inputTokens: 0, outputTokens: 0 };
+ try {
+ const sessionId = sdkMsg.session_id;
+ if (sessionId) {
+ span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sessionId));
+ }
+
+ const usage = sdkMsg.usage;
+ if (usage) {
+ const usageAttrs = extractUsage(usage);
+ for (const [key, value] of Object.entries(usageAttrs)) {
+ span.setAttribute(key, value);
+ }
+ resultUsage.inputTokens = usageAttrs[SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS] ?? 0;
+ resultUsage.outputTokens = usageAttrs[SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS] ?? 0;
+ }
+
+ const totalCost = sdkMsg.total_cost_usd;
+ if (totalCost != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, Number(totalCost) || 0);
+ }
+
+ const modelUsage = sdkMsg.modelUsage;
+ if (modelUsage && typeof modelUsage === 'object') {
+ const modelNames = Object.keys(modelUsage);
+ if (modelNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(modelNames[0]));
+ }
+ }
+
+ if (sdkMsg.num_turns != null) {
+ span.setAttribute('gen_ai.agent.num_turns', Number(sdkMsg.num_turns) || 0);
+ }
+ if (sdkMsg.duration_ms != null) {
+ span.setAttribute('gen_ai.agent.duration_ms', Number(sdkMsg.duration_ms) || 0);
+ }
+ if (sdkMsg.duration_api_ms != null) {
+ span.setAttribute('gen_ai.agent.duration_api_ms', Number(sdkMsg.duration_api_ms) || 0);
+ }
+
+ if (sdkMsg.is_error) {
+ const errResult = sdkMsg.errors?.join('; ') || sdkMsg.result || 'unknown error';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, 'AgentError');
+ span.setStatus({ code: SpanStatusCode.ERROR, message: String(errResult) });
+ } else {
+ span.setStatus({ code: SpanStatusCode.OK });
+ }
+
+ if (captureContent) {
+ const result = sdkMsg.result;
+ if (result) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ JSON.stringify([{
+ role: 'assistant',
+ parts: [{ type: 'text', content: truncateContent(String(result)) }],
+ }]),
+ );
+ }
+ }
+ } catch { /* swallow */ }
+
+ return resultUsage;
+}
+
+// ---------------------------------------------------------------------------
+// Message stream processor
+// ---------------------------------------------------------------------------
+
+function processMessage(
+ sdkMsg: any,
+ span: Span,
+ toolTracker: ToolSpanTracker,
+ subagentTracker: SubagentSpanTracker,
+ captureContent: boolean,
+ tracer: Tracer,
+ chatState: ChatState,
+): { inputTokens: number; outputTokens: number } | null {
+ const msgType = sdkMsg.type;
+ let resultUsage: { inputTokens: number; outputTokens: number } | null = null;
+
+ if (msgType === 'assistant') {
+ updateRootFromAssistant(span, sdkMsg);
+
+ if (hasLlmCallData(sdkMsg)) {
+ const newMsgId = sdkMsg.message?.id;
+ const pendingMsgId = chatState.pendingChatMsgId;
+ if (pendingMsgId != null && newMsgId !== pendingMsgId) {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ }
+ bufferChatMessage(sdkMsg, chatState);
+ }
+ } else if (msgType === 'user') {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ if (captureContent) {
+ const toolInput = buildInputFromToolResults(sdkMsg);
+ if (toolInput) {
+ chatState.pendingInput = toolInput;
+ }
+ }
+ } else if (msgType === 'result') {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ resultUsage = processResultMessage(span, sdkMsg, captureContent);
+ } else if (msgType === 'system' && sdkMsg.subtype === 'task_started') {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ try {
+ const taskId = sdkMsg.task_id;
+ const description = sdkMsg.description;
+ const toolUseId = sdkMsg.tool_use_id;
+ if (taskId) {
+ subagentTracker.startSubagent(taskId, description, toolUseId);
+ }
+ } catch { /* swallow */ }
+ } else if (msgType === 'system' && sdkMsg.subtype === 'task_notification') {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ try {
+ const taskId = sdkMsg.task_id;
+ const status = sdkMsg.status;
+ const isError = status === 'failed' || status === 'stopped';
+ const errorMsg = isError ? sdkMsg.summary : null;
+ const taskUsage = sdkMsg.usage;
+ if (taskId) {
+ subagentTracker.endSubagent(taskId, isError, errorMsg, taskUsage);
+ }
+ } catch { /* swallow */ }
+ }
+
+ chatState.lastBoundaryMs = Date.now();
+ return resultUsage;
+}
+
+function updateRootFromAssistant(span: Span, sdkMsg: any): void {
+ try {
+ const model = sdkMsg.message?.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(model));
+ }
+ const sessionId = sdkMsg.session_id;
+ if (sessionId) {
+ span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sessionId));
+ }
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// Message-based tool span fallback (when hooks don't fire)
+// ---------------------------------------------------------------------------
+
+function processToolBlocksFromMessages(
+ sdkMsg: any,
+ toolTracker: ToolSpanTracker,
+ subagentTracker: SubagentSpanTracker,
+): void {
+ const msgType = sdkMsg.type;
+
+ if (msgType === 'assistant') {
+ const content = sdkMsg.message?.content;
+ if (!content || !Array.isArray(content)) return;
+
+ const parentToolUseId = sdkMsg.parent_tool_use_id;
+ let effectiveParent: Span | undefined;
+ if (parentToolUseId) {
+ effectiveParent = subagentTracker.getSpanForToolUseId(parentToolUseId);
+ }
+
+ for (const block of content) {
+ if (block.type === 'tool_use') {
+ const toolName = block.name || 'unknown';
+ const toolInput = block.input;
+ const toolId = block.id;
+ if (toolId && !toolTracker._inFlight.has(toolId) && !toolTracker._completed.has(toolId)) {
+ if (effectiveParent) {
+ const spanName = generateSpanName('execute_tool', toolName);
+ const parentCtx = trace.setSpan(otelContext.active(), effectiveParent);
+ const span = toolTracker['_tracer'].startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK,
+ },
+ }, parentCtx);
+ setToolSpanAttributes(span, toolName, toolInput, toolId, OpenlitConfig.captureMessageContent ?? true);
+ toolTracker._inFlight.set(toolId, span);
+ } else {
+ toolTracker.startTool(toolName, toolInput, toolId);
+ }
+ }
+ }
+ }
+ } else if (msgType === 'user') {
+ const content = sdkMsg.message?.content;
+ if (!content || !Array.isArray(content)) return;
+ for (const block of content) {
+ if (block.type === 'tool_result') {
+ const toolUseId = block.tool_use_id;
+ const isError = block.is_error;
+ const resultContent = block.content;
+ if (toolUseId && toolTracker._inFlight.has(toolUseId)) {
+ if (isError) {
+ toolTracker.endToolError(toolUseId, resultContent);
+ } else {
+ toolTracker.endTool(toolUseId, resultContent);
+ }
+ }
+ }
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Set initial span attributes on the root invoke_agent span
+// ---------------------------------------------------------------------------
+
+function setInitialSpanAttributes(
+ span: Span,
+ options: any,
+ prompt: any,
+ captureContent: boolean,
+): void {
+ try {
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK);
+ span.setAttribute(GEN_AI_SYSTEM_ATTR, GEN_AI_SYSTEM_VALUE);
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment ?? 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, SERVER_PORT);
+
+ const agentName = resolveAgentName(options);
+ if (agentName) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, agentName);
+ }
+
+ const model = options?.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ }
+
+ if (captureContent) {
+ const systemPrompt = options?.systemPrompt;
+ if (systemPrompt && typeof systemPrompt === 'string') {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS,
+ JSON.stringify([{ type: 'text', content: truncateContent(systemPrompt) }]),
+ );
+ }
+
+ if (prompt && typeof prompt === 'string') {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ JSON.stringify([{
+ role: 'user',
+ parts: [{ type: 'text', content: truncateContent(prompt) }],
+ }]),
+ );
+ }
+ }
+
+ applyCustomSpanAttributes(span);
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// Finalize root span — record duration and token usage metrics
+// ---------------------------------------------------------------------------
+
+function finalizeSpan(
+ span: Span,
+ startTime: number,
+ inputTokens: number,
+ outputTokens: number,
+): void {
+ try {
+ const duration = (Date.now() / 1000) - startTime;
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+
+ if (!OpenlitConfig.disableMetrics) {
+ const attributes: Record<string, any> = {
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
+ [ATTR_SERVICE_NAME]: OpenlitConfig.applicationName ?? 'default',
+ [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: OpenlitConfig.environment ?? 'default',
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK,
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ [GEN_AI_SYSTEM_ATTR]: GEN_AI_SYSTEM_VALUE,
+ [SemanticConvention.SERVER_ADDRESS]: SERVER_ADDRESS,
+ [SemanticConvention.SERVER_PORT]: SERVER_PORT,
+ };
+
+ if (Metrics.genaiClientOperationDuration) {
+ Metrics.genaiClientOperationDuration.record(duration, attributes);
+ }
+
+ if (inputTokens && Metrics.genaiClientUsageTokens) {
+ Metrics.genaiClientUsageTokens.record(inputTokens, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_INPUT,
+ });
+ }
+ if (outputTokens && Metrics.genaiClientUsageTokens) {
+ Metrics.genaiClientUsageTokens.record(outputTokens, {
+ ...attributes,
+ [SemanticConvention.GEN_AI_TOKEN_TYPE]: SemanticConvention.GEN_AI_TOKEN_TYPE_OUTPUT,
+ });
+ }
+ }
+ } catch { /* swallow */ }
+}
+
+// ---------------------------------------------------------------------------
+// patchQuery — wraps the `query()` export from @anthropic-ai/claude-agent-sdk
+// ---------------------------------------------------------------------------
+
+export function patchQuery(tracer: Tracer): (originalQuery: any) => any {
+ return (originalQuery: any) => {
+ return function wrappedQuery(this: any, params: { prompt: any; options?: any }) {
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+ const prompt = params.prompt;
+ const userOptions = params.options;
+ const options = userOptions ? { ...userOptions } : {};
+
+ const agentName = resolveAgentName(options);
+ const spanName = generateSpanName('query', agentName);
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_CLAUDE_AGENT_SDK,
+ },
+ });
+
+ const spanContext = trace.setSpan(otelContext.active(), span);
+ const startTime = Date.now() / 1000;
+ const chatState: ChatState = { lastBoundaryMs: Date.now() };
+ const toolTracker = new ToolSpanTracker(tracer, span, captureContent);
+ const subagentTracker = new SubagentSpanTracker(tracer, toolTracker);
+ const aggregateUsage = { inputTokens: 0, outputTokens: 0 };
+
+ if (prompt && typeof prompt === 'string' && captureContent) {
+ chatState.pendingInput = [{
+ role: 'user',
+ parts: [{ type: 'text', content: truncateContent(prompt) }],
+ }];
+ }
+
+ injectHooks(options, toolTracker, subagentTracker);
+ setInitialSpanAttributes(span, options, prompt, captureContent);
+
+ setFrameworkLlmActive();
+
+ let query: any;
+ try {
+ query = otelContext.with(spanContext, () => {
+ return originalQuery.call(this, { prompt, options });
+ });
+ } catch (e: any) {
+ resetFrameworkLlmActive();
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+
+ let done = false;
+
+ const cleanup = () => {
+ if (done) return;
+ done = true;
+ resetFrameworkLlmActive();
+ subagentTracker.endAll();
+ toolTracker.endAll();
+ finalizeSpan(span, startTime, aggregateUsage.inputTokens, aggregateUsage.outputTokens);
+ span.end();
+ };
+
+ const originalNext = query.next.bind(query);
+ const originalReturn = query.return?.bind(query);
+ const originalThrow = query.throw?.bind(query);
+
+ return new Proxy(query, {
+ get(target: any, prop: string | symbol, receiver: any) {
+ if (prop === 'next') {
+ return async function (...args: any[]) {
+ try {
+ const result = await originalNext(...args);
+ if (result.done) {
+ if (!done) {
+ flushPendingChat(tracer, span, chatState, captureContent, subagentTracker);
+ if (aggregateUsage.inputTokens === 0 && aggregateUsage.outputTokens === 0) {
+ span.setStatus({ code: SpanStatusCode.OK });
+ }
+ }
+ cleanup();
+ return result;
+ }
+
+ const sdkMsg = result.value;
+ try {
+ const msgUsage = processMessage(
+ sdkMsg, span, toolTracker, subagentTracker,
+ captureContent, tracer, chatState,
+ );
+ if (msgUsage) {
+ aggregateUsage.inputTokens = msgUsage.inputTokens;
+ aggregateUsage.outputTokens = msgUsage.outputTokens;
+ }
+ processToolBlocksFromMessages(sdkMsg, toolTracker, subagentTracker);
+ } catch { /* swallow processing errors */ }
+
+ return result;
+ } catch (e: any) {
+ if (!done) {
+ OpenLitHelper.handleException(span, e);
+ }
+ cleanup();
+ throw e;
+ }
+ };
+ }
+
+ if (prop === 'return') {
+ return async function (value?: any) {
+ cleanup();
+ return originalReturn ? originalReturn(value) : { done: true as const, value };
+ };
+ }
+
+ if (prop === 'throw') {
+ return async function (e?: any) {
+ if (!done) {
+ OpenLitHelper.handleException(span, e instanceof Error ? e : new Error(String(e)));
+ }
+ cleanup();
+ return originalThrow ? originalThrow(e) : { done: true as const, value: undefined };
+ };
+ }
+
+ if (prop === Symbol.asyncIterator) {
+ return function () { return receiver; };
+ }
+
+ return Reflect.get(target, prop, receiver);
+ },
+ });
+ };
+ };
+}
diff --git a/sdk/typescript/src/instrumentation/cohere/index.ts b/sdk/typescript/src/instrumentation/cohere/index.ts
index b0a6f2ef..8cb2acf0 100644
--- a/sdk/typescript/src/instrumentation/cohere/index.ts
+++ b/sdk/typescript/src/instrumentation/cohere/index.ts
@@ -6,7 +6,6 @@ import {
} from '@opentelemetry/instrumentation';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { INSTRUMENTATION_PREFIX } from '../../constant';
-import Cohere from 'cohere-ai';
import CohereWrapper from './wrapper';
export interface CohereInstrumentationConfig extends InstrumentationConfig {}
@@ -37,7 +36,7 @@ export default class OpenlitCohereInstrumentation extends InstrumentationBase {
this._patch(cohere);
}
- protected _patch(moduleExports: typeof Cohere) {
+ protected _patch(moduleExports: any) {
try {
if (isWrapped(moduleExports.CohereClient.prototype.embed)) {
this._unwrap(moduleExports.CohereClient.prototype, 'embed');
@@ -71,7 +70,7 @@ export default class OpenlitCohereInstrumentation extends InstrumentationBase {
}
}
- protected _unpatch(moduleExports: typeof Cohere) {
+ protected _unpatch(moduleExports: any) {
this._unwrap(moduleExports.CohereClient.prototype, 'embed');
this._unwrap(moduleExports.CohereClient.prototype, 'chat');
this._unwrap(moduleExports.CohereClient.prototype, 'chatStream');
diff --git a/sdk/typescript/src/instrumentation/cohere/wrapper.ts b/sdk/typescript/src/instrumentation/cohere/wrapper.ts
index 79f92107..f46e3f16 100644
--- a/sdk/typescript/src/instrumentation/cohere/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/cohere/wrapper.ts
@@ -1,69 +1,95 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
-import BaseWrapper from '../base-wrapper';
+import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_COHERE,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: CohereWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: CohereWrapper.serverPort,
+ };
+}
export default class CohereWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_COHERE;
static serverAddress = 'api.cohere.com';
static serverPort = 443;
+
static _patchEmbed(tracer: Tracer): any {
const genAIEndpoint = 'cohere.embed';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'embed-english-v2.0';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ let metricParams: BaseSpanAttributes | undefined;
try {
const response = await originalMethod.apply(this, args);
- const model = response.model || 'embed-english-v2.0';
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+
+ const _responseModel = response.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = response.meta?.billedUnits?.inputTokens || 0;
const cost = OpenLitHelper.getEmbedModelCost(
- model,
+ requestModel,
pricingInfo,
- response.meta.billedUnits.inputTokens
- );
-
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING
+ inputTokens
);
- const { dimensions, encoding_format = 'float', input, user, texts = [] } = args[0];
- // Set base span attribues
+ const { dimensions, encoding_format = 'float', texts = [], user } = args[0];
CohereWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: CohereWrapper.aiSystem,
+ serverAddress: CohereWrapper.serverAddress,
+ serverPort: CohereWrapper.serverPort,
});
- // Request Params attributes : Start
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, encoding_format);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_EMBEDDING_DIMENSION, dimensions);
- if (traceContent) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, [encoding_format]);
+ if (dimensions) {
+ span.setAttribute(SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT, dimensions);
+ }
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(texts));
}
- // Request Params attributes : End
+
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, response.id);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
- response.meta.billedUnits.inputTokens
- );
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
- response.meta.billedUnits.inputTokens
- );
+ metricParams = {
+ genAIEndpoint,
+ model: requestModel,
+ user,
+ cost,
+ aiSystem: CohereWrapper.aiSystem,
+ };
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
}
});
};
@@ -74,9 +100,16 @@ export default class CohereWrapper extends BaseWrapper {
const genAIEndpoint = 'cohere.chat';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'command-r-plus-08-2024';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -84,7 +117,16 @@ export default class CohereWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: CohereWrapper.aiSystem,
+ serverAddress: CohereWrapper.serverAddress,
+ serverPort: CohereWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
+ throw e;
});
};
};
@@ -94,9 +136,16 @@ export default class CohereWrapper extends BaseWrapper {
const genAIEndpoint = 'cohere.chat';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'command-r-plus-08-2024';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -112,7 +161,16 @@ export default class CohereWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: CohereWrapper.aiSystem,
+ serverAddress: CohereWrapper.serverAddress,
+ serverPort: CohereWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
+ throw e;
});
};
};
@@ -136,11 +194,11 @@ export default class CohereWrapper extends BaseWrapper {
genAIEndpoint,
result: response,
span,
- stream: false,
});
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -168,7 +226,7 @@ export default class CohereWrapper extends BaseWrapper {
response_id: '',
text: '',
generationId: '',
- chatHistory: [],
+ chatHistory: [] as any[],
finishReason: '',
meta: {
apiVersion: { version: '1' },
@@ -184,12 +242,11 @@ export default class CohereWrapper extends BaseWrapper {
yield chunk;
}
- // Calculate TTFT and TBT
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
- const timeDiffs = timestamps.slice(1).map((t, i) => t - timestamps[i]);
- tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
+ const timeDiffs = timestamps.slice(1).map((t: number, i: number) => t - timestamps[i]);
+ tbt = timeDiffs.reduce((a: number, b: number) => a + b, 0) / timeDiffs.length / 1000;
}
metricParams = await CohereWrapper._chatCommonSetter({
@@ -205,9 +262,9 @@ export default class CohereWrapper extends BaseWrapper {
return result;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -219,7 +276,7 @@ export default class CohereWrapper extends BaseWrapper {
genAIEndpoint,
result,
span,
- stream,
+ stream = false,
ttft = 0,
tbt = 0,
}: {
@@ -227,53 +284,76 @@ export default class CohereWrapper extends BaseWrapper {
genAIEndpoint: string;
result: any;
span: Span;
- stream: boolean;
+ stream?: boolean;
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'command-r-plus-08-2024';
const {
message,
- model = 'command-r-plus-08-2024',
+ messages,
frequency_penalty = 0,
max_tokens = null,
presence_penalty = 0,
seed = null,
+ stop_sequences = null,
temperature = 1,
+ p: topP,
+ k: topK,
user,
- tools,
+ tools: _tools,
} = args[0];
- // Request Params attributes : Start
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, topP ?? 1);
+ if (topK != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, topK);
+ }
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, seed);
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
+ if (stop_sequences) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(stop_sequences) ? stop_sequences : [stop_sequences]);
+ }
+
+ const inputMessages = messages || (message ? [{ role: 'user', content: message }] : []);
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages([{ role: 'user', content: message }]));
+ if (captureContent) {
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(inputMessages));
}
- // Request Params attributes : End
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ const responseId = result.response_id || result.id || '';
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, responseId);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.response_id);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const inputTokens = result.meta?.billedUnits?.inputTokens
+ ?? result.usage?.billed_units?.input_tokens ?? 0;
+ const outputTokens = result.meta?.billedUnits?.outputTokens
+ ?? result.usage?.billed_units?.output_tokens ?? 0;
- // Calculate cost of the operation
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
- result.meta.billedUnits.inputTokens,
- result.meta.billedUnits.outputTokens
+ inputTokens,
+ outputTokens
);
CohereWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: CohereWrapper.aiSystem,
@@ -281,24 +361,11 @@ export default class CohereWrapper extends BaseWrapper {
serverPort: CohereWrapper.serverPort,
});
- // Response model
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, model);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, requestModel);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
- result.meta.billedUnits.inputTokens
- );
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
- result.meta.billedUnits.outputTokens
- );
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
- result.meta.billedUnits.inputTokens + result.meta.billedUnits.outputTokens
- );
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.meta.billedUnits.inputTokens + result.meta.billedUnits.outputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- // TTFT and TBT streaming metrics
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -306,21 +373,74 @@ export default class CohereWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- if (result.finishReason) {
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.finishReason]);
+ const finishReason = result.finishReason || result.finish_reason || '';
+ if (finishReason) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
+ }
+
+ const responseText = result.text ?? '';
+ const outputType = typeof responseText === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ const toolCalls = result.toolCalls || result.message?.tool_calls;
+ if (toolCalls && Array.isArray(toolCalls)) {
+ const toolNames = toolCalls.map((t: any) => t.function?.name || t.name || '').filter(Boolean);
+ const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
+ const toolArgs = toolCalls.map((t: any) => t.function?.arguments || t.arguments || '').filter(Boolean);
+
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
}
- if (traceContent) {
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(result.text || '', result.finishReason || 'stop')
+ const toolPlan = result.toolPlan || result.message?.tool_plan;
+ if (toolPlan) {
+ span.setAttribute(SemanticConvention.GEN_AI_CONTENT_REASONING, toolPlan);
+ }
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ responseText,
+ finishReason || 'stop',
+ toolCalls
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(inputMessages);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: CohereWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: CohereWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: responseId,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason || 'stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
- // Return metric parameters instead of recording metrics directly
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: CohereWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/google-adk/index.ts b/sdk/typescript/src/instrumentation/google-adk/index.ts
new file mode 100644
index 00000000..b132459d
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/google-adk/index.ts
@@ -0,0 +1,404 @@
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+ isWrapped,
+} from '@opentelemetry/instrumentation';
+import { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { trace } from '@opentelemetry/api';
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import {
+ PassthroughTracer,
+ enrichLlmSpan,
+ enrichToolSpan,
+ enrichMergedToolSpan,
+} from './utils';
+import {
+ AgentCreationRegistry,
+ wrapAgentInit,
+ wrapRunnerRun,
+ wrapRunnerRunAsync,
+ wrapAgentRunAsync,
+} from './wrapper';
+import OpenlitConfig from '../../config';
+
+export interface GoogleADKInstrumentationConfig extends InstrumentationConfig {}
+
+/**
+ * OTel GenAI semantic convention compliant instrumentor for Google ADK.
+ *
+ * Monkey-patches Runner, BaseAgent, and LlmAgent from @google/adk.
+ * Replaces ADK's internal tracers with PassthroughTracer to suppress
+ * duplicate spans. Enriches ADK's LLM and tool spans with OTel attributes.
+ */
+export default class GoogleADKInstrumentation extends InstrumentationBase {
+ private _registry = new AgentCreationRegistry();
+ private _originalTracers: Record<string, any> = {};
+ private _originalTraceCallLlm: any = null;
+ private _originalTraceToolCall: any = null;
+ private _originalTraceMergedToolCalls: any = null;
+
+ constructor(config: GoogleADKInstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-google-adk`, '1.0.0', config);
+ }
+
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
+ const module = new InstrumentationNodeModuleDefinition(
+ '@google/adk',
+ ['>=1.2.0'],
+ (moduleExports) => {
+ this._patchAll(moduleExports);
+ return moduleExports;
+ },
+ (moduleExports) => {
+ if (moduleExports !== undefined) {
+ this._unpatchAll(moduleExports);
+ }
+ }
+ );
+
+ return [module];
+ }
+
+ public manualPatch(adkModule: any): void {
+ this._patchAll(adkModule);
+ }
+
+ // ---------------------------------------------------------------------------
+ // Patching
+ // ---------------------------------------------------------------------------
+
+ private _patchAll(moduleExports: any): void {
+ try {
+ this._disableExistingTracers(moduleExports);
+ this._wrapTraceCallLlm(moduleExports);
+ this._wrapTraceToolCall(moduleExports);
+ this._wrapTraceMergedToolCalls(moduleExports);
+ this._patchLlmAgent(moduleExports);
+ this._patchRunner(moduleExports);
+ this._patchBaseAgent(moduleExports);
+ } catch { /* graceful degradation */ }
+ }
+
+ /**
+ * Replace ADK's internal tracers with PassthroughTracer to suppress
+ * duplicate top-level spans (mirrors Python _disable_existing_tracers).
+ */
+ private _disableExistingTracers(moduleExports: any): void {
+ try {
+ const runners = this._resolveSubmodule(moduleExports, 'runners');
+ if (runners && runners.tracer) {
+ this._originalTracers['runners.tracer'] = runners.tracer;
+ runners.tracer = new PassthroughTracer(runners.tracer);
+ }
+ } catch { /* ignore */ }
+
+ try {
+ const baseAgentMod = this._resolveSubmodule(moduleExports, 'agents', 'base_agent') ??
+ this._resolveSubmodule(moduleExports, 'agents');
+ if (baseAgentMod && baseAgentMod.tracer) {
+ this._originalTracers['base_agent.tracer'] = baseAgentMod.tracer;
+ baseAgentMod.tracer = new PassthroughTracer(baseAgentMod.tracer);
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Wrap ADK's trace_call_llm to enrich the current span with OTel GenAI attributes.
+ */
+ private _wrapTraceCallLlm(moduleExports: any): void {
+ try {
+ const blfMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'base_llm_flow') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (!blfMod) return;
+
+ const originalFn = blfMod.trace_call_llm ?? blfMod.traceCallLlm;
+ if (!originalFn) return;
+
+ this._originalTraceCallLlm = originalFn;
+ const captureContent = () => OpenlitConfig.captureMessageContent ?? true;
+
+ const enriched = (...args: any[]) => {
+ const result = originalFn(...args);
+ try {
+ const span = trace.getActiveSpan();
+ if (span) {
+ const llmRequest = args[2];
+ const llmResponse = args[3];
+ enrichLlmSpan(span, llmRequest, llmResponse, captureContent());
+ }
+ } catch { /* ignore */ }
+ return result;
+ };
+
+ if (blfMod.trace_call_llm) {
+ blfMod.trace_call_llm = enriched;
+ } else if (blfMod.traceCallLlm) {
+ blfMod.traceCallLlm = enriched;
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Wrap ADK's trace_tool_call to enrich the current span with tool attributes.
+ */
+ private _wrapTraceToolCall(moduleExports: any): void {
+ try {
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (!fnMod) return;
+
+ const originalFn = fnMod.trace_tool_call ?? fnMod.traceToolCall;
+ if (!originalFn) return;
+
+ this._originalTraceToolCall = originalFn;
+ const captureContent = () => OpenlitConfig.captureMessageContent ?? true;
+
+ const enriched = (...args: any[]) => {
+ const result = originalFn(...args);
+ try {
+ const span = trace.getActiveSpan();
+ if (span) {
+ const tool = args[0];
+ const functionArgs = args[1];
+ const functionResponseEvent = args[2];
+ const toolError = args[3];
+ enrichToolSpan(span, tool, functionArgs, functionResponseEvent, captureContent(), toolError);
+ }
+ } catch { /* ignore */ }
+ return result;
+ };
+
+ if (fnMod.trace_tool_call) {
+ fnMod.trace_tool_call = enriched;
+ } else if (fnMod.traceToolCall) {
+ fnMod.traceToolCall = enriched;
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Wrap ADK's trace_merged_tool_calls to enrich the current span with merged tool attributes.
+ */
+ private _wrapTraceMergedToolCalls(moduleExports: any): void {
+ try {
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (!fnMod) return;
+
+ const originalFn = fnMod.trace_merged_tool_calls ?? fnMod.traceMergedToolCalls;
+ if (!originalFn) return;
+
+ this._originalTraceMergedToolCalls = originalFn;
+ const captureContent = () => OpenlitConfig.captureMessageContent ?? true;
+
+ const enriched = (...args: any[]) => {
+ const result = originalFn(...args);
+ try {
+ const span = trace.getActiveSpan();
+ if (span) {
+ const responseEventId = args[0];
+ const functionResponseEvent = args[1];
+ enrichMergedToolSpan(span, responseEventId, functionResponseEvent, captureContent());
+ }
+ } catch { /* ignore */ }
+ return result;
+ };
+
+ if (fnMod.trace_merged_tool_calls) {
+ fnMod.trace_merged_tool_calls = enriched;
+ } else if (fnMod.traceMergedToolCalls) {
+ fnMod.traceMergedToolCalls = enriched;
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Patch LlmAgent constructor to create create_agent spans.
+ */
+ private _patchLlmAgent(moduleExports: any): void {
+ try {
+ const LlmAgent = moduleExports.LlmAgent ?? moduleExports.Agent;
+ if (!LlmAgent?.prototype) return;
+
+ const originalClass = LlmAgent;
+ const patchFn = wrapAgentInit(this.tracer, this._registry);
+
+ // Wrap any init-like method if available; otherwise wrap the class prototype methods
+ // ADK's LlmAgent may expose initialization through sub_agents, tools setters, etc.
+ // The most reliable approach is patching the constructor via a proxy pattern.
+ if (typeof originalClass === 'function') {
+ const wrappedConstructor = patchFn(function (this: any, ...args: any[]) {
+ return Reflect.construct(originalClass, args, new.target || originalClass);
+ });
+
+ // Copy static properties
+ Object.setPrototypeOf(wrappedConstructor, originalClass);
+ wrappedConstructor.prototype = originalClass.prototype;
+
+ // ESM-to-CJS interop may define exports as getter-only properties;
+ // both defineProperty and assignment may fail for ESM Module Namespace objects.
+ const exportName = moduleExports.LlmAgent ? 'LlmAgent' : 'Agent';
+ try {
+ Object.defineProperty(moduleExports, exportName, {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: wrappedConstructor,
+ });
+ } catch {
+ try { (moduleExports as any)[exportName] = wrappedConstructor; } catch { /* strict mode */ }
+ }
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Patch Runner.run and Runner.runAsync (or run_async).
+ */
+ private _patchRunner(moduleExports: any): void {
+ try {
+ const Runner = moduleExports.Runner;
+ if (!Runner?.prototype) return;
+
+ // Runner.run (sync)
+ const runMethod = Runner.prototype.run;
+ if (runMethod && !isWrapped(runMethod)) {
+ this._wrap(
+ Runner.prototype,
+ 'run',
+ wrapRunnerRun(this.tracer, 'runner_run', this._registry)
+ );
+ }
+
+ // Runner.runAsync or Runner.run_async (async generator)
+ const runAsyncName = Runner.prototype.runAsync ? 'runAsync' : 'run_async';
+ const runAsyncMethod = Runner.prototype[runAsyncName];
+ if (runAsyncMethod) {
+ if (isWrapped(runAsyncMethod)) this._unwrap(Runner.prototype, runAsyncName);
+ this._wrap(
+ Runner.prototype,
+ runAsyncName,
+ wrapRunnerRunAsync(this.tracer, 'runner_run_async', this._registry)
+ );
+ }
+
+ // Runner.runLive or Runner.run_live (async generator)
+ const runLiveName = Runner.prototype.runLive ? 'runLive' : 'run_live';
+ const runLiveMethod = Runner.prototype[runLiveName];
+ if (runLiveMethod) {
+ if (isWrapped(runLiveMethod)) this._unwrap(Runner.prototype, runLiveName);
+ this._wrap(
+ Runner.prototype,
+ runLiveName,
+ wrapRunnerRunAsync(this.tracer, 'runner_run_live', this._registry)
+ );
+ }
+ } catch { /* ignore */ }
+ }
+
+ /**
+ * Patch BaseAgent.runAsync (or run_async).
+ */
+ private _patchBaseAgent(moduleExports: any): void {
+ try {
+ const BaseAgent = moduleExports.BaseAgent;
+ if (!BaseAgent?.prototype) return;
+
+ const runAsyncName = BaseAgent.prototype.runAsync ? 'runAsync' : 'run_async';
+ const runAsyncMethod = BaseAgent.prototype[runAsyncName];
+ if (runAsyncMethod) {
+ if (isWrapped(runAsyncMethod)) this._unwrap(BaseAgent.prototype, runAsyncName);
+ this._wrap(
+ BaseAgent.prototype,
+ runAsyncName,
+ wrapAgentRunAsync(this.tracer, 'agent_run_async', this._registry)
+ );
+ }
+ } catch { /* ignore */ }
+ }
+
+ // ---------------------------------------------------------------------------
+ // Submodule resolution
+ // ---------------------------------------------------------------------------
+
+ /**
+ * Attempt to resolve a nested submodule from the ADK exports.
+ * ADK's JS package may organize exports differently from Python.
+ */
+ private _resolveSubmodule(moduleExports: any, ...path: string[]): any {
+ let current = moduleExports;
+ for (const segment of path) {
+ if (!current) return null;
+ current = current[segment];
+ }
+ return current || null;
+ }
+
+ // ---------------------------------------------------------------------------
+ // Unpatching
+ // ---------------------------------------------------------------------------
+
+ private _unpatchAll(moduleExports: any): void {
+ try {
+ // Restore original tracers
+ if (this._originalTracers['runners.tracer']) {
+ const runners = this._resolveSubmodule(moduleExports, 'runners');
+ if (runners) runners.tracer = this._originalTracers['runners.tracer'];
+ }
+ if (this._originalTracers['base_agent.tracer']) {
+ const baseAgentMod = this._resolveSubmodule(moduleExports, 'agents', 'base_agent') ??
+ this._resolveSubmodule(moduleExports, 'agents');
+ if (baseAgentMod) baseAgentMod.tracer = this._originalTracers['base_agent.tracer'];
+ }
+
+ // Restore original tracing functions
+ if (this._originalTraceCallLlm) {
+ const blfMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'base_llm_flow') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (blfMod) {
+ if (blfMod.trace_call_llm) blfMod.trace_call_llm = this._originalTraceCallLlm;
+ else if (blfMod.traceCallLlm) blfMod.traceCallLlm = this._originalTraceCallLlm;
+ }
+ }
+ if (this._originalTraceToolCall) {
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (fnMod) {
+ if (fnMod.trace_tool_call) fnMod.trace_tool_call = this._originalTraceToolCall;
+ else if (fnMod.traceToolCall) fnMod.traceToolCall = this._originalTraceToolCall;
+ }
+ }
+ if (this._originalTraceMergedToolCalls) {
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
+ this._resolveSubmodule(moduleExports, 'flows');
+ if (fnMod) {
+ if (fnMod.trace_merged_tool_calls) fnMod.trace_merged_tool_calls = this._originalTraceMergedToolCalls;
+ else if (fnMod.traceMergedToolCalls) fnMod.traceMergedToolCalls = this._originalTraceMergedToolCalls;
+ }
+ }
+
+ // Unwrap patched methods
+ const Runner = moduleExports.Runner;
+ if (Runner?.prototype) {
+ if (isWrapped(Runner.prototype.run)) this._unwrap(Runner.prototype, 'run');
+ const runAsyncName = Runner.prototype.runAsync ? 'runAsync' : 'run_async';
+ if (Runner.prototype[runAsyncName] && isWrapped(Runner.prototype[runAsyncName])) {
+ this._unwrap(Runner.prototype, runAsyncName);
+ }
+ const runLiveName = Runner.prototype.runLive ? 'runLive' : 'run_live';
+ if (Runner.prototype[runLiveName] && isWrapped(Runner.prototype[runLiveName])) {
+ this._unwrap(Runner.prototype, runLiveName);
+ }
+ }
+
+ const BaseAgent = moduleExports.BaseAgent;
+ if (BaseAgent?.prototype) {
+ const runAsyncName = BaseAgent.prototype.runAsync ? 'runAsync' : 'run_async';
+ if (BaseAgent.prototype[runAsyncName] && isWrapped(BaseAgent.prototype[runAsyncName])) {
+ this._unwrap(BaseAgent.prototype, runAsyncName);
+ }
+ }
+ } catch { /* ignore */ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/google-adk/utils.ts b/sdk/typescript/src/instrumentation/google-adk/utils.ts
new file mode 100644
index 00000000..523dff74
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/google-adk/utils.ts
@@ -0,0 +1,692 @@
+import {
+ trace,
+ Span,
+ SpanKind,
+ SpanStatusCode,
+} from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+import { AsyncLocalStorage } from 'async_hooks';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
+import { applyCustomSpanAttributes, getServerAddressForProvider } from '../../helpers';
+
+/**
+ * Prevents Runner.run_async from creating a second invoke_agent span
+ * when called internally by Runner.run (mirrors Python _ADK_WORKFLOW_ACTIVE).
+ */
+export const adkWorkflowActive = new AsyncLocalStorage<boolean>();
+
+export function isAdkWorkflowActive(): boolean {
+ return adkWorkflowActive.getStore() === true;
+}
+
+// ---------------------------------------------------------------------------
+// OTel GenAI operation mapping (mirrors Python OPERATION_MAP)
+// ---------------------------------------------------------------------------
+
+export const OPERATION_MAP: Record<string, string> = {
+ agent_init: SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ runner_run_async: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ runner_run: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ runner_run_live: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ agent_run_async: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+};
+
+const SPAN_KIND_MAP: Record<string, SpanKind> = {
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT]: SpanKind.CLIENT,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT]: SpanKind.CLIENT,
+};
+
+export function getOperationType(endpoint: string): string {
+ return OPERATION_MAP[endpoint] ?? SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT;
+}
+
+export function getSpanKind(operationType: string): SpanKind {
+ return SPAN_KIND_MAP[operationType] ?? SpanKind.INTERNAL;
+}
+
+// ---------------------------------------------------------------------------
+// Span name generation (mirrors Python generate_span_name)
+// ---------------------------------------------------------------------------
+
+export function generateSpanName(endpoint: string, instance: any): string {
+ if (endpoint === 'agent_init') {
+ const name = instance?.name ?? 'agent';
+ return `create_agent ${name}`;
+ }
+ if (endpoint === 'runner_run_async' || endpoint === 'runner_run' || endpoint === 'runner_run_live') {
+ const appName = instance?.app_name ?? instance?._app_name ?? 'google_adk';
+ return `invoke_agent ${appName}`;
+ }
+ if (endpoint === 'agent_run_async') {
+ const name = instance?.name ?? 'agent';
+ return `invoke_agent ${name}`;
+ }
+ return `${getOperationType(endpoint)} ${endpoint}`;
+}
+
+// ---------------------------------------------------------------------------
+// PassthroughTracer (mirrors Python _PassthroughTracer)
+// ---------------------------------------------------------------------------
+
+/**
+ * Drop-in replacement for ADK's tracer objects. Overrides
+ * `startActiveSpan` to yield the current span instead of creating a new one,
+ * letting OpenLIT own top-level spans while ADK's code still runs.
+ */
+export class PassthroughTracer {
+ private _wrapped: any;
+
+ constructor(wrapped: any) {
+ this._wrapped = wrapped;
+ }
+
+ startActiveSpan(...args: any[]): any {
+ const fn = args[args.length - 1];
+ if (typeof fn === 'function') {
+ const currentSpan = trace.getActiveSpan();
+ return fn(currentSpan);
+ }
+ return undefined;
+ }
+
+ startSpan(...args: any[]): any {
+ return this._wrapped.startSpan(...args);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Model extraction (mirrors Python _resolve_model_string / extract_model_name)
+// ---------------------------------------------------------------------------
+
+export function resolveModelString(modelObj: any): string | null {
+ if (typeof modelObj === 'string') return modelObj;
+ if (!modelObj) return null;
+ const modelName = modelObj.model_name ?? modelObj.modelName;
+ if (typeof modelName === 'string') return modelName;
+ const inner = modelObj.model;
+ if (typeof inner === 'string') return inner;
+ return null;
+}
+
+export function extractModelName(instance: any): string {
+ try {
+ const model = instance?.model;
+ if (model) {
+ const resolved = resolveModelString(model);
+ if (resolved) return resolved;
+ }
+ const rootAgent = instance?.agent;
+ if (rootAgent) return extractModelName(rootAgent);
+ } catch { /* ignore */ }
+ return 'unknown';
+}
+
+// ---------------------------------------------------------------------------
+// Server address resolution (mirrors Python resolve_server_info)
+// ---------------------------------------------------------------------------
+
+const PREFIX_TO_PROVIDER: Record<string, string> = {
+ anthropic: 'anthropic',
+ claude: 'anthropic',
+ openai: 'openai',
+ gpt: 'openai',
+ mistral: 'mistral_ai',
+ cohere: 'cohere',
+};
+
+function detectProviderFromModelStr(modelStr: string): [string, number, string] | null {
+ if (!modelStr) return null;
+ const lower = modelStr.toLowerCase();
+ const prefix = lower.includes('/') ? lower.split('/')[0] : lower.split('-')[0];
+ const providerKey = PREFIX_TO_PROVIDER[prefix];
+ if (!providerKey) return null;
+ const [addr, port] = getServerAddressForProvider(providerKey);
+ if (!addr) return null;
+ return [addr, port, providerKey];
+}
+
+export function resolveServerInfo(
+ instance?: any,
+ modelName?: string | null
+): [string, number, string] {
+ if (modelName) {
+ const detected = detectProviderFromModelStr(modelName);
+ if (detected) return detected;
+ }
+
+ if (instance) {
+ try {
+ let modelObj = instance.model;
+ if (!modelObj) {
+ const agent = instance.agent;
+ if (agent) modelObj = agent.model;
+ }
+ if (modelObj) {
+ const resolved = resolveModelString(modelObj);
+ if (resolved) {
+ const detected = detectProviderFromModelStr(resolved);
+ if (detected) return detected;
+ }
+ }
+ } catch { /* ignore */ }
+ }
+
+ const useVertex = (process.env.GOOGLE_GENAI_USE_VERTEXAI || '').toLowerCase();
+ if (useVertex === 'true' || useVertex === '1') {
+ const [addr, port] = getServerAddressForProvider('gcp.vertex_ai');
+ return [addr, port, 'gcp.vertex_ai'];
+ }
+ const [addr, port] = getServerAddressForProvider('gcp.gemini');
+ return [addr, port, 'gcp.gemini'];
+}
+
+// ---------------------------------------------------------------------------
+// Common span attributes (mirrors Python common_framework_span_attributes)
+// ---------------------------------------------------------------------------
+
+export function setCommonSpanAttributes(
+ span: Span,
+ operationType: string,
+): void {
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment || 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName || 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operationType);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK);
+}
+
+// ---------------------------------------------------------------------------
+// Content extraction helpers (mirrors Python _extract_parts)
+// ---------------------------------------------------------------------------
+
+function truncateContent(str: string, maxLen?: number | null): string {
+ const limit = maxLen ?? OpenlitConfig.maxContentLength;
+ if (limit && str.length > limit) return str.slice(0, limit) + '...';
+ return str;
+}
+
+interface ExtractedParts {
+ textParts: string[];
+ toolCalls: { name: string; id: string; arguments?: string }[];
+ toolResponses: { name: string; id: string; content?: string }[];
+}
+
+function extractParts(parts: any[] | null | undefined): ExtractedParts {
+ const textParts: string[] = [];
+ const toolCalls: { name: string; id: string; arguments?: string }[] = [];
+ const toolResponses: { name: string; id: string; content?: string }[] = [];
+
+ for (const part of parts || []) {
+ const text = part?.text;
+ if (text) textParts.push(truncateContent(String(text)));
+
+ const fc = part?.function_call ?? part?.functionCall;
+ if (fc) {
+ const entry: { name: string; id: string; arguments?: string } = {
+ name: fc.name ?? '',
+ id: fc.id ?? '',
+ };
+ const fcArgs = fc.args;
+ if (fcArgs) {
+ try {
+ entry.arguments = typeof fcArgs === 'object' ? JSON.stringify(fcArgs) : String(fcArgs);
+ } catch { entry.arguments = String(fcArgs); }
+ }
+ toolCalls.push(entry);
+ }
+
+ const fr = part?.function_response ?? part?.functionResponse;
+ if (fr) {
+ const respEntry: { name: string; id: string; content?: string } = {
+ name: fr.name ?? '',
+ id: fr.id ?? '',
+ };
+ const frResp = fr.response;
+ if (frResp != null) {
+ try {
+ respEntry.content = typeof frResp === 'object' ? JSON.stringify(frResp) : String(frResp);
+ } catch { respEntry.content = String(frResp); }
+ }
+ toolResponses.push(respEntry);
+ }
+ }
+
+ return { textParts, toolCalls, toolResponses };
+}
+
+// ---------------------------------------------------------------------------
+// Input/Output message capture (mirrors Python capture_input_messages / capture_output_messages)
+// ---------------------------------------------------------------------------
+
+export function captureInputMessages(span: Span, llmRequest: any, captureContent: boolean): void {
+ if (!captureContent) return;
+ try {
+ const contents = llmRequest?.contents;
+ if (!contents) return;
+ const messages: any[] = [];
+ for (const content of (contents as any[]).slice(0, 20)) {
+ const role = content?.role ?? 'user';
+ const rawParts = content?.parts ?? [];
+ const { textParts, toolCalls, toolResponses } = extractParts(rawParts);
+
+ const parts: any[] = [];
+ for (const text of textParts) parts.push({ type: 'text', content: text });
+ for (const tc of toolCalls) {
+ parts.push({ type: 'tool_call', id: tc.id, name: tc.name, arguments: tc.arguments ?? '' });
+ }
+ for (const tr of toolResponses) {
+ parts.push({ type: 'tool_call_response', id: tr.id, response: tr.content ?? '' });
+ }
+ if (parts.length > 0) messages.push({ role: String(role), parts });
+ }
+ if (messages.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(messages));
+ }
+ } catch { /* ignore */ }
+}
+
+export function captureOutputMessages(
+ span: Span,
+ llmResponse: any,
+ captureContent: boolean,
+ finishReason = 'stop',
+): void {
+ if (!captureContent) return;
+ try {
+ const content = llmResponse?.content;
+ if (!content) return;
+ const rawParts = content.parts ?? [];
+ const { textParts, toolCalls } = extractParts(rawParts);
+
+ const parts: any[] = [];
+ for (const text of textParts) parts.push({ type: 'text', content: text });
+ for (const tc of toolCalls) {
+ parts.push({ type: 'tool_call', id: tc.id, name: tc.name, arguments: tc.arguments ?? '' });
+ }
+ if (parts.length > 0) {
+ const messages = [{ role: 'assistant', parts, finish_reason: finishReason }];
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, JSON.stringify(messages));
+ }
+ } catch { /* ignore */ }
+}
+
+export function captureEventOutput(span: Span, event: any, captureContent: boolean): void {
+ if (!captureContent) return;
+ try {
+ const content = event?.content;
+ if (!content) return;
+ const rawParts = content.parts ?? [];
+ const { textParts, toolCalls } = extractParts(rawParts);
+
+ const parts: any[] = [];
+ for (const text of textParts) parts.push({ type: 'text', content: text });
+ for (const tc of toolCalls) {
+ parts.push({ type: 'tool_call', id: tc.id, name: tc.name, arguments: tc.arguments ?? '' });
+ }
+ if (parts.length > 0) {
+ const messages = [{ role: 'assistant', parts, finish_reason: 'stop' }];
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, JSON.stringify(messages));
+ }
+ } catch { /* ignore */ }
+}
+
+// ---------------------------------------------------------------------------
+// Token extraction (mirrors Python extract_token_usage)
+// ---------------------------------------------------------------------------
+
+export interface TokenUsage {
+ inputTokens?: number;
+ outputTokens?: number;
+ reasoningTokens?: number;
+ cachedTokens?: number;
+ totalTokens?: number;
+}
+
+export function extractTokenUsage(llmResponse: any): TokenUsage {
+ try {
+ const usage = llmResponse?.usage_metadata ?? llmResponse?.usageMetadata;
+ if (!usage) return {};
+ return {
+ inputTokens: usage.prompt_token_count ?? usage.promptTokenCount,
+ outputTokens: usage.candidates_token_count ?? usage.candidatesTokenCount,
+ reasoningTokens: usage.thoughts_token_count ?? usage.thoughtsTokenCount,
+ cachedTokens: usage.cached_content_token_count ?? usage.cachedContentTokenCount,
+ totalTokens: usage.total_token_count ?? usage.totalTokenCount,
+ };
+ } catch { return {}; }
+}
+
+// ---------------------------------------------------------------------------
+// Output type detection (mirrors Python _determine_output_type)
+// ---------------------------------------------------------------------------
+
+function determineOutputType(llmResponse: any): string {
+ try {
+ const content = llmResponse?.content;
+ if (content) {
+ for (const part of (content.parts ?? [])) {
+ if (part?.function_call || part?.functionCall) return 'tool_calls';
+ }
+ }
+ } catch { /* ignore */ }
+ return 'text';
+}
+
+// ---------------------------------------------------------------------------
+// LLM span enrichment (mirrors Python enrich_llm_span)
+// ---------------------------------------------------------------------------
+
+export function enrichLlmSpan(
+ span: Span,
+ llmRequest: any,
+ llmResponse: any,
+ captureMessageContent: boolean,
+): void {
+ try {
+ const requestModel = llmRequest?.model;
+ const modelStr = requestModel ? String(requestModel) : null;
+ const [serverAddress, serverPort, providerName] = resolveServerInfo(undefined, modelStr);
+
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, providerName);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, serverAddress);
+ span.setAttribute(SemanticConvention.SERVER_PORT, serverPort);
+
+ if (llmRequest) {
+ if (modelStr) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelStr);
+
+ const config = llmRequest.config;
+ if (config) {
+ const temp = config.temperature;
+ if (temp != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, Number(temp));
+ const topP = config.top_p ?? config.topP;
+ if (topP != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, Number(topP));
+ const maxTokens = config.max_output_tokens ?? config.maxOutputTokens;
+ if (maxTokens != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, Number(maxTokens));
+ }
+
+ if (captureMessageContent) {
+ const sysInstr = config?.system_instruction ?? config?.systemInstruction;
+ if (sysInstr) {
+ const instrText = typeof sysInstr === 'string' ? sysInstr : String(sysInstr);
+ span.setAttribute(
+ SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS,
+ JSON.stringify([{ type: 'text', content: truncateContent(instrText) }])
+ );
+ }
+ }
+ captureInputMessages(span, llmRequest, captureMessageContent);
+ }
+
+ if (llmResponse) {
+ const { inputTokens, outputTokens, reasoningTokens, cachedTokens, totalTokens } = extractTokenUsage(llmResponse);
+ if (inputTokens != null) span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ if (outputTokens != null) span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ if (reasoningTokens != null) span.setAttribute(SemanticConvention.GEN_AI_USAGE_COMPLETION_TOKENS_DETAILS_REASONING, reasoningTokens);
+ if (cachedTokens != null) span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cachedTokens);
+ if (totalTokens != null) span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
+
+ const responseModel = llmResponse.model_version ?? llmResponse.modelVersion;
+ if (responseModel) span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(responseModel));
+
+ let frStr = 'stop';
+ const finishReason = llmResponse.finish_reason ?? llmResponse.finishReason;
+ if (finishReason) {
+ try {
+ frStr = (typeof finishReason === 'object' && finishReason.value)
+ ? String(finishReason.value).toLowerCase()
+ : String(finishReason).toLowerCase();
+ } catch { frStr = String(finishReason).toLowerCase(); }
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [frStr]);
+ }
+
+ const responseId = llmResponse.response_id ?? llmResponse.responseId ?? llmResponse.id;
+ if (responseId) span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, String(responseId));
+
+ const errorCode = llmResponse.error_code ?? llmResponse.errorCode;
+ if (errorCode) {
+ span.setAttribute(SemanticConvention.ERROR_TYPE, String(errorCode));
+ const errorMessage = llmResponse.error_message ?? llmResponse.errorMessage;
+ if (errorMessage) span.setStatus({ code: SpanStatusCode.ERROR, message: String(errorMessage) });
+ }
+
+ captureOutputMessages(span, llmResponse, captureMessageContent, frStr);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, determineOutputType(llmResponse));
+ }
+ } catch { /* ignore */ }
+}
+
+// ---------------------------------------------------------------------------
+// ADK Event extraction (mirrors Python _extract_from_event / _is_adk_event)
+// ---------------------------------------------------------------------------
+
+function isAdkEvent(obj: any): boolean {
+ if (!obj) return false;
+ return (obj.constructor?.name === 'Event') && ('content' in obj);
+}
+
+function extractFromEvent(eventObj: any): [any | null, string | null] {
+ try {
+ const content = eventObj?.content;
+ if (!content) return [null, null];
+ const parts = content.parts;
+ if (!parts || parts.length === 0) return [null, null];
+ const fnResp = parts[0]?.function_response ?? parts[0]?.functionResponse;
+ if (!fnResp) return [null, null];
+ return [fnResp.response ?? null, fnResp.id ?? null];
+ } catch { return [null, null]; }
+}
+
+// ---------------------------------------------------------------------------
+// Tool type mapping (mirrors Python _otel_gen_ai_tool_type)
+// ---------------------------------------------------------------------------
+
+function otelToolType(tool: any): string {
+ const name = tool?.constructor?.name ?? '';
+ if (name.includes('Function')) return 'function';
+ if (name.includes('Agent')) return 'extension';
+ return 'function';
+}
+
+// ---------------------------------------------------------------------------
+// Tool span enrichment (mirrors Python enrich_tool_span)
+// ---------------------------------------------------------------------------
+
+export function enrichToolSpan(
+ span: Span,
+ tool: any,
+ functionArgs: any,
+ functionResponseEvent: any,
+ captureMessageContent: boolean,
+ error?: any,
+): void {
+ try {
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK);
+
+ if (tool) {
+ const toolName = tool.name ?? tool.constructor?.name ?? 'unknown';
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, String(toolName));
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, otelToolType(tool));
+ const toolDesc = tool.description;
+ if (toolDesc) span.setAttribute(SemanticConvention.GEN_AI_TOOL_DESCRIPTION, truncateContent(String(toolDesc)));
+ }
+
+ let responseDict: any = null;
+ let toolCallId: string | null = null;
+ if (isAdkEvent(functionResponseEvent)) {
+ [responseDict, toolCallId] = extractFromEvent(functionResponseEvent);
+ } else if (typeof functionResponseEvent === 'object' && functionResponseEvent !== null) {
+ responseDict = functionResponseEvent;
+ toolCallId = functionResponseEvent.id ?? null;
+ }
+
+ if (captureMessageContent) {
+ if (functionArgs != null) {
+ try {
+ const argsStr = typeof functionArgs === 'object' ? JSON.stringify(functionArgs) : String(functionArgs);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, truncateContent(argsStr));
+ } catch { span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, truncateContent(String(functionArgs))); }
+ }
+ if (responseDict != null) {
+ try {
+ const resultStr = typeof responseDict === 'object' ? JSON.stringify(responseDict) : String(responseDict);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, truncateContent(resultStr));
+ } catch { span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, truncateContent(String(responseDict))); }
+ }
+ }
+
+ if (toolCallId) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, String(toolCallId));
+
+ if (error != null) {
+ const errorType = error.constructor?.name || '_OTHER';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
+ }
+ } catch { /* ignore */ }
+}
+
+// ---------------------------------------------------------------------------
+// Merged tool span enrichment (mirrors Python enrich_merged_tool_span)
+// ---------------------------------------------------------------------------
+
+export function enrichMergedToolSpan(
+ span: Span,
+ responseEventId: any,
+ functionResponseEvent: any,
+ captureMessageContent: boolean,
+): void {
+ try {
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, '(merged tools)');
+
+ if (responseEventId) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, String(responseEventId));
+
+ if (captureMessageContent && functionResponseEvent != null) {
+ try {
+ const content = functionResponseEvent.content;
+ if (content) {
+ const parts = content.parts ?? [];
+ const toolResults: any[] = [];
+ for (const part of parts) {
+ const fnResp = part?.function_response ?? part?.functionResponse;
+ if (fnResp) {
+ const entry: any = {};
+ const name = fnResp.name;
+ if (name) entry.name = String(name);
+ const resp = fnResp.response;
+ if (resp != null) entry.response = resp;
+ if (Object.keys(entry).length > 0) toolResults.push(entry);
+ }
+ }
+ if (toolResults.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, truncateContent(JSON.stringify(toolResults)));
+ }
+ }
+ } catch { /* ignore */ }
+ }
+ } catch { /* ignore */ }
+}
+
+// ---------------------------------------------------------------------------
+// Runner/Agent attribute setters (mirrors Python _set_runner_agent_attributes / _set_agent_attributes)
+// ---------------------------------------------------------------------------
+
+export function setRunnerAgentAttributes(span: Span, instance: any, endpoint: string): void {
+ try {
+ const appName = instance?.app_name ?? instance?._app_name ?? 'google_adk';
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(appName));
+
+ if (endpoint === 'runner_run_live') {
+ span.setAttribute(SemanticConvention.GEN_AI_EXECUTION_MODE, 'live');
+ } else if (endpoint === 'runner_run') {
+ span.setAttribute(SemanticConvention.GEN_AI_EXECUTION_MODE, 'sync');
+ } else {
+ span.setAttribute(SemanticConvention.GEN_AI_EXECUTION_MODE, 'async');
+ }
+ } catch { /* ignore */ }
+}
+
+export function setAgentAttributes(span: Span, instance: any): void {
+ try {
+ const name = instance?.name;
+ if (name) span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ const description = instance?.description;
+ if (description) span.setAttribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, String(description));
+ } catch { /* ignore */ }
+}
+
+// ---------------------------------------------------------------------------
+// Response processing for Runner/Agent spans (mirrors Python process_google_adk_response)
+// ---------------------------------------------------------------------------
+
+export function processGoogleAdkResponse(
+ span: Span,
+ endpoint: string,
+ instance: any,
+ startTime: number,
+ _captureMessageContent: boolean,
+): void {
+ const endTime = Date.now();
+ const operationType = getOperationType(endpoint);
+ const [serverAddress, serverPort] = resolveServerInfo(instance);
+ const requestModel = extractModelName(instance);
+
+ setCommonSpanAttributes(span, operationType);
+
+ if (requestModel && requestModel !== 'unknown') {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, requestModel);
+ }
+ if (serverAddress) span.setAttribute(SemanticConvention.SERVER_ADDRESS, serverAddress);
+ if (serverPort) span.setAttribute(SemanticConvention.SERVER_PORT, serverPort);
+
+ if (endpoint === 'runner_run_async' || endpoint === 'runner_run' || endpoint === 'runner_run_live') {
+ setRunnerAgentAttributes(span, instance, endpoint);
+ } else if (endpoint === 'agent_run_async') {
+ setAgentAttributes(span, instance);
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (endTime - startTime) / 1000);
+ applyCustomSpanAttributes(span);
+ span.setStatus({ code: SpanStatusCode.OK });
+}
+
+// ---------------------------------------------------------------------------
+// Metrics recording (mirrors Python record_google_adk_metrics)
+// ---------------------------------------------------------------------------
+
+export function recordGoogleAdkMetrics(
+ operationType: string,
+ duration: number,
+ requestModel: string,
+ serverAddress: string,
+ serverPort: number,
+): void {
+ try {
+ const Metrics = require('../../otel/metrics').default;
+ const attributes: Record<string, any> = {
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
+ [ATTR_SERVICE_NAME]: OpenlitConfig.applicationName || 'default',
+ [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: OpenlitConfig.environment || 'default',
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK,
+ };
+ if (requestModel && requestModel !== 'unknown') {
+ attributes[SemanticConvention.GEN_AI_REQUEST_MODEL] = requestModel;
+ }
+ if (serverAddress) attributes[SemanticConvention.SERVER_ADDRESS] = serverAddress;
+ if (serverPort) attributes[SemanticConvention.SERVER_PORT] = serverPort;
+
+ if (Metrics.genaiClientOperationDuration) {
+ Metrics.genaiClientOperationDuration.record(duration, attributes);
+ }
+ } catch { /* ignore */ }
+}
diff --git a/sdk/typescript/src/instrumentation/google-adk/wrapper.ts b/sdk/typescript/src/instrumentation/google-adk/wrapper.ts
new file mode 100644
index 00000000..8210e45d
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/google-adk/wrapper.ts
@@ -0,0 +1,430 @@
+import {
+ Tracer,
+ SpanKind,
+ SpanContext,
+ context,
+ trace,
+ Link,
+ SpanStatusCode,
+} from '@opentelemetry/api';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, {
+ applyCustomSpanAttributes,
+ setFrameworkLlmActive,
+ resetFrameworkLlmActive,
+ setFrameworkParentContext,
+ clearFrameworkParentContext,
+} from '../../helpers';
+import {
+ adkWorkflowActive,
+ isAdkWorkflowActive,
+ getOperationType,
+ getSpanKind,
+ generateSpanName,
+ resolveModelString,
+ processGoogleAdkResponse,
+ captureEventOutput,
+} from './utils';
+
+// ---------------------------------------------------------------------------
+// Agent Creation Registry (mirrors Python _AgentCreationRegistry)
+// ---------------------------------------------------------------------------
+
+export class AgentCreationRegistry {
+ private _contexts = new Map<string, SpanContext>();
+
+ register(agentName: string, spanContext: SpanContext): void {
+ this._contexts.set(agentName, spanContext);
+ }
+
+ get(agentName: string): SpanContext | undefined {
+ return this._contexts.get(agentName);
+ }
+
+ getAll(): SpanContext[] {
+ return Array.from(this._contexts.values());
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Agent init wrapper (mirrors Python _wrap_agent_init)
+// ---------------------------------------------------------------------------
+
+function truncateContent(str: string, maxLen?: number | null): string {
+ const limit = maxLen ?? OpenlitConfig.maxContentLength;
+ if (limit && str.length > limit) return str.slice(0, limit) + '...';
+ return str;
+}
+
+export function wrapAgentInit(tracer: Tracer, registry: AgentCreationRegistry) {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const result = originalMethod.apply(this, args);
+
+ try {
+ const name = this.name ?? 'agent';
+ const spanName = `create_agent ${name}`;
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK,
+ },
+ });
+
+ context.with(trace.setSpan(context.active(), span), () => {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+
+ const description = this.description;
+ if (description) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, String(description));
+ }
+
+ const model = this.model;
+ if (model) {
+ const modelStr = resolveModelString(model) ?? String(model);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelStr);
+ }
+
+ const instruction = this.instruction;
+ if (instruction && captureContent) {
+ const instrStr = String(instruction);
+ span.setAttribute(
+ SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS,
+ JSON.stringify([{ type: 'text', content: truncateContent(instrStr) }])
+ );
+ }
+
+ const tools = this.tools;
+ if (tools && Array.isArray(tools)) {
+ const toolDefs: any[] = [];
+ for (const t of tools.slice(0, 20)) {
+ const tName = t?.name ?? t?.constructor?.name ?? 'unknown';
+ const entry: any = { type: 'function', name: String(tName) };
+ const tDesc = t?.description;
+ if (tDesc) entry.description = truncateContent(String(tDesc));
+ toolDefs.push(entry);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_DEFINITIONS, JSON.stringify(toolDefs));
+ }
+
+ const subAgents = this.sub_agents ?? this.subAgents;
+ if (subAgents && Array.isArray(subAgents)) {
+ const handoffNames = subAgents.slice(0, 20).map(
+ (sa: any) => String(sa?.name ?? 'unknown')
+ );
+ span.setAttribute('gen_ai.agent.handoffs', JSON.stringify(handoffNames));
+ }
+
+ span.setStatus({ code: SpanStatusCode.OK });
+ applyCustomSpanAttributes(span);
+
+ const creationCtx = span.spanContext();
+ this._openlit_creation_context = creationCtx;
+ registry.register(String(name), creationCtx);
+
+ span.end();
+ });
+ } catch (e: any) {
+ // Silently ignore instrumentation errors
+ }
+
+ return result;
+ };
+ };
+}
+
+// ---------------------------------------------------------------------------
+// Runner.run wrapper — sync (mirrors Python sync_runner_wrap)
+// ---------------------------------------------------------------------------
+
+export function wrapRunnerRun(
+ tracer: Tracer,
+ endpoint: string,
+ registry: AgentCreationRegistry,
+) {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const operationType = getOperationType(endpoint);
+ const spanKind = getSpanKind(operationType);
+ const spanName = generateSpanName(endpoint, this);
+
+ const links: Link[] = [];
+ const allContexts = registry.getAll();
+ for (const ctx of allContexts) links.push({ context: ctx, attributes: {} });
+
+ const span = tracer.startSpan(spanName, {
+ kind: spanKind,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+
+ const kwargs = args[args.length - 1];
+ const sessionId = typeof kwargs === 'object' ? (kwargs?.session_id ?? kwargs?.sessionId) : undefined;
+ if (sessionId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sessionId));
+
+ setFrameworkLlmActive();
+ setFrameworkParentContext(context.active());
+
+ return adkWorkflowActive.run(true, () => {
+ try {
+ const response = originalMethod.apply(this, args);
+
+ if (response && typeof response.then === 'function') {
+ return response
+ .then((res: any) => {
+ processGoogleAdkResponse(span, endpoint, this, startTime, captureContent);
+ span.end();
+ return res;
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ })
+ .finally(() => {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ });
+ }
+
+ processGoogleAdkResponse(span, endpoint, this, startTime, captureContent);
+ span.end();
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ throw e;
+ }
+ });
+ });
+ };
+ };
+}
+
+// ---------------------------------------------------------------------------
+// Runner.run_async wrapper — async generator (mirrors Python async_runner_wrap)
+// ---------------------------------------------------------------------------
+
+export function wrapRunnerRunAsync(
+ tracer: Tracer,
+ endpoint: string,
+ registry: AgentCreationRegistry,
+) {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isAdkWorkflowActive()) return originalMethod.apply(this, args);
+
+ const operationType = getOperationType(endpoint);
+ const spanKind = getSpanKind(operationType);
+ const spanName = generateSpanName(endpoint, this);
+
+ const links: Link[] = [];
+ const allContexts = registry.getAll();
+ for (const ctx of allContexts) links.push({ context: ctx, attributes: {} });
+
+ const span = tracer.startSpan(spanName, {
+ kind: spanKind,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK,
+ },
+ });
+
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- preserve `this` for originalMethod.apply
+ const self = this;
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+ const startTime = Date.now();
+
+ const kwargs = args[args.length - 1];
+ const sessionId = typeof kwargs === 'object' ? (kwargs?.session_id ?? kwargs?.sessionId) : undefined;
+ if (sessionId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sessionId));
+
+ const generator = originalMethod.apply(self, args);
+
+ if (generator && typeof generator[Symbol.asyncIterator] === 'function') {
+ return wrapAsyncGenerator(generator, span, self, endpoint, startTime, captureContent);
+ }
+
+ if (generator && typeof generator.then === 'function') {
+ return context.with(trace.setSpan(context.active(), span), () => {
+ setFrameworkLlmActive();
+ setFrameworkParentContext(context.active());
+ return generator
+ .then((res: any) => {
+ processGoogleAdkResponse(span, endpoint, self, startTime, captureContent);
+ span.end();
+ return res;
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ })
+ .finally(() => {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ });
+ });
+ }
+
+ processGoogleAdkResponse(span, endpoint, self, startTime, captureContent);
+ span.end();
+ return generator;
+ };
+ };
+}
+
+function wrapAsyncGenerator(
+ generator: AsyncIterable<any>,
+ span: any,
+ instance: any,
+ endpoint: string,
+ startTime: number,
+ captureContent: boolean,
+): AsyncIterable<any> {
+ const originalIterator = generator[Symbol.asyncIterator].bind(generator);
+ return {
+ [Symbol.asyncIterator]() {
+ const iter = originalIterator();
+ return {
+ async next() {
+ return context.with(trace.setSpan(context.active(), span), async () => {
+ setFrameworkLlmActive();
+ setFrameworkParentContext(context.active());
+ try {
+ const result = await iter.next();
+ if (result.done) {
+ processGoogleAdkResponse(span, endpoint, instance, startTime, captureContent);
+ span.end();
+ return result;
+ }
+ const event = result.value;
+ if (event && typeof event.is_final_response === 'function' && event.is_final_response()) {
+ captureEventOutput(span, event, captureContent);
+ }
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ } finally {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ }
+ });
+ },
+ async return(value?: any) {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ processGoogleAdkResponse(span, endpoint, instance, startTime, captureContent);
+ span.end();
+ return iter.return ? iter.return(value) : { done: true as const, value };
+ },
+ async throw(e?: any) {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ return iter.throw ? iter.throw(e) : { done: true as const, value: undefined };
+ },
+ };
+ },
+ } as AsyncIterable<any>;
+}
+
+// ---------------------------------------------------------------------------
+// BaseAgent.run_async wrapper — async generator (mirrors Python async_agent_wrap)
+// ---------------------------------------------------------------------------
+
+export function wrapAgentRunAsync(
+ tracer: Tracer,
+ endpoint: string,
+ registry: AgentCreationRegistry,
+) {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const operationType = getOperationType(endpoint);
+ const spanKind = getSpanKind(operationType);
+ const spanName = generateSpanName(endpoint, this);
+
+ const links: Link[] = [];
+ const agentName = this.name;
+ if (agentName) {
+ const creationCtx = registry.get(String(agentName));
+ if (creationCtx) links.push({ context: creationCtx, attributes: {} });
+ }
+
+ const span = tracer.startSpan(spanName, {
+ kind: spanKind,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_GOOGLE_ADK,
+ },
+ });
+
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- preserve `this` for originalMethod.apply
+ const self = this;
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+ const startTime = Date.now();
+
+ // Extract session_id from ctx argument (first arg)
+ const ctx = args[0];
+ if (ctx) {
+ const session = ctx.session;
+ if (session) {
+ const sid = session.id;
+ if (sid) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, String(sid));
+ }
+ }
+
+ const generator = originalMethod.apply(self, args);
+
+ if (generator && typeof generator[Symbol.asyncIterator] === 'function') {
+ return wrapAsyncGenerator(generator, span, self, endpoint, startTime, captureContent);
+ }
+
+ if (generator && typeof generator.then === 'function') {
+ return context.with(trace.setSpan(context.active(), span), () => {
+ setFrameworkLlmActive();
+ setFrameworkParentContext(context.active());
+ return generator
+ .then((res: any) => {
+ processGoogleAdkResponse(span, endpoint, self, startTime, captureContent);
+ span.end();
+ return res;
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ })
+ .finally(() => {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
+ });
+ });
+ }
+
+ processGoogleAdkResponse(span, endpoint, self, startTime, captureContent);
+ span.end();
+ return generator;
+ };
+ };
+}
diff --git a/sdk/typescript/src/instrumentation/google-ai/wrapper.ts b/sdk/typescript/src/instrumentation/google-ai/wrapper.ts
index 0dbcd46a..e83c3c6f 100644
--- a/sdk/typescript/src/instrumentation/google-ai/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/google-ai/wrapper.ts
@@ -1,39 +1,68 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: GoogleAIWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: GoogleAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: GoogleAIWrapper.serverPort,
+ };
+}
+
class GoogleAIWrapper extends BaseWrapper {
- static aiSystem = 'google_ai_studio';
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_GOOGLE_AI_STUDIO;
static serverAddress = 'generativelanguage.googleapis.com';
static serverPort = 443;
-
+
static _patchGenerateContent(tracer: Tracer): any {
const genAIEndpoint = 'google.generativeai.models.generate_content';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const rawModel = this?.model || 'gemini-2.0-flash';
+ const requestModel = rawModel.replace(/^models\//, '');
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
- // generateContentStream returns { stream, response } — stream is on .stream
if (response && response.stream && typeof response.stream[Symbol.asyncIterator] === 'function') {
const wrappedStream = GoogleAIWrapper._generateContentStreamGenerator({
args,
genAIEndpoint,
response: response.stream,
span,
+ requestModel,
});
return { ...response, stream: wrappedStream };
}
- return GoogleAIWrapper._generateContent({ args, genAIEndpoint, response, span });
+ return GoogleAIWrapper._generateContent({ args, genAIEndpoint, response, span, requestModel });
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: GoogleAIWrapper.aiSystem,
+ serverAddress: GoogleAIWrapper.serverAddress,
+ serverPort: GoogleAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -46,11 +75,13 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint,
response,
span,
+ requestModel,
}: {
args: any[];
genAIEndpoint: string;
response: any;
span: Span;
+ requestModel: string;
}): Promise<any> {
let metricParams;
try {
@@ -59,6 +90,7 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint,
result: response,
span,
+ requestModel,
});
return response;
} catch (e: any) {
@@ -77,35 +109,43 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint,
response,
span,
+ requestModel,
}: {
args: any[];
genAIEndpoint: string;
response: any;
span: Span;
+ requestModel: string;
}): AsyncGenerator<unknown, any, unknown> {
let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
-
+
try {
const result = {
model: '',
text: '',
+ responseId: '',
candidates: [] as any[],
usageMetadata: {
promptTokenCount: 0,
candidatesTokenCount: 0,
totalTokenCount: 0,
},
+ functionCall: null as any,
};
-
+
for await (const chunk of response) {
timestamps.push(Date.now());
-
+
if (chunk.modelVersion || chunk.model) {
result.model = chunk.modelVersion || chunk.model;
}
-
+
+ if (chunk.responseId) {
+ result.responseId = chunk.responseId;
+ }
+
const chunkText = typeof chunk.text === 'function' ? chunk.text() : chunk.text;
if (chunkText) {
result.text += chunkText;
@@ -119,13 +159,16 @@ class GoogleAIWrapper extends BaseWrapper {
safetyRatings: c.safetyRatings || [],
}));
}
-
+
chunk.candidates.forEach((c: any, idx: number) => {
if (c.content?.parts) {
c.content.parts.forEach((part: any) => {
if (part.text) {
result.candidates[idx].content.parts[0].text += part.text;
}
+ if (part.functionCall) {
+ result.functionCall = part.functionCall;
+ }
});
}
if (c.finishReason) {
@@ -145,7 +188,6 @@ class GoogleAIWrapper extends BaseWrapper {
yield chunk;
}
- // Calculate TTFT and TBT
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -158,6 +200,7 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint,
result,
span,
+ requestModel,
ttft,
tbt,
isStream: true,
@@ -180,6 +223,7 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint,
result,
span,
+ requestModel,
ttft = 0,
tbt = 0,
isStream = false,
@@ -188,13 +232,14 @@ class GoogleAIWrapper extends BaseWrapper {
genAIEndpoint: string;
result: any;
span: Span;
+ requestModel: string;
ttft?: number;
tbt?: number;
isStream?: boolean;
}) {
- const traceContent = OpenlitConfig.traceContent;
- // Non-streaming: result is GenerateContentResult = { response: GenerateContentResponse }
- // Streaming: result is our custom accumulated plain object
+ const captureContent = OpenlitConfig.captureMessageContent;
+ // Non-streaming: result = { response: GenerateContentResponse }
+ // Streaming: result = our accumulated plain object
const responseData = result.response || result;
const config = args[0]?.config || args[1] || {};
const {
@@ -203,67 +248,52 @@ class GoogleAIWrapper extends BaseWrapper {
topP,
topK,
stopSequences,
+ frequencyPenalty,
+ presencePenalty,
} = config;
- // Request Params attributes
- if (temperature !== undefined) {
+ // Request param attributes — only set when explicitly provided (matches Python)
+ if (temperature != null) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
}
- if (maxOutputTokens !== undefined) {
+ if (maxOutputTokens != null) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, maxOutputTokens);
}
- if (topP !== undefined) {
+ if (topP != null) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, topP);
}
- if (topK !== undefined) {
+ if (topK != null) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, topK);
}
if (stopSequences) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, stopSequences);
}
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStream);
-
- if (traceContent) {
- const contents = args[0]?.contents || args[0];
- let messages: any[] = [];
- if (typeof contents === 'string') {
- messages = [{ role: 'user', content: contents }];
- } else if (Array.isArray(contents)) {
- messages = contents.map((item: any) => ({
- role: item.role || 'user',
- content: Array.isArray(item.parts)
- ? item.parts.map((p: any) => p.text || '').join(' ')
- : (item.parts || ''),
- }));
- }
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages));
+ if (frequencyPenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequencyPenalty);
}
+ if (presencePenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presencePenalty);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStream);
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
-
- const model = responseData.modelVersion || responseData.model || args[0]?.model || 'gemini-pro';
- const responseModel = model;
+ const responseModel = responseData.modelVersion || responseData.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- // Calculate cost of the operation
const usageMetadata = responseData.usageMetadata;
- const promptTokens = usageMetadata?.promptTokenCount || 0;
- const completionTokens = usageMetadata?.candidatesTokenCount || 0;
+ const inputTokens = usageMetadata?.promptTokenCount || 0;
+ const outputTokens = usageMetadata?.candidatesTokenCount || 0;
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
- promptTokens,
- completionTokens
+ inputTokens,
+ outputTokens
);
GoogleAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user: undefined,
cost,
aiSystem: GoogleAIWrapper.aiSystem,
@@ -271,16 +301,11 @@ class GoogleAIWrapper extends BaseWrapper {
serverPort: GoogleAIWrapper.serverPort,
});
- // Response model
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- // Token usage
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, usageMetadata?.totalTokenCount || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, usageMetadata?.totalTokenCount || 0);
-
- // TTFT and TBT metrics
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -288,31 +313,118 @@ class GoogleAIWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
+ // Response ID
+ const responseId = responseData.responseId || '';
+ if (responseId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, responseId);
+ }
+
// Finish reason
- if (responseData.candidates && responseData.candidates[0]?.finishReason) {
- span.setAttribute(
- SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
- [responseData.candidates[0].finishReason]
- );
+ const finishReason = responseData.candidates?.[0]?.finishReason || '';
+ if (finishReason) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
}
// Output type
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
-
- // Content
- if (traceContent) {
- const completionContent = (typeof responseData.text === 'function' ? responseData.text() : responseData.text) ||
- (responseData.candidates?.[0]?.content?.parts?.[0]?.text) || '';
- const finishReason = responseData.candidates?.[0]?.finishReason || 'stop';
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(completionContent, finishReason)
+ const completionText = isStream
+ ? responseData.text
+ : (typeof responseData.text === 'function' ? responseData.text() : responseData.text);
+ const outputType = typeof completionText === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ // Function calls / tool calls (matches Python: tool name, call id, args)
+ const functionCall = isStream
+ ? responseData.functionCall
+ : responseData.candidates?.[0]?.content?.parts?.find((p: any) => p.functionCall)?.functionCall;
+ if (functionCall) {
+ if (functionCall.name) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, functionCall.name);
+ }
+ if (functionCall.args) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, JSON.stringify(functionCall.args));
+ }
+ }
+
+ // Reasoning tokens (Google: thoughts_token_count)
+ const reasoningTokens = usageMetadata?.thoughtsTokenCount || 0;
+ if (reasoningTokens > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_REASONING_TOKENS, reasoningTokens);
+ }
+
+ // Cache tokens (matches Python: cached_content_token_count, cache_creation_input_tokens)
+ const cacheReadTokens = usageMetadata?.cachedContentTokenCount || 0;
+ if (cacheReadTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cacheReadTokens);
+ }
+ const cacheCreationTokens = usageMetadata?.cacheCreationInputTokens || 0;
+ if (cacheCreationTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, cacheCreationTokens);
+ }
+
+ // Content attributes (gated by captureMessageContent)
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const contents = args[0]?.contents || args[0];
+ let messages: any[] = [];
+ if (typeof contents === 'string') {
+ messages = [{ role: 'user', content: contents }];
+ } else if (Array.isArray(contents)) {
+ messages = contents.map((item: any) => ({
+ role: item.role === 'model' ? 'assistant' : (item.role || 'user'),
+ content: Array.isArray(item.parts)
+ ? item.parts.map((p: any) => p.text || '').join(' ')
+ : (item.parts || ''),
+ }));
+ }
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+
+ const outputContent = completionText
+ || (responseData.candidates?.[0]?.content?.parts?.[0]?.text)
+ || '';
+ const toolCallsForOutput = functionCall ? [{
+ name: functionCall.name || '',
+ arguments: functionCall.args || {},
+ }] : undefined;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ outputContent,
+ finishReason || 'stop',
+ toolCallsForOutput
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
+
+ // Emit inference event (independent of captureMessageContent, per rule)
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: GoogleAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: GoogleAIWrapper.serverPort,
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (responseId) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID] = responseId;
+ }
+ if (finishReason) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = [finishReason];
+ }
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user: undefined,
cost,
aiSystem: GoogleAIWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/groq/wrapper.ts b/sdk/typescript/src/instrumentation/groq/wrapper.ts
index 7466a05a..0e478746 100644
--- a/sdk/typescript/src/instrumentation/groq/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/groq/wrapper.ts
@@ -1,21 +1,41 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: GroqWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: GroqWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: GroqWrapper.serverPort,
+ };
+}
+
class GroqWrapper extends BaseWrapper {
- static aiSystem = 'groq';
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_GROQ;
static serverAddress = 'api.groq.com';
static serverPort = 443;
-
+
static _patchChatCompletionCreate(tracer: Tracer): any {
const genAIEndpoint = 'groq.chat.completions';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'llama-3.1-8b-instant';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -37,6 +57,14 @@ class GroqWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: GroqWrapper.aiSystem,
+ serverAddress: GroqWrapper.serverAddress,
+ serverPort: GroqWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -69,7 +97,6 @@ class GroqWrapper extends BaseWrapper {
throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -90,7 +117,7 @@ class GroqWrapper extends BaseWrapper {
let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
-
+
try {
const { messages } = args[0];
let { tools } = args[0];
@@ -113,16 +140,16 @@ class GroqWrapper extends BaseWrapper {
total_tokens: 0,
},
};
-
- let toolCalls: any[] = [];
-
+
+ const toolCalls: any[] = [];
+
for await (const chunk of response) {
timestamps.push(Date.now());
-
+
result.id = chunk.id;
result.created = chunk.created;
result.model = chunk.model;
-
+
if (chunk.system_fingerprint) {
result.system_fingerprint = chunk.system_fingerprint;
}
@@ -137,14 +164,12 @@ class GroqWrapper extends BaseWrapper {
result.choices[0].message.content += chunk.choices[0].delta.content;
}
- // Handle tool calls for streaming
if (chunk.choices[0]?.delta.tool_calls) {
const deltaTools = chunk.choices[0].delta.tool_calls;
-
+
for (const tool of deltaTools) {
const idx = tool.index || 0;
-
- // Extend array if needed
+
while (toolCalls.length <= idx) {
toolCalls.push({
id: '',
@@ -152,9 +177,8 @@ class GroqWrapper extends BaseWrapper {
function: { name: '', arguments: '' }
});
}
-
+
if (tool.id) {
- // New tool call
toolCalls[idx].id = tool.id;
toolCalls[idx].type = tool.type || 'function';
if (tool.function?.name) {
@@ -164,17 +188,23 @@ class GroqWrapper extends BaseWrapper {
toolCalls[idx].function.arguments = tool.function.arguments;
}
} else if (tool.function?.arguments) {
- // Append arguments to existing tool call
toolCalls[idx].function.arguments += tool.function.arguments;
}
}
-
+
tools = true;
}
+ if (chunk.x_groq?.usage) {
+ const usage = chunk.x_groq.usage;
+ result.usage.prompt_tokens = usage.prompt_tokens || 0;
+ result.usage.completion_tokens = usage.completion_tokens || 0;
+ result.usage.total_tokens = usage.total_tokens || 0;
+ }
+
yield chunk;
}
-
+
if (toolCalls.length > 0) {
result.choices[0].message = {
...result.choices[0].message,
@@ -182,28 +212,27 @@ class GroqWrapper extends BaseWrapper {
} as any;
}
- // Estimate token usage if not provided
- let promptTokens = 0;
- for (const message of messages || []) {
- promptTokens += OpenLitHelper.openaiTokens(message.content as string, result.model) ?? 0;
- }
+ if (!result.usage.prompt_tokens && !result.usage.completion_tokens) {
+ let promptTokens = 0;
+ for (const message of messages || []) {
+ promptTokens += OpenLitHelper.openaiTokens(message.content as string, result.model) ?? 0;
+ }
- const completionTokens = OpenLitHelper.openaiTokens(
- result.choices[0].message.content ?? '',
- result.model
- );
-
- if (completionTokens) {
- result.usage = {
- prompt_tokens: promptTokens,
- completion_tokens: completionTokens,
- total_tokens: promptTokens + completionTokens,
- };
+ const completionTokens = OpenLitHelper.openaiTokens(
+ result.choices[0].message.content ?? '',
+ result.model
+ );
+ if (completionTokens) {
+ result.usage = {
+ prompt_tokens: promptTokens,
+ completion_tokens: completionTokens,
+ total_tokens: promptTokens + completionTokens,
+ };
+ }
}
args[0].tools = tools;
-
- // Calculate TTFT and TBT
+
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -226,7 +255,6 @@ class GroqWrapper extends BaseWrapper {
throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -248,11 +276,13 @@ class GroqWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'llama-3.1-8b-instant';
const {
messages,
frequency_penalty = 0,
max_tokens = null,
+ n = 1,
presence_penalty = 0,
seed = null,
stop = null,
@@ -260,43 +290,43 @@ class GroqWrapper extends BaseWrapper {
top_p,
user,
stream = false,
+ tools: _tools,
} = args[0];
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens || -1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, seed ? String(seed) : '');
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
if (stop) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(stop) ? stop : [stop]);
}
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
}
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
}
- // Request Params attributes : End
-
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- const model = result.model || 'llama-3.1-8b-instant';
- const responseModel = result.model || model;
+ const responseModel = result.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- // Calculate cost of the operation
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
result.usage.prompt_tokens,
result.usage.completion_tokens
@@ -304,7 +334,7 @@ class GroqWrapper extends BaseWrapper {
GroqWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: GroqWrapper.aiSystem,
@@ -312,24 +342,17 @@ class GroqWrapper extends BaseWrapper {
serverPort: GroqWrapper.serverPort,
});
- // Response model
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
-
- // Groq-specific attributes
+
if (result.system_fingerprint) {
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT, result.system_fingerprint);
}
- // Token usage
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, result.usage.prompt_tokens);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
- result.usage.completion_tokens
- );
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, result.usage.total_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.usage.total_tokens);
-
- // TTFT and TBT metrics
+ const inputTokens = result.usage.prompt_tokens;
+ const outputTokens = result.usage.completion_tokens;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -337,28 +360,24 @@ class GroqWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Finish reason
if (result.choices[0].finish_reason) {
span.setAttribute(
SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[result.choices[0].finish_reason]
);
}
-
- // Output type
- const outputType = typeof result.choices[0].message.content === 'string'
- ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+
+ const outputType = typeof result.choices[0].message.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
: SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
- // Tool calls handling
if (result.choices[0].message.tool_calls) {
const toolCalls = result.choices[0].message.tool_calls;
const toolNames = toolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
const toolArgs = toolCalls.map((t: any) => t.function?.arguments || '').filter(Boolean);
- const toolTypes = toolCalls.map((t: any) => t.type || '').filter(Boolean);
-
+
if (toolNames.length > 0) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
}
@@ -366,28 +385,46 @@ class GroqWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
}
if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- }
- if (toolTypes.length > 0) {
- const toolTypesStr = toolTypes.join(', ');
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolTypesStr);
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, toolTypesStr);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
}
- // Content
- if (traceContent) {
- const completionContent = result.choices[0].message.content || '';
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
const toolCalls = result.choices[0].message.tool_calls;
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(completionContent, result.choices[0].finish_reason || 'stop', toolCalls)
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.choices[0].message.content || '',
+ result.choices[0].finish_reason || 'stop',
+ toolCalls
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: GroqWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: GroqWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.choices[0].finish_reason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: GroqWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/huggingface/wrapper.ts b/sdk/typescript/src/instrumentation/huggingface/wrapper.ts
index 3c252848..8effed9b 100644
--- a/sdk/typescript/src/instrumentation/huggingface/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/huggingface/wrapper.ts
@@ -1,9 +1,22 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: HuggingFaceWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: HuggingFaceWrapper.serverPort,
+ };
+}
+
class HuggingFaceWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE;
static serverAddress = 'api-inference.huggingface.co';
@@ -13,9 +26,16 @@ class HuggingFaceWrapper extends BaseWrapper {
const genAIEndpoint = 'huggingface.chat.completions';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'mistralai/Mistral-7B-Instruct-v0.1';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -30,6 +50,14 @@ class HuggingFaceWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: HuggingFaceWrapper.aiSystem,
+ serverAddress: HuggingFaceWrapper.serverAddress,
+ serverPort: HuggingFaceWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -85,8 +113,9 @@ class HuggingFaceWrapper extends BaseWrapper {
try {
const { messages } = args[0] || {};
+ let { tools } = args[0] || {};
const result = {
- id: '0',
+ id: '',
created: -1,
model: args[0]?.model || '',
choices: [
@@ -99,6 +128,8 @@ class HuggingFaceWrapper extends BaseWrapper {
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
};
+ const toolCalls: any[] = [];
+
for await (const chunk of response) {
timestamps.push(Date.now());
if (chunk.id) result.id = chunk.id;
@@ -110,9 +141,44 @@ class HuggingFaceWrapper extends BaseWrapper {
if (chunk.choices?.[0]?.delta?.content) {
result.choices[0].message.content += chunk.choices[0].delta.content;
}
+
+ if (chunk.choices?.[0]?.delta?.tool_calls) {
+ const deltaTools = chunk.choices[0].delta.tool_calls;
+ for (const tool of deltaTools) {
+ const idx = tool.index || 0;
+ while (toolCalls.length <= idx) {
+ toolCalls.push({
+ id: '',
+ type: 'function',
+ function: { name: '', arguments: '' },
+ });
+ }
+ if (tool.id) {
+ toolCalls[idx].id = tool.id;
+ toolCalls[idx].type = tool.type || 'function';
+ if (tool.function?.name) {
+ toolCalls[idx].function.name = tool.function.name;
+ }
+ if (tool.function?.arguments) {
+ toolCalls[idx].function.arguments = tool.function.arguments;
+ }
+ } else if (tool.function?.arguments) {
+ toolCalls[idx].function.arguments += tool.function.arguments;
+ }
+ }
+ tools = true;
+ }
+
yield chunk;
}
+ if (toolCalls.length > 0) {
+ result.choices[0].message = {
+ ...result.choices[0].message,
+ tool_calls: toolCalls,
+ } as any;
+ }
+
let promptTokens = 0;
for (const message of messages || []) {
promptTokens += OpenLitHelper.generalTokens(message.content as string) ?? 0;
@@ -126,6 +192,8 @@ class HuggingFaceWrapper extends BaseWrapper {
};
}
+ args[0].tools = tools;
+
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -169,33 +237,55 @@ class HuggingFaceWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'mistralai/Mistral-7B-Instruct-v0.1';
const {
messages,
- model,
+ frequency_penalty = 0,
max_tokens = null,
+ n = 1,
+ presence_penalty = 0,
+ seed = null,
+ stop = null,
temperature = 1,
top_p,
stream = false,
+ tools: _tools,
} = args[0] || {};
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens || -1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
+ if (stop) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(stop) ? stop : [stop]);
+ }
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
+ }
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
}
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- if (result.id) span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
+ const responseModel = result.model || requestModel;
- const responseModel = result.model || model || '';
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost = OpenLitHelper.getChatModelCost(
- responseModel,
+ requestModel,
pricingInfo,
result.usage?.prompt_tokens || 0,
result.usage?.completion_tokens || 0
@@ -203,7 +293,7 @@ class HuggingFaceWrapper extends BaseWrapper {
HuggingFaceWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model: responseModel,
+ model: requestModel,
cost,
aiSystem: HuggingFaceWrapper.aiSystem,
serverAddress: HuggingFaceWrapper.serverAddress,
@@ -211,30 +301,86 @@ class HuggingFaceWrapper extends BaseWrapper {
});
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, result.usage?.prompt_tokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, result.usage?.completion_tokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, result.usage?.total_tokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.usage?.total_tokens || 0);
- if (ttft > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
- if (tbt > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ const inputTokens = result.usage?.prompt_tokens || 0;
+ const outputTokens = result.usage?.completion_tokens || 0;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- if (result.choices?.[0]?.finish_reason) {
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.choices[0].finish_reason]);
+ if (ttft > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ }
+ if (tbt > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- if (traceContent && result.choices?.[0]?.message) {
+ if (result.choices?.[0]?.finish_reason) {
span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(
- result.choices[0].message.content || '',
- result.choices[0].finish_reason || 'stop'
- )
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ [result.choices[0].finish_reason]
+ );
+ }
+
+ const outputType = typeof result.choices?.[0]?.message?.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ if (result.choices?.[0]?.message?.tool_calls) {
+ const tc = result.choices[0].message.tool_calls;
+ const toolNames = tc.map((t: any) => t.function?.name || '').filter(Boolean);
+ const toolIds = tc.map((t: any) => t.id || '').filter(Boolean);
+ const toolArgs = tc.map((t: any) => t.function?.arguments || '').filter(Boolean);
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
+ }
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const toolCalls = result.choices?.[0]?.message?.tool_calls;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.choices?.[0]?.message?.content || '',
+ result.choices?.[0]?.finish_reason || 'stop',
+ toolCalls
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: HuggingFaceWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: HuggingFaceWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.choices?.[0]?.finish_reason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
- return { genAIEndpoint, model: responseModel, cost, aiSystem: HuggingFaceWrapper.aiSystem };
+ return {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: HuggingFaceWrapper.aiSystem,
+ };
}
// ── Text Generation ──────────────────────────────────────────────────────────
@@ -243,9 +389,16 @@ class HuggingFaceWrapper extends BaseWrapper {
const genAIEndpoint = 'huggingface.text.generation';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'gpt2';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) =>
@@ -253,6 +406,14 @@ class HuggingFaceWrapper extends BaseWrapper {
)
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: HuggingFaceWrapper.aiSystem,
+ serverAddress: HuggingFaceWrapper.serverAddress,
+ serverPort: HuggingFaceWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -273,24 +434,23 @@ class HuggingFaceWrapper extends BaseWrapper {
}): Promise<any> {
let metricParams;
try {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
const { model = '', inputs = '', parameters = {} } = args[0] || {};
- const { max_new_tokens = null, temperature = 1 } = parameters;
+ const { max_new_tokens = null, temperature = 1, top_p } = parameters;
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_new_tokens || -1);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
+ if (max_new_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_new_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT, inputs);
- }
-
const generatedText: string = response?.generated_text || '';
const promptTokens = OpenLitHelper.generalTokens(inputs) ?? 0;
const completionTokens = OpenLitHelper.generalTokens(generatedText) ?? 0;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const responseModel = model;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost = OpenLitHelper.getChatModelCost(model, pricingInfo, promptTokens, completionTokens);
HuggingFaceWrapper.setBaseSpanAttributes(span, {
@@ -302,14 +462,38 @@ class HuggingFaceWrapper extends BaseWrapper {
serverPort: HuggingFaceWrapper.serverPort,
});
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, promptTokens + completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, promptTokens + completionTokens);
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ inputMessagesJson = OpenLitHelper.buildInputMessages([{ role: 'user', content: inputs }]);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(generatedText, 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT, generatedText);
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: model,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: HuggingFaceWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: HuggingFaceWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: promptTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: completionTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
metricParams = { genAIEndpoint, model, cost, aiSystem: HuggingFaceWrapper.aiSystem };
diff --git a/sdk/typescript/src/instrumentation/index.ts b/sdk/typescript/src/instrumentation/index.ts
index 33063da0..b36764ee 100644
--- a/sdk/typescript/src/instrumentation/index.ts
+++ b/sdk/typescript/src/instrumentation/index.ts
@@ -12,6 +12,7 @@ import TogetherInstrumentation from './together';
import OllamaInstrumentation from './ollama';
import VercelAIInstrumentation from './vercel-ai';
import LangChainInstrumentation from './langchain';
+import LangGraphInstrumentation from './langgraph';
import PineconeInstrumentation from './pinecone';
import BedrockInstrumentation from './bedrock';
import LlamaIndexInstrumentation from './llamaindex';
@@ -20,6 +21,52 @@ import ReplicateInstrumentation from './replicate';
import ChromaInstrumentation from './chroma';
import QdrantInstrumentation from './qdrant';
import MilvusInstrumentation from './milvus';
+import AzureAIInferenceInstrumentation from './azure-ai-inference';
+import OpenAIAgentsInstrumentation from './openai-agents';
+import StrandsInstrumentation from './strands';
+import GoogleADKInstrumentation from './google-adk';
+import ClaudeAgentSDKInstrumentation from './claude-agent-sdk';
+
+/**
+ * OTel community instrumentations loaded dynamically (like Python SDK).
+ * Each entry maps a logical name to the npm package and exported class.
+ * If the package is installed, the instrumentation is registered automatically.
+ * If not installed, it is silently skipped.
+ *
+ * Node.js equivalents of the Python SDK's OTel instrumentations:
+ * Python: requests, urllib, urllib3 → Node: http (@opentelemetry/instrumentation-http)
+ * Python: httpx, aiohttp-client → Node: undici (@opentelemetry/instrumentation-undici)
+ * Python: django, flask, fastapi… → Node: express, fastify, koa, hapi, nestjs-core
+ */
+const OTEL_COMMUNITY_INSTRUMENTATIONS: Record<string, { pkg: string; cls: string }> = {
+ // HTTP client instrumentations
+ 'http': { pkg: '@opentelemetry/instrumentation-http', cls: 'HttpInstrumentation' },
+ 'undici': { pkg: '@opentelemetry/instrumentation-undici', cls: 'UndiciInstrumentation' },
+ // HTTP framework instrumentations
+ 'express': { pkg: '@opentelemetry/instrumentation-express', cls: 'ExpressInstrumentation' },
+ 'fastify': { pkg: '@opentelemetry/instrumentation-fastify', cls: 'FastifyInstrumentation' },
+ 'koa': { pkg: '@opentelemetry/instrumentation-koa', cls: 'KoaInstrumentation' },
+ 'hapi': { pkg: '@opentelemetry/instrumentation-hapi', cls: 'HapiInstrumentation' },
+ 'nestjs-core': { pkg: '@opentelemetry/instrumentation-nestjs-core', cls: 'NestInstrumentation' },
+};
+
+function loadOtelCommunityInstrumentations(disabledInstrumentors: string[]): any[] {
+ const instances: any[] = [];
+ for (const [name, { pkg, cls }] of Object.entries(OTEL_COMMUNITY_INSTRUMENTATIONS)) {
+ if (disabledInstrumentors.includes(name)) continue;
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const mod = require(pkg);
+ const InstrClass = mod[cls];
+ if (InstrClass) {
+ instances.push(new InstrClass());
+ }
+ } catch {
+ // Package not installed — skip silently (same as Python SDK)
+ }
+ }
+ return instances;
+}
export default class Instrumentations {
static availableInstrumentations: OpenlitInstrumentations = {
@@ -33,6 +80,7 @@ export default class Instrumentations {
ollama: new OllamaInstrumentation(),
'vercel-ai': new VercelAIInstrumentation(),
langchain: new LangChainInstrumentation(),
+ langgraph: new LangGraphInstrumentation(),
pinecone: new PineconeInstrumentation(),
bedrock: new BedrockInstrumentation(),
llamaindex: new LlamaIndexInstrumentation(),
@@ -41,22 +89,32 @@ export default class Instrumentations {
chroma: new ChromaInstrumentation(),
qdrant: new QdrantInstrumentation(),
milvus: new MilvusInstrumentation(),
+ 'azure-ai-inference': new AzureAIInferenceInstrumentation(),
+ 'openai-agents': new OpenAIAgentsInstrumentation(),
+ strands: new StrandsInstrumentation(),
+ 'google-adk': new GoogleADKInstrumentation(),
+ 'claude-agent-sdk': new ClaudeAgentSDKInstrumentation(),
};
static setup(
tracerProvider: TracerProvider,
- disabledInstrumentations: string[] = [],
+ disabledInstrumentors: string[] = [],
instrumentations?: OpenlitInstrumentations
) {
+ const otelCommunity = loadOtelCommunityInstrumentations(disabledInstrumentors);
+
if (instrumentations === undefined) {
- const filteredInstrumentations = this.getFilteredInstrumentations(disabledInstrumentations);
+ const filteredInstrumentations = this.getFilteredInstrumentations(disabledInstrumentors);
registerInstrumentations({
- instrumentations: filteredInstrumentations.map(([_, instrumentation]) => instrumentation),
+ instrumentations: [
+ ...filteredInstrumentations.map(([_, instrumentation]) => instrumentation),
+ ...otelCommunity,
+ ],
tracerProvider,
});
} else {
const filteredInstrumentations = this.getFilteredInstrumentations(
- disabledInstrumentations,
+ disabledInstrumentors,
instrumentations
);
filteredInstrumentations.forEach(([k, instrumentation]) => {
@@ -68,19 +126,20 @@ export default class Instrumentations {
}
});
registerInstrumentations({
+ instrumentations: otelCommunity,
tracerProvider,
});
}
}
static getFilteredInstrumentations(
- disabledInstrumentations: string[],
+ disabledInstrumentors: string[],
instrumentations?: OpenlitInstrumentations
): [InstrumentationType, any][] {
const availableInstrumentations = instrumentations || this.availableInstrumentations;
return Object.keys(availableInstrumentations)
.filter((k) => {
- if (disabledInstrumentations.includes(k)) {
+ if (disabledInstrumentors.includes(k)) {
if (typeof availableInstrumentations[k as InstrumentationType].disable === 'function') {
availableInstrumentations[k as InstrumentationType].disable();
}
diff --git a/sdk/typescript/src/instrumentation/langchain/index.ts b/sdk/typescript/src/instrumentation/langchain/index.ts
index e5777a5d..a4feff7e 100644
--- a/sdk/typescript/src/instrumentation/langchain/index.ts
+++ b/sdk/typescript/src/instrumentation/langchain/index.ts
@@ -18,23 +18,13 @@ export default class OpenlitLangChainInstrumentation extends InstrumentationBase
}
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
- // We bypass OTel's RequireInTheMiddleSingleton here because it uses a null-whitelist
- // RITM instance, which causes RITM to report `name` as the `fullModuleName` (including
- // the .cjs extension), e.g. '@langchain/core/language_models/chat_models.cjs'.
- // The trie search then fails to match our registered bare name (without .cjs).
- // Instead, we set up a direct require-in-the-middle Hook in enable() with a proper
- // whitelist, which causes RITM to preserve the original specifier as `name`.
return [];
}
- /** Override enable() to install a direct RITM Hook rather than going through the singleton. */
public enable(): void {
- super.enable(); // sets this._enabled = true, initialises tracer
+ super.enable();
if (this._ritmHook) return;
try {
- // Require RITM directly — it is a transitive dep of @opentelemetry/instrumentation.
- // Using a whitelist ['@langchain/core/language_models/chat_models'] causes RITM to
- // preserve the original module specifier as `name` (avoiding the .cjs issue).
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Hook } = require('require-in-the-middle');
this._ritmHook = new Hook(
@@ -45,10 +35,9 @@ export default class OpenlitLangChainInstrumentation extends InstrumentationBase
return exports;
}
);
- } catch { /* require-in-the-middle not available — no-op */ }
+ } catch { /* require-in-the-middle not available */ }
}
- /** Override disable() to remove our direct RITM Hook. */
public disable(): void {
super.disable();
this._ritmHook?.unhook?.();
@@ -56,7 +45,6 @@ export default class OpenlitLangChainInstrumentation extends InstrumentationBase
this._unpatch();
}
- /** Called from tests / manual usage — pass the @langchain/core/callbacks/manager exports. */
public manualPatch(callbacksManagerModule: any): void {
const CallbackManager = callbacksManagerModule?.CallbackManager;
if (CallbackManager) {
@@ -65,10 +53,6 @@ export default class OpenlitLangChainInstrumentation extends InstrumentationBase
}
}
- /**
- * Scan require.cache for @langchain/core's dist/callbacks/manager.cjs.
- * It is always loaded as a relative dep before the chat_models hook fires.
- */
private _patchFromCache(): void {
try {
const cache = (require as NodeJS.Require & { cache: Record<string, any> }).cache;
@@ -95,8 +79,6 @@ export default class OpenlitLangChainInstrumentation extends InstrumentationBase
private _applyPatch(CallbackManager: any): void {
try {
- // Patch _configureSync — the single low-level entry point called by both
- // CallbackManager.configure and getCallbackManagerForConfig (Runnables/chains).
if (isWrapped(CallbackManager._configureSync)) {
this._unwrap(CallbackManager, '_configureSync');
}
diff --git a/sdk/typescript/src/instrumentation/langchain/wrapper.ts b/sdk/typescript/src/instrumentation/langchain/wrapper.ts
index e1d29295..a384056c 100644
--- a/sdk/typescript/src/instrumentation/langchain/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/langchain/wrapper.ts
@@ -1,85 +1,632 @@
-import { SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, SpanStatusCode, Tracer, context, trace } from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, {
+ applyCustomSpanAttributes,
+ isLangGraphActive,
+ runWithFrameworkLlm,
+ setFrameworkLlmActive,
+ resetFrameworkLlmActive,
+ setFrameworkParentContext,
+ clearFrameworkParentContext,
+ getServerAddressForProvider,
+} from '../../helpers';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
-// ----------------------------------------------------------------------------
-// Span tracking across async callback events
-// ----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// Types
+// ---------------------------------------------------------------------------
+
interface SpanHolder {
- span: any;
+ span: Span;
startTime: number;
modelName: string;
+ modelParameters: Record<string, any>;
+ provider: string;
+ serverAddress: string;
+ serverPort: number;
parentRunId?: string;
+ children: string[];
streamingContent: string[];
tokenTimestamps: number[];
firstTokenTime?: number;
- promptTokens: number;
- completionTokens: number;
+ inputTokens: number;
+ outputTokens: number;
+ cacheReadInputTokens: number;
+ cacheCreationInputTokens: number;
+ promptContent: string;
+ inputMessagesRaw: any;
+ prompts: any[];
+ inputMessagesStructured: any[];
+ systemInstructions: any[] | null;
+ toolDefinitions: any[] | null;
+ toolCalls: any[] | null;
+ finishReason: string;
+ isAgentChain: boolean;
+ responseId: string | null;
+ /** Token pair for framework LLM suppression reset */
+ suppressionActive: boolean;
+}
+
+// ---------------------------------------------------------------------------
+// Provider detection (mirrors Python PROVIDER_MAP)
+// ---------------------------------------------------------------------------
+
+const PROVIDER_MAP: Record<string, string> = {
+ anthropic: 'anthropic',
+ azure: 'azure',
+ bedrock: 'aws.bedrock',
+ bedrock_converse: 'aws.bedrock',
+ cohere: 'cohere',
+ google: 'google',
+ google_genai: 'google',
+ google_vertexai: 'google',
+ groq: 'groq',
+ mistralai: 'mistral_ai',
+ ollama: 'ollama',
+ openai: 'openai',
+ together: 'together',
+ vertexai: 'google',
+ fireworks: 'fireworks',
+ perplexity: 'perplexity',
+ huggingface: 'huggingface',
+ deepinfra: 'deepinfra',
+ anyscale: 'anyscale',
+};
+
+function detectProvider(serialized: any): string {
+ if (!serialized) return SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN;
+ const classId: string[] = serialized.id || [];
+ if (Array.isArray(classId)) {
+ const classPath = classId.join('.').toLowerCase();
+ for (const [key, val] of Object.entries(PROVIDER_MAP)) {
+ if (classPath.includes(key)) return val;
+ }
+ }
+ return SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN;
+}
+
+// ---------------------------------------------------------------------------
+// Model name extraction (mirrors Python extract_model_name)
+// ---------------------------------------------------------------------------
+
+const MODEL_PATHS_BY_ID: Array<[string, string[], 'serialized' | 'kwargs']> = [
+ ['ChatGoogleGenerativeAI', ['kwargs', 'model'], 'serialized'],
+ ['ChatVertexAI', ['kwargs', 'model_name'], 'serialized'],
+ ['ChatMistralAI', ['kwargs', 'model'], 'serialized'],
+ ['OpenAI', ['invocation_params', 'model_name'], 'kwargs'],
+ ['ChatOpenAI', ['invocation_params', 'model_name'], 'kwargs'],
+ ['AzureChatOpenAI', ['invocation_params', 'model'], 'kwargs'],
+ ['AzureChatOpenAI', ['invocation_params', 'model_name'], 'kwargs'],
+ ['AzureChatOpenAI', ['invocation_params', 'azure_deployment'], 'kwargs'],
+ ['HuggingFacePipeline', ['invocation_params', 'model_id'], 'kwargs'],
+ ['BedrockChat', ['kwargs', 'model_id'], 'serialized'],
+ ['Bedrock', ['kwargs', 'model_id'], 'serialized'],
+ ['BedrockLLM', ['kwargs', 'model_id'], 'serialized'],
+ ['ChatBedrock', ['kwargs', 'model_id'], 'serialized'],
+ ['ChatBedrockConverse', ['kwargs', 'model_id'], 'serialized'],
+ ['LlamaCpp', ['invocation_params', 'model_path'], 'kwargs'],
+ ['WatsonxLLM', ['invocation_params', 'model_id'], 'kwargs'],
+];
+
+const MODEL_PATTERNS: Array<[string, string, string | null]> = [
+ ['ChatAnthropic', 'model', 'anthropic'],
+ ['Anthropic', 'model', 'anthropic'],
+ ['ChatTongyi', 'model_name', null],
+ ['ChatCohere', 'model', null],
+ ['Cohere', 'model', null],
+ ['HuggingFaceHub', 'model', null],
+ ['ChatAnyscale', 'model_name', null],
+ ['TextGen', 'model', 'text-gen'],
+ ['Ollama', 'model', null],
+ ['OllamaLLM', 'model', null],
+ ['ChatOllama', 'model', null],
+ ['ChatFireworks', 'model', null],
+ ['ChatPerplexity', 'model', null],
+ ['VLLM', 'model', null],
+ ['Xinference', 'model_uid', null],
+ ['ChatOCIGenAI', 'model_id', null],
+ ['DeepInfra', 'model_id', null],
+];
+
+const FALLBACK_PATHS: Array<[string[], 'serialized' | 'kwargs']> = [
+ [['kwargs', 'model_name'], 'serialized'],
+ [['kwargs', 'model'], 'serialized'],
+ [['kwargs', 'model_id'], 'serialized'],
+ [['invocation_params', 'model_name'], 'kwargs'],
+ [['invocation_params', 'model'], 'kwargs'],
+ [['invocation_params', 'model_id'], 'kwargs'],
+];
+
+function _extractByPath(serialized: any, kwargs: any, keys: string[], selectFrom: string): string | null {
+ let obj = selectFrom === 'kwargs' ? kwargs : serialized;
+ if (obj == null) return null;
+ for (const key of keys) {
+ if (typeof obj === 'object' && obj !== null) {
+ obj = obj[key];
+ } else {
+ return null;
+ }
+ if (obj == null) return null;
+ }
+ return obj ? String(obj) : null;
+}
+
+function _getClassName(serialized: any): string | null {
+ if (!serialized) return null;
+ const id = serialized.id;
+ if (Array.isArray(id) && id.length > 0) return id[id.length - 1];
+ return null;
+}
+
+function _extractModelFromRepr(serialized: any, pattern: string): string | null {
+ if (!serialized) return null;
+ const repr = serialized.repr || '';
+ if (repr) {
+ const re = new RegExp(`${pattern}='(.*?)'`);
+ const match = re.exec(repr);
+ if (match) return match[1];
+ }
+ return null;
+}
+
+function extractModelName(serialized: any, kwargs: any): string {
+ const className = _getClassName(serialized);
+
+ for (const [modelId, keys, selectFrom] of MODEL_PATHS_BY_ID) {
+ if (className === modelId) {
+ const result = _extractByPath(serialized, kwargs, keys, selectFrom);
+ if (result) return result;
+ }
+ }
+
+ for (const [modelId, pattern, defaultVal] of MODEL_PATTERNS) {
+ if (className === modelId) {
+ const result = _extractModelFromRepr(serialized, pattern);
+ if (result) return result;
+ if (defaultVal) return defaultVal;
+ }
+ }
+
+ for (const [keys, selectFrom] of FALLBACK_PATHS) {
+ const result = _extractByPath(serialized, kwargs, keys, selectFrom);
+ if (result) return result;
+ }
+
+ return className || 'unknown';
+}
+
+function extractModelParameters(kwargs: any): Record<string, any> {
+ const params: Record<string, any> = {};
+ const ip = kwargs?.invocation_params || {};
+ const paramKeys = [
+ 'temperature', 'max_tokens', 'max_completion_tokens',
+ 'top_p', 'top_k', 'frequency_penalty', 'presence_penalty',
+ 'request_timeout', 'stop_sequences', 'seed',
+ ];
+ for (const key of paramKeys) {
+ if (ip[key] != null) params[key] = ip[key];
+ }
+ return params;
+}
+
+// ---------------------------------------------------------------------------
+// Chain type detection (mirrors Python)
+// ---------------------------------------------------------------------------
+
+const SKIP_CHAIN_CLASS_PREFIXES = new Set([
+ 'RunnableSequence', 'RunnableParallel', 'RunnableLambda',
+ 'RunnablePassthrough', 'RunnableAssign', 'RunnablePick',
+ 'RunnableBranch', 'RunnableEach', 'Prompt', 'PromptTemplate',
+ 'ChatPromptTemplate', 'MessagesPlaceholder',
+ 'SystemMessagePromptTemplate', 'HumanMessagePromptTemplate',
+ 'AIMessagePromptTemplate', 'BasePromptTemplate',
+ 'StrOutputParser', 'JsonOutputParser', 'PydanticOutputParser',
+]);
+
+function isInternalChain(serialized: any, name: string): boolean {
+ if (serialized?.id) {
+ const classPath: string[] = serialized.id;
+ if (Array.isArray(classPath) && classPath.length > 0) {
+ const cn = String(classPath[classPath.length - 1]);
+ if (SKIP_CHAIN_CLASS_PREFIXES.has(cn)) return true;
+ if (cn.startsWith('Runnable')) return true;
+ }
+ }
+ if (SKIP_CHAIN_CLASS_PREFIXES.has(name)) return true;
+ return false;
+}
+
+function detectObservationType(serialized: any, callbackType: string, name: string): string {
+ if (callbackType === 'tool') return 'tool';
+ if (callbackType === 'retriever') return 'retriever';
+ if (callbackType === 'llm') return 'generation';
+ if (callbackType === 'chain') {
+ if (serialized?.id) {
+ const classPath: string[] = serialized.id;
+ if (classPath.some((part: string) => String(part).toLowerCase().includes('agent'))) {
+ return 'agent';
+ }
+ }
+ if (name && name.toLowerCase().includes('agent')) return 'agent';
+ return 'chain';
+ }
+ return 'span';
+}
+
+// ---------------------------------------------------------------------------
+// Message formatting helpers (mirrors Python utils.py)
+// ---------------------------------------------------------------------------
+
+const ROLE_MAP: Record<string, string> = {
+ system: 'system',
+ human: 'user',
+ ai: 'assistant',
+ tool: 'tool',
+ function: 'tool',
+};
+
+function buildInputMessagesFromLangChain(messages: any[][]): any[] {
+ try {
+ const structured: any[] = [];
+ for (const msgList of messages) {
+ for (const msg of msgList) {
+ const role = msg._getType?.() || msg.type || 'user';
+ const content = msg.content ?? String(msg);
+ const otelRole = ROLE_MAP[role] || 'user';
+ structured.push({ role: otelRole, parts: buildParts(content) });
+ }
+ }
+ return structured;
+ } catch { return []; }
+}
+
+function buildInputMessagesFromPrompts(prompts: string[]): any[] {
+ try {
+ return prompts.map(p => ({
+ role: 'user',
+ parts: [{ type: 'text', content: typeof p === 'string' ? p : String(p) }],
+ }));
+ } catch { return []; }
+}
+
+function buildInputMessages(messagesOrPrompts: any): any[] {
+ if (!messagesOrPrompts) return [];
+ if (Array.isArray(messagesOrPrompts) && messagesOrPrompts.length > 0) {
+ const first = messagesOrPrompts[0];
+ if (typeof first === 'string') return buildInputMessagesFromPrompts(messagesOrPrompts);
+ if (Array.isArray(first) && first.length > 0 && first[0]?.content !== undefined) {
+ return buildInputMessagesFromLangChain(messagesOrPrompts);
+ }
+ return buildInputMessagesFromPrompts(messagesOrPrompts);
+ }
+ return [];
+}
+
+function buildParts(content: any): any[] {
+ if (typeof content === 'string') return [{ type: 'text', content }];
+ if (Array.isArray(content)) {
+ const parts: any[] = [];
+ for (const part of content) {
+ if (typeof part === 'string') {
+ parts.push({ type: 'text', content: part });
+ } else if (typeof part === 'object' && part !== null) {
+ const ptype = part.type || 'text';
+ if (ptype === 'text') {
+ parts.push({ type: 'text', content: part.text || '' });
+ } else if (ptype === 'image_url') {
+ const url = part.image_url;
+ if (typeof url === 'string') parts.push({ type: 'image', url });
+ else if (url?.url) parts.push({ type: 'image', url: url.url });
+ } else {
+ parts.push({ type: ptype, content: String(part) });
+ }
+ }
+ }
+ return parts.length > 0 ? parts : [{ type: 'text', content: '' }];
+ }
+ return [{ type: 'text', content: String(content) }];
+}
+
+function shouldCaptureMessageContent(): boolean {
+ return OpenlitConfig.captureMessageContent ?? (OpenlitConfig as any).traceContent ?? true;
+}
+
+function normalizeToolCalls(rawToolCalls: any[]): Array<{ id: string; type: string; name: string; arguments: unknown }> {
+ return rawToolCalls.map((call: any) => ({
+ id: call?.id || call?.tool_call_id || '',
+ type: call?.type || 'function',
+ name: call?.name || call?.function?.name || '',
+ arguments: call?.args ?? call?.arguments ?? call?.function?.arguments ?? {},
+ }));
}
-// Singleton handler — injected once into every CallbackManager created
+function stringifyToolCallArgument(value: unknown): string {
+ if (typeof value === 'string') return value;
+ try {
+ return JSON.stringify(value ?? {});
+ } catch {
+ return '[unserializable]';
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Conversation ID extraction (mirrors Python _resolve_conversation_id)
+// ---------------------------------------------------------------------------
+
+function resolveConversationId(metadata: any): string | null {
+ if (!metadata) return null;
+ for (const key of ['thread_id', 'conversation_id', 'session_id']) {
+ if (metadata[key]) return String(metadata[key]);
+ }
+ const configurable = metadata.configurable || {};
+ for (const key of ['thread_id', 'conversation_id']) {
+ if (configurable[key]) return String(configurable[key]);
+ }
+ return null;
+}
+
+// ---------------------------------------------------------------------------
+// Token calculation (approximate, mirrors Python general_tokens)
+// ---------------------------------------------------------------------------
+
+function generalTokens(text: string): number {
+ return Math.ceil(text.length / 2);
+}
+
+// ---------------------------------------------------------------------------
+// Callback Handler
+// ---------------------------------------------------------------------------
+
let handlerInstance: OpenLITCallbackHandler | null = null;
class OpenLITCallbackHandler {
name = 'openlit_callback_handler';
lc_serializable = false;
- // LangChain checks this to decide if it should be copied to child runs
awaitHandlers = false;
private tracer: Tracer;
private spans = new Map<string, SpanHolder>();
+ private skippedRuns = new Map<string, string | undefined>();
constructor(tracer: Tracer) {
this.tracer = tracer;
}
- // ---- Model name helpers --------------------------------------------------
+ // ---- Helpers -----------------------------------------------------------
- private _extractModelName(llm: any): string {
- if (!llm) return 'unknown';
- const id: string[] = llm.id || [];
- const className = id[id.length - 1] || '';
+ private _getNameFromCallback(serialized: any, kwargs: any): string {
+ if (kwargs?.name) return kwargs.name;
+ if (serialized) {
+ if (serialized.kwargs?.name) return serialized.kwargs.name;
+ if (serialized.name) return serialized.name;
+ if (serialized.id) {
+ const id = serialized.id;
+ if (Array.isArray(id) && id.length > 0) return id[id.length - 1];
+ }
+ }
+ return 'unknown';
+ }
- // Try various well-known invocation_params / kwargs paths
- const kw = llm.kwargs || {};
- const ip = kw.invocation_params || {};
+ private _resolveParentRunId(parentRunId?: string): string | undefined {
+ const visited = new Set<string>();
+ let current = parentRunId;
+ while (current && this.skippedRuns.has(current)) {
+ if (visited.has(current)) break;
+ visited.add(current);
+ current = this.skippedRuns.get(current);
+ }
+ return current;
+ }
- return (
- ip.model_name || ip.model || ip.model_id ||
- kw.model_name || kw.model || kw.model_id ||
- className || 'unknown'
- );
+ private _getParentContext(parentRunId?: string) {
+ const resolved = this._resolveParentRunId(parentRunId);
+ if (!resolved) return undefined;
+ const holder = this.spans.get(resolved);
+ if (!holder) return undefined;
+ return trace.setSpan(context.active(), holder.span);
+ }
+
+ private _createSpan(
+ runId: string,
+ parentRunId: string | undefined,
+ spanName: string,
+ kind: SpanKind = SpanKind.INTERNAL,
+ ): Span {
+ const resolved = this._resolveParentRunId(parentRunId);
+ let parentContext: ReturnType<typeof trace.setSpan> | undefined;
+ if (resolved && this.spans.has(resolved)) {
+ parentContext = trace.setSpan(context.active(), this.spans.get(resolved)!.span);
+ }
+ return this.tracer.startSpan(spanName, { kind }, parentContext);
}
- private _detectProvider(llm: any): string {
- if (!llm) return SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN;
- const classPath = (llm.id || []).join('.').toLowerCase();
- const providerMap: Record<string, string> = {
- openai: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
- anthropic: SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC,
- bedrock: SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK,
- google: SemanticConvention.GEN_AI_SYSTEM_VERTEXAI,
- cohere: SemanticConvention.GEN_AI_SYSTEM_COHERE,
- mistral: SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
+ private _newHolder(span: Span, parentRunId?: string): SpanHolder {
+ return {
+ span,
+ startTime: Date.now(),
+ modelName: 'unknown',
+ modelParameters: {},
+ provider: '',
+ serverAddress: '',
+ serverPort: 0,
+ parentRunId,
+ children: [],
+ streamingContent: [],
+ tokenTimestamps: [],
+ inputTokens: 0,
+ outputTokens: 0,
+ cacheReadInputTokens: 0,
+ cacheCreationInputTokens: 0,
+ promptContent: '',
+ inputMessagesRaw: null,
+ prompts: [],
+ inputMessagesStructured: [],
+ systemInstructions: null,
+ toolDefinitions: null,
+ toolCalls: null,
+ finishReason: 'stop',
+ isAgentChain: false,
+ responseId: null,
+ suppressionActive: false,
};
- for (const [key, val] of Object.entries(providerMap)) {
- if (classPath.includes(key)) return val;
+ }
+
+ private _setCommonAttributes(span: Span, operationType: string): void {
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operationType);
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment || 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName || 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ }
+
+ private _setModelParameters(span: Span, params: Record<string, any>): void {
+ if (params.temperature != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, params.temperature);
+ if (params.max_tokens != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.max_tokens);
+ if (params.max_completion_tokens != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.max_completion_tokens);
+ if (params.top_p != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, params.top_p);
+ if (params.top_k != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, params.top_k);
+ if (params.frequency_penalty != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, params.frequency_penalty);
+ if (params.presence_penalty != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, params.presence_penalty);
+ if (params.seed != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(params.seed));
+ const stop = params.stop || params.stop_sequences;
+ if (stop) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(stop) ? stop : [stop],
+ );
}
- return SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN;
}
- // ---- Parent context -------------------------------------------------------
+ private _endSpan(runId: string, error?: string): void {
+ const holder = this.spans.get(runId);
+ if (!holder) return;
- private _getParentContext(parentRunId?: string) {
- if (!parentRunId) return undefined;
- const holder = this.spans.get(parentRunId);
- if (!holder) return undefined;
- return trace.setSpan(context.active(), holder.span);
+ for (const childId of holder.children || []) {
+ const child = this.spans.get(childId);
+ if (child) {
+ try { child.span.end(); } catch { /* already ended */ }
+ }
+ }
+
+ if (error) {
+ holder.span.setStatus({ code: SpanStatusCode.ERROR, message: error });
+ } else {
+ holder.span.setStatus({ code: SpanStatusCode.OK });
+ }
+ holder.span.end();
+ this.spans.delete(runId);
}
- // ---- LLM callbacks -------------------------------------------------------
+ // ---- Chain Callbacks ---------------------------------------------------
+
+ handleChainStart(
+ chain: any,
+ inputs: any,
+ runId: string,
+ parentRunId?: string,
+ _tags?: string[],
+ metadata?: any,
+ _runType?: string,
+ name?: string,
+ ) {
+ try {
+ const resolvedName = this._getNameFromCallback(chain, { name });
+ const obsType = detectObservationType(chain, 'chain', resolvedName);
+
+ if (obsType !== 'agent' && isInternalChain(chain, resolvedName)) {
+ this.skippedRuns.set(runId, parentRunId);
+ return;
+ }
+
+ if (obsType !== 'agent' && isLangGraphActive() && !parentRunId) {
+ this.skippedRuns.set(runId, parentRunId);
+ return;
+ }
+
+ if (obsType !== 'agent' && parentRunId) {
+ this.skippedRuns.set(runId, parentRunId);
+ return;
+ }
+
+ const operationType = obsType === 'agent'
+ ? SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT
+ : SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
+ const spanName = obsType === 'agent'
+ ? `invoke_agent ${resolvedName}`
+ : `invoke_workflow ${resolvedName}`;
+
+ const span = this._createSpan(runId, parentRunId, spanName);
+ const holder = this._newHolder(span, parentRunId);
+ if (obsType === 'agent') holder.isAgentChain = true;
+ this.spans.set(runId, holder);
+
+ if (parentRunId) {
+ const parentResolved = this._resolveParentRunId(parentRunId);
+ if (parentResolved && this.spans.has(parentResolved)) {
+ this.spans.get(parentResolved)!.children.push(runId);
+ }
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
+ this._setCommonAttributes(span, operationType);
+
+ if (obsType === 'agent') {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, resolvedName);
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_ID, runId);
+ } else {
+ span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, resolvedName);
+ }
+
+ const convId = resolveConversationId(metadata);
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+
+ if (OpenlitConfig.captureMessageContent && inputs) {
+ try {
+ const inputStr = typeof inputs === 'string' ? inputs : JSON.stringify(inputs);
+ span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_INPUT, inputStr.slice(0, 2000));
+ } catch { /* non-blocking */ }
+ }
+
+ applyCustomSpanAttributes(span);
+ } catch { /* non-blocking */ }
+ }
+
+ handleChainEnd(outputs: any, runId: string) {
+ try {
+ this.skippedRuns.delete(runId);
+ const holder = this.spans.get(runId);
+ if (!holder) return;
+
+ const duration = (Date.now() - holder.startTime) / 1000;
+ holder.span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+
+ if (OpenlitConfig.captureMessageContent && outputs) {
+ try {
+ const outputStr = typeof outputs === 'string' ? outputs : JSON.stringify(outputs);
+ holder.span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_OUTPUT, outputStr.slice(0, 2000));
+ } catch { /* non-blocking */ }
+ }
+
+ this._endSpan(runId);
+ } catch { /* non-blocking */ }
+ }
+
+ handleChainError(error: any, runId: string) {
+ try {
+ this.skippedRuns.delete(runId);
+ if (this.spans.has(runId)) {
+ const span = this.spans.get(runId)!.span;
+ const errorType = error?.constructor?.name || '_OTHER';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ }
+ this._endSpan(runId, String(error));
+ } catch { /* non-blocking */ }
+ }
+
+ // ---- LLM Callbacks -----------------------------------------------------
handleChatModelStart(
llm: any,
@@ -89,56 +636,181 @@ class OpenLITCallbackHandler {
_extraParams?: any,
_tags?: string[],
metadata?: any,
- name?: string
+ kwargs?: any,
) {
try {
- const modelName = this._extractModelName(llm);
- const provider = this._detectProvider(llm);
+ const modelName = extractModelName(llm, kwargs || {});
+ const modelParams = extractModelParameters(kwargs || {});
+ const provider = detectProvider(llm);
const spanName = `chat ${modelName}`;
- const parentCtx = this._getParentContext(parentRunId);
- const span = this.tracer.startSpan(
- spanName,
- { kind: SpanKind.CLIENT },
- parentCtx
- );
+ const span = this._createSpan(runId, parentRunId, spanName, SpanKind.CLIENT);
+ const holder = this._newHolder(span, parentRunId);
+ holder.modelName = modelName;
+ holder.modelParameters = modelParams;
+ holder.provider = provider;
+ holder.suppressionActive = true;
+ setFrameworkLlmActive();
+ setFrameworkParentContext(trace.setSpan(context.active(), span));
+ this.spans.set(runId, holder);
+
+ if (parentRunId) {
+ const parentResolved = this._resolveParentRunId(parentRunId);
+ if (parentResolved && this.spans.has(parentResolved)) {
+ this.spans.get(parentResolved)!.children.push(runId);
+ }
+ }
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, provider);
span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, provider);
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_ENVIRONMENT, OpenlitConfig.environment || '');
- span.setAttribute(SemanticConvention.GEN_AI_APPLICATION_NAME, OpenlitConfig.applicationName || '');
+ this._setCommonAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelName);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ this._setModelParameters(span, modelParams);
+
+ const convId = resolveConversationId(metadata);
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+
+ // Server address from invocation_params or provider defaults
+ const ip = kwargs?.invocation_params || {};
+ const apiBase = ip.api_base || ip.base_url;
+ if (apiBase) {
+ try {
+ const url = new URL(apiBase);
+ holder.serverAddress = url.hostname || '';
+ holder.serverPort = url.port ? Number(url.port) : 443;
+ } catch { /* ignore */ }
+ }
+ if (!holder.serverAddress) {
+ const [defaultHost, defaultPort] = getServerAddressForProvider(provider);
+ if (defaultHost) {
+ holder.serverAddress = defaultHost;
+ holder.serverPort = defaultPort;
+ }
+ }
+
+ if (messages) {
+ const formatted: string[] = [];
+ for (const msgList of messages) {
+ for (const msg of msgList) {
+ const role = msg._getType?.() || msg.type || 'unknown';
+ const content = msg.content ?? String(msg);
+ formatted.push(`${role}: ${content}`);
+ }
+ }
+ const promptStr = formatted.join('\n');
+ holder.promptContent = promptStr;
+ holder.inputTokens = generalTokens(promptStr);
+ holder.inputMessagesRaw = messages;
+
+ if (OpenlitConfig.captureMessageContent) {
+ // System instructions
+ const sysInstructions: any[] = [];
+ for (const msgList of messages) {
+ for (const msg of msgList) {
+ const role = msg._getType?.() || msg.type || '';
+ if (role === 'system') {
+ const content = msg.content ?? '';
+ if (content) sysInstructions.push({ type: 'text', content: String(content) });
+ }
+ }
+ }
+ if (sysInstructions.length > 0) {
+ holder.systemInstructions = sysInstructions;
+ span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, JSON.stringify(sysInstructions));
+ }
- // Model parameters from invocation_params
- const ip = llm?.kwargs?.invocation_params || {};
- if (ip.temperature != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, ip.temperature);
- if (ip.max_tokens != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, ip.max_tokens);
- if (ip.top_p != null) span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, ip.top_p);
+ // Tool definitions
+ const tools = ip.tools || ip.functions;
+ if (tools && Array.isArray(tools)) {
+ holder.toolDefinitions = tools;
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_DEFINITIONS, JSON.stringify(tools));
+ }
- if (OpenlitConfig.traceContent && messages?.length > 0) {
- const flatMessages = messages.flat().map((m: any) => ({
- role: m._getType?.() || m.type || m.role || 'user',
- content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content),
- }));
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(flatMessages));
+ // Structured input messages
+ try {
+ holder.inputMessagesStructured = buildInputMessages(messages);
+ } catch { /* non-blocking */ }
+ }
}
- this.spans.set(runId, {
- span,
- startTime: Date.now(),
- modelName,
- parentRunId,
- streamingContent: [],
- tokenTimestamps: [],
- promptTokens: 0,
- completionTokens: 0,
- });
+ applyCustomSpanAttributes(span);
} catch { /* non-blocking */ }
}
- handleLLMNewToken(token: string, _idx: any, runId: string) {
+ handleLLMStart(
+ serialized: any,
+ prompts: string[],
+ runId: string,
+ parentRunId?: string,
+ _extraParams?: any,
+ _tags?: string[],
+ metadata?: any,
+ kwargs?: any,
+ ) {
+ try {
+ const modelName = extractModelName(serialized, kwargs || {});
+ const modelParams = extractModelParameters(kwargs || {});
+ const provider = detectProvider(serialized);
+ const spanName = `chat ${modelName}`;
+
+ const span = this._createSpan(runId, parentRunId, spanName, SpanKind.CLIENT);
+ const holder = this._newHolder(span, parentRunId);
+ holder.modelName = modelName;
+ holder.modelParameters = modelParams;
+ holder.provider = provider;
+ holder.prompts = prompts || [];
+ holder.suppressionActive = true;
+ setFrameworkLlmActive();
+ setFrameworkParentContext(trace.setSpan(context.active(), span));
+ this.spans.set(runId, holder);
+
+ if (parentRunId) {
+ const parentResolved = this._resolveParentRunId(parentRunId);
+ if (parentResolved && this.spans.has(parentResolved)) {
+ this.spans.get(parentResolved)!.children.push(runId);
+ }
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, provider);
+ this._setCommonAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelName);
+ this._setModelParameters(span, modelParams);
+
+ const convId = resolveConversationId(metadata);
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+
+ // Server address
+ const ip = kwargs?.invocation_params || {};
+ const apiBase = ip.api_base || ip.base_url;
+ if (apiBase) {
+ try {
+ const url = new URL(apiBase);
+ holder.serverAddress = url.hostname || '';
+ holder.serverPort = url.port ? Number(url.port) : 443;
+ } catch { /* ignore */ }
+ }
+ if (!holder.serverAddress) {
+ const [defaultHost, defaultPort] = getServerAddressForProvider(provider);
+ if (defaultHost) {
+ holder.serverAddress = defaultHost;
+ holder.serverPort = defaultPort;
+ }
+ }
+
+ if (prompts && prompts.length > 0) {
+ const promptStr = prompts.join('\n');
+ holder.inputTokens = generalTokens(promptStr);
+ if (OpenlitConfig.captureMessageContent) {
+ try {
+ holder.inputMessagesStructured = buildInputMessages(prompts);
+ } catch { /* non-blocking */ }
+ }
+ }
+
+ applyCustomSpanAttributes(span);
+ } catch { /* non-blocking */ }
+ }
+
+ handleLLMNewToken(token: string, _idx: any, runId: string, _chunk?: any) {
try {
const holder = this.spans.get(runId);
if (!holder) return;
@@ -146,306 +818,313 @@ class OpenLITCallbackHandler {
if (!holder.firstTokenTime) holder.firstTokenTime = now;
holder.tokenTimestamps.push(now);
if (token) holder.streamingContent.push(token);
- // Mark as streaming
- holder.span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
} catch { /* non-blocking */ }
}
handleLLMEnd(output: any, runId: string) {
- this._finalizeLLMSpan(runId, output, undefined);
- }
-
- handleLLMError(error: any, runId: string) {
- try {
- const holder = this.spans.get(runId);
- if (!holder) return;
- OpenLitHelper.handleException(holder.span, error);
- holder.span.end();
- this.spans.delete(runId);
- } catch { /* non-blocking */ }
- }
-
- private async _finalizeLLMSpan(runId: string, output: any, _error: any) {
try {
const holder = this.spans.get(runId);
if (!holder) return;
- const { span, startTime, modelName, streamingContent, tokenTimestamps, firstTokenTime } = holder;
+ const {
+ span,
+ startTime,
+ modelName,
+ modelParameters = {},
+ streamingContent = [],
+ tokenTimestamps = [],
+ firstTokenTime,
+ } = holder;
const endTime = Date.now();
+ const duration = (endTime - startTime) / 1000;
+
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+
const isStreaming = streamingContent.length > 0;
+ let ttft = 0;
+ let tbt = 0;
+
+ if (isStreaming) {
+ if (firstTokenTime) ttft = (firstTokenTime - startTime) / 1000;
+ if (tokenTimestamps.length > 1) {
+ const diffs = tokenTimestamps.slice(1).map((t, i) => t - tokenTimestamps[i]);
+ tbt = diffs.reduce((a, b) => a + b, 0) / diffs.length / 1000;
+ }
+ } else {
+ ttft = duration;
+ }
- // Extract tokens from output
- let promptTokens = 0;
- let completionTokens = 0;
- let completionContent = '';
- let finishReason = 'stop';
+ // Extract tokens and content from output
+ let inputTokens = holder.inputTokens;
+ let outputTokens = 0;
+ let completionContent = streamingContent.join('');
let responseModel = modelName;
- let toolCalls: Array<{ id: string; type: string; name: string; arguments: unknown }> = [];
+ let responseId: string | null = null;
+ // From llm_output (top-level)
if (output?.llm_output) {
const lu = output.llm_output;
const tu = lu.token_usage || lu.usage || {};
- promptTokens = tu.prompt_tokens || tu.input_tokens || 0;
- completionTokens = tu.completion_tokens || tu.output_tokens || 0;
+ inputTokens = tu.prompt_tokens || tu.input_tokens || inputTokens;
+ outputTokens = tu.completion_tokens || tu.output_tokens || outputTokens;
responseModel = lu.model_name || lu.model || modelName;
+ responseId = lu.id || null;
+
+ // Cache token extraction
+ const promptDetails = tu.prompt_tokens_details || tu.input_tokens_details || {};
+ let cached = promptDetails.cached_tokens || 0;
+ const inputDetails = tu.input_tokens_details || {};
+ let creation = inputDetails.cache_creation_tokens || 0;
+ const langchainInput = tu.input_token_details || {};
+ if (!cached) cached = langchainInput.cache_read || 0;
+ if (!creation) creation = langchainInput.cache_creation || 0;
+ holder.cacheReadInputTokens = cached;
+ holder.cacheCreationInputTokens = creation;
}
+ // From generations
const generations = output?.generations || [];
for (const genList of generations) {
for (const gen of (Array.isArray(genList) ? genList : [genList])) {
const msg = gen?.message || gen;
- // From usage_metadata (standard LangChain)
+
+ // Usage from usage_metadata
const um = msg?.usage_metadata;
if (um) {
- if (!promptTokens) promptTokens = um.input_tokens || um.prompt_tokens || 0;
- if (!completionTokens) completionTokens = um.output_tokens || um.completion_tokens || 0;
- }
- // Content
- const content = gen?.text || msg?.content || '';
- if (content && typeof content === 'string' && content.length > completionContent.length) {
- completionContent = content;
+ if (!inputTokens) inputTokens = um.input_tokens || um.prompt_tokens || 0;
+ if (!outputTokens) outputTokens = um.output_tokens || um.completion_tokens || 0;
+
+ // Cache tokens from usage_metadata
+ const pd = um.prompt_tokens_details || um.input_tokens_details || {};
+ if (!holder.cacheReadInputTokens) holder.cacheReadInputTokens = pd.cached_tokens || 0;
+ const langchainInput = um.input_token_details || {};
+ if (!holder.cacheReadInputTokens) holder.cacheReadInputTokens = langchainInput.cache_read || 0;
+ if (!holder.cacheCreationInputTokens) holder.cacheCreationInputTokens = langchainInput.cache_creation || 0;
}
- // Tool calls — LangChain surfaces these on AIMessage.tool_calls as
- // `{ id, name, args }`. Normalise the field name so helpers.buildOutputMessages
- // (which accepts a toolCalls array) can fold them into gen_ai.output.messages.
- const rawToolCalls =
- msg?.tool_calls ||
- gen?.message?.tool_calls ||
- msg?.additional_kwargs?.tool_calls ||
- [];
- if (Array.isArray(rawToolCalls) && rawToolCalls.length > 0) {
- // When the provider returns multiple generations (n > 1 or multiple
- // prompts), LangChain still collapses into a single assistant
- // message here. Take the last generation that carries tool_calls
- // to stay symmetric with how `finishReason` below is overwritten
- // (last-writer-wins) rather than merging tool calls from different
- // choices into a single message.
- toolCalls = [];
- for (const tc of rawToolCalls) {
- toolCalls.push({
- id: tc.id || tc.tool_call_id || '',
- type: tc.type || 'function',
- name: tc.name || tc.function?.name || '',
- arguments: tc.args ?? tc.arguments ?? tc.function?.arguments ?? {},
- });
+
+ // Token usage from response_metadata
+ if (msg?.response_metadata) {
+ const rm = msg.response_metadata;
+ const tokenUsage = rm.token_usage;
+ if (tokenUsage) {
+ inputTokens = tokenUsage.prompt_tokens || tokenUsage.input_tokens || inputTokens;
+ outputTokens = tokenUsage.completion_tokens || tokenUsage.output_tokens || outputTokens;
+ }
+ if (rm.usage) {
+ inputTokens = rm.usage.inputTokens || rm.usage.input_tokens || inputTokens;
+ outputTokens = rm.usage.outputTokens || rm.usage.output_tokens || outputTokens;
+ }
+ if (rm['amazon-bedrock-invocationMetrics']) {
+ const bm = rm['amazon-bedrock-invocationMetrics'];
+ inputTokens = bm.inputTokenCount || inputTokens;
+ outputTokens = bm.outputTokenCount || outputTokens;
}
}
+
+ // Content
+ const genContent = gen?.text || msg?.content;
+ if (genContent && typeof genContent === 'string' && genContent.length > completionContent.length) {
+ completionContent = genContent;
+ }
+
// Finish reason
const fr = gen?.generationInfo?.finish_reason || msg?.response_metadata?.finish_reason;
- if (fr) finishReason = fr;
+ if (fr) holder.finishReason = fr;
+
+ // Tool calls. Keep last-writer-wins semantics across generations so
+ // choices are not merged into one assistant message.
+ const tc = msg?.tool_calls || msg?.additional_kwargs?.tool_calls || gen?.message?.tool_calls;
+ if (tc && Array.isArray(tc) && tc.length > 0) {
+ holder.toolCalls = normalizeToolCalls(tc);
+ }
}
}
- if (isStreaming) {
- completionContent = streamingContent.join('');
- }
+ // Fallback token estimation
+ if (!outputTokens && completionContent) outputTokens = generalTokens(completionContent);
+ if (!inputTokens && holder.promptContent) inputTokens = generalTokens(holder.promptContent);
- const totalTokens = promptTokens + completionTokens;
- const duration = (endTime - startTime) / 1000;
+ // Cost
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(modelName, pricingInfo, inputTokens, outputTokens);
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(responseModel, pricingInfo, promptTokens, completionTokens);
+ // Provider for span attributes
+ const provider = holder.provider || SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN;
+ const serverAddress = holder.serverAddress || '';
+ const serverPort = holder.serverPort || 0;
+ // Set span attributes
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, inputTokens + outputTokens);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, cost);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [holder.finishReason]);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, typeof completionContent === 'string' ? 'text' : 'json');
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStreaming);
+
+ if (responseId) span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, responseId);
- if (isStreaming && firstTokenTime) {
- const ttft = (firstTokenTime - startTime) / 1000;
+ if (serverAddress) {
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, serverAddress);
+ span.setAttribute(SemanticConvention.SERVER_PORT, serverPort);
+ }
+
+ if (isStreaming && ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
- if (tokenTimestamps.length > 1) {
- const diffs = tokenTimestamps.slice(1).map((t, i) => t - tokenTimestamps[i]);
- const tbt = diffs.reduce((a, b) => a + b, 0) / diffs.length / 1000;
- span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ if (tbt > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ }
+
+ // Cache tokens
+ if (holder.cacheReadInputTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, holder.cacheReadInputTokens);
+ }
+ if (holder.cacheCreationInputTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, holder.cacheCreationInputTokens);
+ }
+
+ // Tool calls on span
+ if (holder.toolCalls && holder.toolCalls.length > 0) {
+ const names = holder.toolCalls.map((t: any) => t.name || t.function?.name || '').filter(Boolean);
+ const ids = holder.toolCalls.map((t: any) => t.id || '').filter(Boolean);
+ const args = holder.toolCalls.map((t: any) => stringifyToolCallArgument(t.arguments ?? t.function?.arguments));
+ if (names.length) span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, names.join(', '));
+ if (ids.length) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, ids.join(', '));
+ if (args.length) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, args);
+ }
+
+ let outputMessagesJson: string | null = null;
+
+ // Content attributes (gated by captureMessageContent)
+ if (shouldCaptureMessageContent()) {
+ const inputRaw = holder.inputMessagesRaw || holder.prompts || [];
+ const inputMessagesStructured = holder.inputMessagesStructured || [];
+ const inputMsgs = inputMessagesStructured.length > 0
+ ? inputMessagesStructured
+ : buildInputMessages(inputRaw);
+ const outputToolCalls = holder.toolCalls && holder.toolCalls.length > 0 ? holder.toolCalls : undefined;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(completionContent, holder.finishReason, outputToolCalls);
+
+ if (inputMsgs.length > 0) span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(inputMsgs));
+ if (outputMessagesJson && (outputMessagesJson !== '[]' || completionContent || outputToolCalls)) {
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
}
}
- if (OpenlitConfig.traceContent && (completionContent || toolCalls.length > 0)) {
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(
- completionContent,
- finishReason,
- toolCalls.length > 0 ? toolCalls : undefined
- )
- );
- }
-
- // Flatten tool-call metadata for easier indexing / filtering in backends
- // that don't expand the nested gen_ai.output.messages JSON.
- if (toolCalls.length > 0) {
- const toolNames = toolCalls.map((t) => t.name || '').filter(Boolean);
- const toolIds = toolCalls.map((t) => t.id || '').filter(Boolean);
- const toolArgs = toolCalls.map((t) => {
- if (typeof t.arguments === 'string') {
- return t.arguments;
- }
- try {
- return JSON.stringify(t.arguments ?? {});
- } catch {
- // Circular references, BigInt, etc. — never let span finalisation
- // throw here (the outer try/catch would swallow the error and
- // leave the span un-ended / the run entry in `spans` leaked).
- return '[unserializable]';
- }
- });
- if (toolNames.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ // Emit inference event (always emitted; content within is gated)
+ const eventAttrs: Record<string, any> = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: modelName,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [holder.finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: typeof completionContent === 'string' ? 'text' : 'json',
+ };
+ if (serverAddress) eventAttrs[SemanticConvention.SERVER_ADDRESS] = serverAddress;
+ if (serverPort) eventAttrs[SemanticConvention.SERVER_PORT] = serverPort;
+ if (responseId) eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID] = responseId;
+
+ if (shouldCaptureMessageContent()) {
+ const inputRaw = holder.inputMessagesRaw || holder.prompts || [];
+ const inputMessagesStructured = holder.inputMessagesStructured || [];
+ const inputMsgs = inputMessagesStructured.length > 0
+ ? inputMessagesStructured
+ : buildInputMessages(inputRaw);
+ if (inputMsgs.length > 0) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = JSON.stringify(inputMsgs);
+ if (outputMessagesJson && outputMessagesJson !== '[]') eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ if (holder.systemInstructions) {
+ eventAttrs[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS] = JSON.stringify(holder.systemInstructions);
}
- if (toolIds.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ if (holder.toolDefinitions) {
+ eventAttrs[SemanticConvention.GEN_AI_TOOL_DEFINITIONS] = JSON.stringify(holder.toolDefinitions);
}
- if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
+
+ // Request params for event
+ for (const [k, attr] of [
+ ['temperature', SemanticConvention.GEN_AI_REQUEST_TEMPERATURE],
+ ['top_p', SemanticConvention.GEN_AI_REQUEST_TOP_P],
+ ['frequency_penalty', SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY],
+ ['presence_penalty', SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY],
+ ] as const) {
+ if (modelParameters[k] != null) eventAttrs[attr] = modelParameters[k];
}
+ const maxT = modelParameters.max_tokens || modelParameters.max_completion_tokens;
+ if (maxT != null) eventAttrs[SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS] = maxT;
}
- // base attributes (system, endpoint, etc.)
- BaseWrapper.setBaseSpanAttributes(span, {
- genAIEndpoint: `langchain.chat_model`,
- model: responseModel,
- cost,
- aiSystem: SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN,
- serverAddress: 'localhost',
- serverPort: 80,
- });
+ if (typeof OpenLitHelper.emitInferenceEvent === 'function') {
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+ // Record metrics
const metricParams: BaseSpanAttributes = {
genAIEndpoint: 'langchain.chat_model',
model: responseModel,
cost,
- aiSystem: SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN,
- serverAddress: 'localhost',
- serverPort: 80,
+ aiSystem: provider,
+ serverAddress,
+ serverPort,
};
- span.setStatus({ code: 1 });
- span.end();
BaseWrapper.recordMetrics(span, metricParams);
- this.spans.delete(runId);
- } catch { /* non-blocking */ }
- }
- // ---- Chain callbacks -------------------------------------------------------
-
- handleChainStart(chain: any, inputs: any, runId: string, parentRunId?: string) {
- try {
- const id: string[] = chain?.id || [];
- const name = id[id.length - 1] || 'chain';
- const isAgent = id.some((part: string) => part.toLowerCase().includes('agent')) ||
- name.toLowerCase().includes('agent');
-
- const operationType = isAgent
- ? SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT
- : SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
- const spanName = isAgent ? `invoke_agent ${name}` : `invoke_workflow ${name}`;
-
- const parentCtx = this._getParentContext(parentRunId);
- const span = this.tracer.startSpan(
- spanName,
- { kind: SpanKind.INTERNAL },
- parentCtx
- );
-
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operationType);
- span.setAttribute(SemanticConvention.GEN_AI_ENVIRONMENT, OpenlitConfig.environment || '');
- span.setAttribute(SemanticConvention.GEN_AI_APPLICATION_NAME, OpenlitConfig.applicationName || '');
-
- if (isAgent) {
- span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, name);
- } else {
- span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, name);
- }
-
- if (OpenlitConfig.traceContent && inputs) {
- span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_INPUT, JSON.stringify(inputs).slice(0, 2000));
+ if (holder.suppressionActive) {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
}
-
- this.spans.set(runId, {
- span,
- startTime: Date.now(),
- modelName: name,
- parentRunId,
- streamingContent: [],
- tokenTimestamps: [],
- promptTokens: 0,
- completionTokens: 0,
- });
+ this._endSpan(runId);
} catch { /* non-blocking */ }
}
- handleChainEnd(outputs: any, runId: string) {
+ handleLLMError(error: any, runId: string) {
try {
const holder = this.spans.get(runId);
if (!holder) return;
- const duration = (Date.now() - holder.startTime) / 1000;
- holder.span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- if (OpenlitConfig.traceContent && outputs) {
- holder.span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_OUTPUT, JSON.stringify(outputs).slice(0, 2000));
+ if (holder.suppressionActive) {
+ resetFrameworkLlmActive();
+ clearFrameworkParentContext();
}
- holder.span.setStatus({ code: 1 });
- holder.span.end();
- this.spans.delete(runId);
+ const errorType = error?.constructor?.name || '_OTHER';
+ holder.span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ OpenLitHelper.handleException(holder.span, error instanceof Error ? error : new Error(String(error)));
+ this._endSpan(runId, String(error));
} catch { /* non-blocking */ }
}
- handleChainError(error: any, runId: string) {
- try {
- const holder = this.spans.get(runId);
- if (!holder) return;
- OpenLitHelper.handleException(holder.span, error);
- holder.span.end();
- this.spans.delete(runId);
- } catch { /* non-blocking */ }
- }
-
- // ---- Tool callbacks --------------------------------------------------------
+ // ---- Tool Callbacks ----------------------------------------------------
- handleToolStart(tool: any, input: string, runId: string, parentRunId?: string) {
+ handleToolStart(tool: any, input: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: any, kwargs?: any) {
try {
- const id: string[] = tool?.id || [];
- const name = tool?.name || tool?.kwargs?.name || id[id.length - 1] || 'unknown';
+ const name = this._getNameFromCallback(tool, kwargs || {});
const spanName = `execute_tool ${name}`;
- const parentCtx = this._getParentContext(parentRunId);
- const span = this.tracer.startSpan(
- spanName,
- { kind: SpanKind.INTERNAL },
- parentCtx
- );
+ const span = this._createSpan(runId, parentRunId, spanName);
+ const holder = this._newHolder(span, parentRunId);
+ this.spans.set(runId, holder);
+
+ if (parentRunId) {
+ const parentResolved = this._resolveParentRunId(parentRunId);
+ if (parentResolved && this.spans.has(parentResolved)) {
+ this.spans.get(parentResolved)!.children.push(runId);
+ }
+ }
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS);
- span.setAttribute(SemanticConvention.GEN_AI_ENVIRONMENT, OpenlitConfig.environment || '');
- span.setAttribute(SemanticConvention.GEN_AI_APPLICATION_NAME, OpenlitConfig.applicationName || '');
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
+ this._setCommonAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS);
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, name);
span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, 'function');
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, runId);
const description = tool?.description;
- if (description) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_DESCRIPTION, String(description));
- }
+ if (description) span.setAttribute(SemanticConvention.GEN_AI_TOOL_DESCRIPTION, String(description));
- if (OpenlitConfig.traceContent && input) {
+ const convId = resolveConversationId(metadata);
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+
+ if (OpenlitConfig.captureMessageContent && input) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, String(input).slice(0, 2000));
}
- this.spans.set(runId, {
- span,
- startTime: Date.now(),
- modelName: name,
- parentRunId,
- streamingContent: [],
- tokenTimestamps: [],
- promptTokens: 0,
- completionTokens: 0,
- });
+ applyCustomSpanAttributes(span);
} catch { /* non-blocking */ }
}
@@ -455,60 +1134,61 @@ class OpenLITCallbackHandler {
if (!holder) return;
const duration = (Date.now() - holder.startTime) / 1000;
holder.span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- if (OpenlitConfig.traceContent && output) {
+
+ // Extract tool_call_id from output if available
+ if (output?.tool_call_id) {
+ holder.span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, output.tool_call_id);
+ }
+
+ if (OpenlitConfig.captureMessageContent && output) {
holder.span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, String(output).slice(0, 2000));
}
- holder.span.setStatus({ code: 1 });
- holder.span.end();
- this.spans.delete(runId);
+
+ this._endSpan(runId);
} catch { /* non-blocking */ }
}
handleToolError(error: any, runId: string) {
try {
- const holder = this.spans.get(runId);
- if (!holder) return;
- OpenLitHelper.handleException(holder.span, error);
- holder.span.end();
- this.spans.delete(runId);
+ if (this.spans.has(runId)) {
+ const span = this.spans.get(runId)!.span;
+ const errorType = error?.constructor?.name || '_OTHER';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ }
+ this._endSpan(runId, String(error));
} catch { /* non-blocking */ }
}
- // ---- Retriever callbacks ---------------------------------------------------
+ // ---- Retriever Callbacks -----------------------------------------------
- handleRetrieverStart(retriever: any, query: string, runId: string, parentRunId?: string) {
+ handleRetrieverStart(retriever: any, query: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: any, kwargs?: any) {
try {
- const id: string[] = retriever?.id || [];
- const name = retriever?.name || retriever?.kwargs?.name || id[id.length - 1] || 'unknown';
+ const name = this._getNameFromCallback(retriever, kwargs || {});
const spanName = `retrieval ${name}`;
- const parentCtx = this._getParentContext(parentRunId);
- const span = this.tracer.startSpan(
- spanName,
- { kind: SpanKind.CLIENT },
- parentCtx
- );
+ const span = this._createSpan(runId, parentRunId, spanName, SpanKind.CLIENT);
+ const holder = this._newHolder(span, parentRunId);
+ this.spans.set(runId, holder);
+
+ if (parentRunId) {
+ const parentResolved = this._resolveParentRunId(parentRunId);
+ if (parentResolved && this.spans.has(parentResolved)) {
+ this.spans.get(parentResolved)!.children.push(runId);
+ }
+ }
- span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE);
- span.setAttribute(SemanticConvention.GEN_AI_ENVIRONMENT, OpenlitConfig.environment || '');
- span.setAttribute(SemanticConvention.GEN_AI_APPLICATION_NAME, OpenlitConfig.applicationName || '');
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN);
+ this._setCommonAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE);
span.setAttribute(SemanticConvention.GEN_AI_DATA_SOURCE_ID, name);
- if (OpenlitConfig.traceContent && query) {
+ const convId = resolveConversationId(metadata);
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+
+ if (OpenlitConfig.captureMessageContent && query) {
span.setAttribute(SemanticConvention.GEN_AI_RETRIEVAL_QUERY_TEXT, String(query).slice(0, 2000));
}
- this.spans.set(runId, {
- span,
- startTime: Date.now(),
- modelName: name,
- parentRunId,
- streamingContent: [],
- tokenTimestamps: [],
- promptTokens: 0,
- completionTokens: 0,
- });
+ applyCustomSpanAttributes(span);
} catch { /* non-blocking */ }
}
@@ -520,10 +1200,10 @@ class OpenLITCallbackHandler {
holder.span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
holder.span.setAttribute(SemanticConvention.GEN_AI_RETRIEVAL_DOCUMENT_COUNT, documents?.length || 0);
- if (OpenlitConfig.traceContent && documents?.length > 0) {
+ if (OpenlitConfig.captureMessageContent && documents?.length > 0) {
const structured = documents.slice(0, 3).map((doc: any) => {
const content = doc?.pageContent || doc?.page_content || String(doc);
- const entry: Record<string, string> = { content: content.slice(0, 2000) };
+ const entry: Record<string, string> = { content: String(content).slice(0, 2000) };
const meta = doc?.metadata;
if (meta) {
const docId = meta.id || meta.source;
@@ -534,45 +1214,83 @@ class OpenLITCallbackHandler {
holder.span.setAttribute(SemanticConvention.GEN_AI_RETRIEVAL_DOCUMENTS, JSON.stringify(structured));
}
- holder.span.setStatus({ code: 1 });
- holder.span.end();
- this.spans.delete(runId);
+ this._endSpan(runId);
} catch { /* non-blocking */ }
}
handleRetrieverError(error: any, runId: string) {
+ try {
+ if (this.spans.has(runId)) {
+ const span = this.spans.get(runId)!.span;
+ const errorType = error?.constructor?.name || '_OTHER';
+ span.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ }
+ this._endSpan(runId, String(error));
+ } catch { /* non-blocking */ }
+ }
+
+ // ---- Agent Callbacks ---------------------------------------------------
+
+ handleAgentAction(action: any, runId: string) {
try {
const holder = this.spans.get(runId);
if (!holder) return;
- OpenLitHelper.handleException(holder.span, error);
- holder.span.end();
- this.spans.delete(runId);
+ holder.span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT);
+ if (OpenlitConfig.captureMessageContent) {
+ const tool = action?.tool ?? String(action);
+ const toolInput = action?.tool_input ?? '';
+ const log = action?.log ?? '';
+ holder.span.setAttribute(SemanticConvention.GEN_AI_AGENT_ACTION_TOOL, String(tool).slice(0, 2000));
+ holder.span.setAttribute(SemanticConvention.GEN_AI_AGENT_ACTION_TOOL_INPUT, String(toolInput).slice(0, 2000));
+ if (log) holder.span.setAttribute(SemanticConvention.GEN_AI_AGENT_ACTION_LOG, String(log).slice(0, 2000));
+ }
+ } catch { /* non-blocking */ }
+ }
+
+ handleAgentFinish(finish: any, runId: string) {
+ try {
+ const holder = this.spans.get(runId);
+ if (!holder) return;
+ if (OpenlitConfig.captureMessageContent) {
+ const output = finish?.return_values ?? String(finish);
+ const log = finish?.log ?? '';
+ holder.span.setAttribute(SemanticConvention.GEN_AI_AGENT_FINISH_OUTPUT, String(output).slice(0, 2000));
+ if (log) holder.span.setAttribute(SemanticConvention.GEN_AI_AGENT_FINISH_LOG, String(log).slice(0, 2000));
+ }
} catch { /* non-blocking */ }
}
}
-// ----------------------------------------------------------------------------
-// Wrapper factory
-// ----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// Wrapper factory that patches CallbackManager._configureSync
+// ---------------------------------------------------------------------------
class LangChainWrapper extends BaseWrapper {
static _patchConfigure(tracer: Tracer): any {
- // Ensure singleton handler
if (!handlerInstance) {
handlerInstance = new OpenLITCallbackHandler(tracer);
}
const handler = handlerInstance;
+ /**
+ * The LLM call itself must run inside runWithFrameworkLlm() so that
+ * provider wrappers (OpenAI, Anthropic, etc.) skip their own span
+ * creation. We achieve this by wrapping _configureSync: when
+ * LangChain configures callbacks for an LLM call, the callback
+ * handler's handleChatModelStart/handleLLMStart already sets the
+ * suppression flag via the span holder. But to actually suppress
+ * the provider wrapper, we need the flag in the AsyncLocalStorage
+ * context of the LLM call. Since LangChain doesn't give us a
+ * hook around the actual LLM invocation, we rely on the provider
+ * wrappers checking isFrameworkLlmActive() which is set during
+ * the configure phase and active throughout the call chain.
+ */
return (originalConfigure: (...args: any[]) => any) => {
return function (
this: any,
inheritableHandlers?: any,
...rest: any[]
) {
- // inheritableHandlers can be:
- // - undefined : no handlers passed
- // - Array : list of handler objects (chat model calls)
- // - CallbackManager instance: already-built manager (Runnable/chain calls)
if (Array.isArray(inheritableHandlers) || !inheritableHandlers) {
const handlers: any[] = inheritableHandlers ? [...inheritableHandlers] : [];
if (!handlers.some((h: any) => h?.name === 'openlit_callback_handler')) {
@@ -580,7 +1298,6 @@ class LangChainWrapper extends BaseWrapper {
}
return originalConfigure.call(this, handlers, ...rest);
} else {
- // Existing CallbackManager — add our handler directly
const cbManager = inheritableHandlers;
if (cbManager?.handlers && !cbManager.handlers.some((h: any) => h?.name === 'openlit_callback_handler')) {
cbManager.addHandler(handler, true);
@@ -592,5 +1309,5 @@ class LangChainWrapper extends BaseWrapper {
}
}
+export { OpenLITCallbackHandler, runWithFrameworkLlm };
export default LangChainWrapper;
-export { OpenLITCallbackHandler };
diff --git a/sdk/typescript/src/instrumentation/langgraph/index.ts b/sdk/typescript/src/instrumentation/langgraph/index.ts
new file mode 100644
index 00000000..ccf36a0a
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/langgraph/index.ts
@@ -0,0 +1,116 @@
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+ isWrapped,
+} from '@opentelemetry/instrumentation';
+import { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import LangGraphWrapper from './wrapper';
+
+export interface LangGraphInstrumentationConfig extends InstrumentationConfig {}
+
+export default class OpenlitLangGraphInstrumentation extends InstrumentationBase {
+ constructor(config: LangGraphInstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-langgraph`, '1.0.0', config);
+ }
+
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
+ const module = new InstrumentationNodeModuleDefinition(
+ '@langchain/langgraph',
+ ['>=0.0.31'],
+ (moduleExports) => {
+ this._patch(moduleExports);
+ return moduleExports;
+ },
+ (moduleExports) => {
+ if (moduleExports !== undefined) {
+ this._unpatch(moduleExports);
+ }
+ }
+ );
+
+ return [module];
+ }
+
+ public manualPatch(langgraph: any): void {
+ this._patch(langgraph);
+ }
+
+ protected _patch(moduleExports: any) {
+ try {
+ const StateGraph = moduleExports.StateGraph;
+ if (StateGraph?.prototype) {
+ if (StateGraph.prototype.compile) {
+ if (isWrapped(StateGraph.prototype.compile)) {
+ this._unwrap(StateGraph.prototype, 'compile');
+ }
+ this._wrap(
+ StateGraph.prototype,
+ 'compile',
+ LangGraphWrapper._patchCompile(this.tracer)
+ );
+ }
+
+ if (StateGraph.prototype.addNode) {
+ if (isWrapped(StateGraph.prototype.addNode)) {
+ this._unwrap(StateGraph.prototype, 'addNode');
+ }
+ this._wrap(
+ StateGraph.prototype,
+ 'addNode',
+ LangGraphWrapper._patchAddNode(this.tracer)
+ );
+ }
+ }
+
+ // Pregel is the compiled graph runtime — patch invoke and stream.
+ // It may be exported directly or available on CompiledStateGraph.
+ const Pregel = moduleExports.Pregel;
+ if (Pregel?.prototype) {
+ this._patchPregelProto(Pregel.prototype);
+ }
+
+ const CompiledStateGraph = moduleExports.CompiledStateGraph;
+ if (CompiledStateGraph?.prototype) {
+ this._patchPregelProto(CompiledStateGraph.prototype);
+ }
+ } catch { /* graceful degradation */ }
+ }
+
+ private _patchPregelProto(proto: any): void {
+ if (proto.invoke) {
+ if (isWrapped(proto.invoke)) {
+ this._unwrap(proto, 'invoke');
+ }
+ this._wrap(proto, 'invoke', LangGraphWrapper._patchInvoke(this.tracer));
+ }
+
+ if (proto.stream) {
+ if (isWrapped(proto.stream)) {
+ this._unwrap(proto, 'stream');
+ }
+ this._wrap(proto, 'stream', LangGraphWrapper._patchStream(this.tracer));
+ }
+ }
+
+ protected _unpatch(moduleExports: any) {
+ try {
+ const StateGraph = moduleExports.StateGraph;
+ if (StateGraph?.prototype) {
+ if (isWrapped(StateGraph.prototype.compile)) this._unwrap(StateGraph.prototype, 'compile');
+ if (isWrapped(StateGraph.prototype.addNode)) this._unwrap(StateGraph.prototype, 'addNode');
+ }
+ const Pregel = moduleExports.Pregel;
+ if (Pregel?.prototype) {
+ if (isWrapped(Pregel.prototype.invoke)) this._unwrap(Pregel.prototype, 'invoke');
+ if (isWrapped(Pregel.prototype.stream)) this._unwrap(Pregel.prototype, 'stream');
+ }
+ const CompiledStateGraph = moduleExports.CompiledStateGraph;
+ if (CompiledStateGraph?.prototype) {
+ if (isWrapped(CompiledStateGraph.prototype.invoke)) this._unwrap(CompiledStateGraph.prototype, 'invoke');
+ if (isWrapped(CompiledStateGraph.prototype.stream)) this._unwrap(CompiledStateGraph.prototype, 'stream');
+ }
+ } catch { /* ignore */ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/langgraph/wrapper.ts b/sdk/typescript/src/instrumentation/langgraph/wrapper.ts
new file mode 100644
index 00000000..2e1ebee0
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/langgraph/wrapper.ts
@@ -0,0 +1,642 @@
+import {
+ Tracer,
+ SpanKind,
+ context,
+ trace,
+ SpanContext,
+ Link,
+ SpanStatusCode,
+} from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, { applyCustomSpanAttributes } from '../../helpers';
+import {
+ runWithLangGraph,
+ runWithCreateAgent,
+ isCreateAgentActive,
+ getLangGraphConversationId,
+ runWithLangGraphConversationId,
+} from '../../helpers';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
+
+// ---------------------------------------------------------------------------
+// Helpers
+// ---------------------------------------------------------------------------
+
+function getGraphName(instance: any): string {
+ if (!instance) return 'graph';
+ const name = instance.name;
+ if (name) return String(name);
+ const graphId = instance.graph_id ?? instance.graphId;
+ if (graphId) return String(graphId);
+ const className = instance.constructor?.name;
+ if (className && !['Pregel', 'CompiledStateGraph', 'StateGraph'].includes(className)) {
+ return className;
+ }
+ return 'graph';
+}
+
+function extractConfigInfo(config: any): { threadId?: string; checkpointId?: string } {
+ const info: { threadId?: string; checkpointId?: string } = {};
+ if (!config || typeof config !== 'object') return info;
+ try {
+ const configurable = config.configurable;
+ if (configurable && typeof configurable === 'object') {
+ if (configurable.thread_id != null) info.threadId = String(configurable.thread_id);
+ if (configurable.checkpoint_id != null) info.checkpointId = String(configurable.checkpoint_id);
+ }
+ } catch { /* ignore */ }
+ return info;
+}
+
+function isToolNode(nodeName: string, action: any): boolean {
+ const typeName = action?.constructor?.name || '';
+ if (typeName.includes('ToolNode')) return true;
+ if (action?.func && (action.func.constructor?.name || '').includes('ToolNode')) return true;
+ const lower = nodeName.toLowerCase();
+ if (lower.includes('tool') && !lower.includes('agent')) return true;
+ return false;
+}
+
+function setCommonSpanAttributes(
+ span: any,
+ operationType: string,
+): void {
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment || 'default');
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName || 'default');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operationType);
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, SemanticConvention.GEN_AI_SYSTEM_LANGGRAPH);
+}
+
+function extractGraphStructure(instance: any): { nodes: string[]; edges: string[] } {
+ const nodes: string[] = [];
+ const edges: string[] = [];
+ try {
+ if (instance.nodes) {
+ const n = instance.nodes;
+ if (typeof n.keys === 'function') {
+ for (const k of n.keys()) nodes.push(String(k));
+ } else if (typeof n === 'object') {
+ for (const k of Object.keys(n)) nodes.push(k);
+ }
+ }
+ if (instance.edges) {
+ const edgeSet = instance.edges;
+ if (edgeSet instanceof Set || Array.isArray(edgeSet)) {
+ for (const edge of edgeSet) {
+ if (Array.isArray(edge) && edge.length >= 2) {
+ edges.push(`${edge[0]}->${edge[1]}`);
+ }
+ }
+ } else if (typeof edgeSet === 'object') {
+ for (const [source, targets] of Object.entries(edgeSet as Record<string, any>)) {
+ if (typeof targets === 'object' && targets !== null) {
+ if (Array.isArray(targets)) {
+ for (const t of targets) edges.push(`${source}->${t}`);
+ } else if (targets instanceof Set) {
+ for (const t of targets) edges.push(`${source}->${t}`);
+ } else {
+ for (const t of Object.values(targets)) edges.push(`${source}->${t}`);
+ }
+ }
+ }
+ }
+ }
+ } catch { /* ignore */ }
+ return { nodes, edges };
+}
+
+function setGraphAttributes(span: any, nodes: string[], edges: string[]): void {
+ if (nodes.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_NODES, JSON.stringify(nodes));
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_NODE_COUNT, nodes.length);
+ }
+ if (edges.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_EDGES, JSON.stringify(edges));
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_EDGE_COUNT, edges.length);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Re-entry suppression via OTel context (mirrors Python _LANGGRAPH_SUPPRESS_KEY)
+// ---------------------------------------------------------------------------
+
+const LANGGRAPH_SUPPRESS_SYMBOL = Symbol.for('openlit-langgraph-suppress');
+
+function isLangGraphSuppressed(): boolean {
+ return context.active().getValue(LANGGRAPH_SUPPRESS_SYMBOL) === true;
+}
+
+function withLangGraphSuppression<T>(fn: () => T): T {
+ const ctx = context.active().setValue(LANGGRAPH_SUPPRESS_SYMBOL, true);
+ return context.with(ctx, fn);
+}
+
+// ---------------------------------------------------------------------------
+// Wrapper factory
+// ---------------------------------------------------------------------------
+
+export default class LangGraphWrapper {
+ /**
+ * Wrap Pregel.prototype.invoke — creates an invoke_workflow span.
+ */
+ static _patchInvoke(tracer: Tracer): any {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isLangGraphSuppressed()) return originalMethod.apply(this, args);
+
+ const graphName = getGraphName(this);
+ const spanName = `invoke_workflow ${graphName}`;
+ const links: Link[] = [];
+ const creationCtx: SpanContext | undefined = this._openlit_creation_context;
+ if (creationCtx) links.push({ context: creationCtx, attributes: {} });
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_LANGGRAPH,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ setCommonSpanAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK);
+ span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, graphName);
+ span.setAttribute(SemanticConvention.GEN_AI_EXECUTION_MODE, 'invoke');
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+
+ const config = args[1] ?? (typeof args[0] === 'object' && args[0]?.configurable ? args[0] : undefined);
+ const configInfo = extractConfigInfo(config);
+ if (configInfo.threadId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, configInfo.threadId);
+ if (configInfo.checkpointId) span.setAttribute(SemanticConvention.GEN_AI_CHECKPOINT_ID, configInfo.checkpointId);
+
+ const { nodes, edges } = extractGraphStructure(this);
+ setGraphAttributes(span, nodes, edges);
+
+ const execute = () => withLangGraphSuppression(() =>
+ runWithLangGraph(() => {
+ const convId = configInfo.threadId;
+ if (convId) {
+ return runWithLangGraphConversationId(convId, () => originalMethod.apply(this, args));
+ }
+ return originalMethod.apply(this, args);
+ })
+ );
+
+ try {
+ const result = execute();
+ if (result && typeof result.then === 'function') {
+ return result
+ .then((response: any) => {
+ finalizeInvokeSpan(span, response, startTime);
+ return response;
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ });
+ }
+ finalizeInvokeSpan(span, result, startTime);
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ });
+ };
+ };
+ }
+
+ /**
+ * Wrap Pregel.prototype.stream — creates an invoke_workflow span with stream mode.
+ */
+ static _patchStream(tracer: Tracer): any {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isLangGraphSuppressed()) return originalMethod.apply(this, args);
+
+ const graphName = getGraphName(this);
+ const spanName = `invoke_workflow ${graphName}`;
+ const links: Link[] = [];
+ const creationCtx: SpanContext | undefined = this._openlit_creation_context;
+ if (creationCtx) links.push({ context: creationCtx, attributes: {} });
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_LANGGRAPH,
+ },
+ });
+
+ const parentCtx = trace.setSpan(context.active(), span);
+
+ return context.with(parentCtx, () => {
+ const startTime = Date.now();
+ setCommonSpanAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK);
+ span.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, graphName);
+ span.setAttribute(SemanticConvention.GEN_AI_EXECUTION_MODE, 'stream');
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
+
+ const config = args[1] ?? undefined;
+ const configInfo = extractConfigInfo(config);
+ if (configInfo.threadId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, configInfo.threadId);
+ if (configInfo.checkpointId) span.setAttribute(SemanticConvention.GEN_AI_CHECKPOINT_ID, configInfo.checkpointId);
+
+ const { nodes, edges } = extractGraphStructure(this);
+ setGraphAttributes(span, nodes, edges);
+
+ const executionState = {
+ executedNodes: [] as string[],
+ chunkCount: 0,
+ };
+
+ try {
+ const result = withLangGraphSuppression(() =>
+ runWithLangGraph(() => {
+ const convId = configInfo.threadId;
+ if (convId) {
+ return runWithLangGraphConversationId(convId, () => originalMethod.apply(this, args));
+ }
+ return originalMethod.apply(this, args);
+ })
+ );
+
+ if (result && typeof result[Symbol.asyncIterator] === 'function') {
+ return wrapAsyncIterableStream(result, span, executionState, startTime);
+ }
+ if (result && typeof result[Symbol.iterator] === 'function') {
+ return wrapSyncIterableStream(result, span, executionState, startTime);
+ }
+
+ finalizeStreamSpan(span, executionState, startTime);
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ });
+ };
+ };
+ }
+
+ /**
+ * Wrap StateGraph.prototype.compile — creates a create_agent span.
+ */
+ static _patchCompile(tracer: Tracer): any {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ if (isCreateAgentActive()) return originalMethod.apply(this, args);
+
+ const graphName = getGraphName(this);
+ const agentName = (graphName === 'graph' || graphName === 'LangGraph') ? 'default' : graphName;
+ const spanName = `create_agent ${agentName}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_LANGGRAPH,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ try {
+ const result = runWithCreateAgent(() => originalMethod.apply(this, args));
+
+ setCommonSpanAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT);
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, agentName);
+
+ const { nodes, edges } = extractGraphStructure(this);
+ setGraphAttributes(span, nodes, edges);
+
+ if (nodes.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_DEFINITIONS, JSON.stringify(nodes));
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, `Agent with nodes: ${nodes.join(', ')}`);
+ } else {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, 'LangGraph agent');
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (Date.now() - startTime) / 1000);
+ span.setStatus({ code: SpanStatusCode.OK });
+ applyCustomSpanAttributes(span);
+
+ if (result && typeof result === 'object') {
+ result._openlit_creation_context = span.spanContext();
+ }
+
+ span.end();
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ });
+ };
+ };
+ }
+
+ /**
+ * Wrap StateGraph.prototype.addNode — wraps node callables
+ * to create invoke_agent spans per node execution.
+ */
+ static _patchAddNode(tracer: Tracer): any {
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const nodeKey = args[0];
+ const action = args[1];
+
+ if (!action || typeof action !== 'function') {
+ return originalMethod.apply(this, args);
+ }
+
+ const nodeName = typeof nodeKey === 'string' ? nodeKey : String(nodeKey);
+
+ if (isToolNode(nodeName, action)) {
+ return originalMethod.apply(this, args);
+ }
+
+ const wrappedAction = createWrappedNode(tracer, action, nodeName);
+ const newArgs = [args[0], wrappedAction, ...args.slice(2)];
+ return originalMethod.apply(this, newArgs);
+ };
+ };
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Node wrapper — creates invoke_agent spans for each node execution
+// ---------------------------------------------------------------------------
+
+function createWrappedNode(tracer: Tracer, originalFunc: any, nodeName: string): any {
+ if (originalFunc._openlit_wrapped) return originalFunc;
+
+ const wrapped = function (this: any, state: any, ...nodeArgs: any[]) {
+ const spanName = `invoke_agent ${nodeName}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_LANGGRAPH,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ setCommonSpanAttributes(span, SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT);
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, nodeName);
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_ID, nodeName);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+
+ const convId = getLangGraphConversationId();
+ if (convId) span.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, convId);
+ applyCustomSpanAttributes(span);
+
+ try {
+ const result = originalFunc.call(this, state, ...nodeArgs);
+ if (result && typeof result.then === 'function') {
+ return result
+ .then((res: any) => {
+ extractLlmInfoFromResult(span, state, res);
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (Date.now() - startTime) / 1000);
+ span.setStatus({ code: SpanStatusCode.OK });
+ span.end();
+ return res;
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ });
+ }
+ extractLlmInfoFromResult(span, state, result);
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (Date.now() - startTime) / 1000);
+ span.setStatus({ code: SpanStatusCode.OK });
+ span.end();
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ });
+ };
+
+ wrapped._openlit_wrapped = true;
+ Object.defineProperty(wrapped, 'name', { value: originalFunc.name || nodeName });
+ return wrapped;
+}
+
+// ---------------------------------------------------------------------------
+// Response processing helpers
+// ---------------------------------------------------------------------------
+
+function finalizeInvokeSpan(span: any, response: any, startTime: number): void {
+ try {
+ if (response && typeof response === 'object' && response.messages) {
+ const messages = response.messages;
+ if (Array.isArray(messages)) {
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_MESSAGE_COUNT, messages.length);
+ }
+ }
+ } catch { /* ignore */ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_STATUS, 'success');
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (Date.now() - startTime) / 1000);
+ span.setStatus({ code: SpanStatusCode.OK });
+ applyCustomSpanAttributes(span);
+ span.end();
+}
+
+function finalizeStreamSpan(
+ span: any,
+ executionState: { executedNodes: string[]; chunkCount: number },
+ startTime: number
+): void {
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_EXECUTED_NODES, JSON.stringify(executionState.executedNodes));
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_TOTAL_CHUNKS, executionState.chunkCount);
+ span.setAttribute(SemanticConvention.GEN_AI_GRAPH_STATUS, 'success');
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, (Date.now() - startTime) / 1000);
+ span.setStatus({ code: SpanStatusCode.OK });
+ applyCustomSpanAttributes(span);
+ span.end();
+}
+
+function processStreamChunk(
+ chunk: any,
+ executionState: { executedNodes: string[]; chunkCount: number }
+): void {
+ executionState.chunkCount++;
+ try {
+ if (chunk && typeof chunk === 'object' && !Array.isArray(chunk)) {
+ for (const key of Object.keys(chunk)) {
+ if (!['__start__', '__end__', '__interrupt__'].includes(key)) {
+ if (!executionState.executedNodes.includes(key)) {
+ executionState.executedNodes.push(key);
+ }
+ }
+ }
+ }
+ if (Array.isArray(chunk) && chunk.length >= 2 && typeof chunk[0] === 'string') {
+ const nodeName = chunk[0];
+ if (!['__start__', '__end__', '__interrupt__'].includes(nodeName)) {
+ if (!executionState.executedNodes.includes(nodeName)) {
+ executionState.executedNodes.push(nodeName);
+ }
+ }
+ }
+ } catch { /* ignore */ }
+}
+
+function wrapAsyncIterableStream(
+ stream: AsyncIterable<any>,
+ span: any,
+ executionState: { executedNodes: string[]; chunkCount: number },
+ startTime: number
+): AsyncIterable<any> {
+ const originalIterator = stream[Symbol.asyncIterator].bind(stream);
+ return {
+ [Symbol.asyncIterator]() {
+ const iter = originalIterator();
+ return {
+ async next() {
+ try {
+ const result = await iter.next();
+ if (result.done) {
+ finalizeStreamSpan(span, executionState, startTime);
+ return result;
+ }
+ processStreamChunk(result.value, executionState);
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ },
+ async return(value?: any) {
+ finalizeStreamSpan(span, executionState, startTime);
+ return iter.return ? iter.return(value) : { done: true as const, value };
+ },
+ async throw(e?: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ return iter.throw ? iter.throw(e) : { done: true as const, value: undefined };
+ },
+ };
+ },
+ } as AsyncIterable<any>;
+}
+
+function wrapSyncIterableStream(
+ stream: Iterable<any>,
+ span: any,
+ executionState: { executedNodes: string[]; chunkCount: number },
+ startTime: number
+): Iterable<any> {
+ const originalIterator = stream[Symbol.iterator].bind(stream);
+ return {
+ [Symbol.iterator]() {
+ const iter = originalIterator();
+ return {
+ next() {
+ try {
+ const result = iter.next();
+ if (result.done) {
+ finalizeStreamSpan(span, executionState, startTime);
+ return result;
+ }
+ processStreamChunk(result.value, executionState);
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ throw e;
+ }
+ },
+ return(value?: any) {
+ finalizeStreamSpan(span, executionState, startTime);
+ return iter.return ? iter.return(value) : { done: true as const, value };
+ },
+ throw(e?: any) {
+ OpenLitHelper.handleException(span, e);
+ span.end();
+ return iter.throw ? iter.throw(e) : { done: true as const, value: undefined };
+ },
+ };
+ },
+ } as Iterable<any>;
+}
+
+// ---------------------------------------------------------------------------
+// LLM info extraction from node results (matching Python extract_llm_info_from_result)
+// ---------------------------------------------------------------------------
+
+function extractLlmInfoFromResult(span: any, _state: any, result: any): void {
+ try {
+ if (!result || typeof result !== 'object') return;
+ const messages = result.messages;
+ if (!messages || !Array.isArray(messages) || messages.length === 0) return;
+
+ const lastMsg = messages[messages.length - 1];
+ if (!lastMsg) return;
+
+ if (lastMsg.response_metadata && typeof lastMsg.response_metadata === 'object') {
+ const metadata = lastMsg.response_metadata;
+ const modelName = metadata.model_name || metadata.model;
+ if (modelName) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelName);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelName);
+ }
+ const tokenUsage = metadata.token_usage;
+ if (tokenUsage && typeof tokenUsage === 'object') {
+ if (tokenUsage.prompt_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, tokenUsage.prompt_tokens);
+ }
+ if (tokenUsage.completion_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, tokenUsage.completion_tokens);
+ }
+ }
+ if (metadata.finish_reason) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [metadata.finish_reason]);
+ }
+ if (metadata.id) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, metadata.id);
+ }
+ }
+
+ if (lastMsg.usage_metadata && typeof lastMsg.usage_metadata === 'object') {
+ const usage = lastMsg.usage_metadata;
+ if (usage.input_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, usage.input_tokens);
+ }
+ if (usage.output_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, usage.output_tokens);
+ }
+ }
+
+ if (lastMsg.content != null) {
+ const content = typeof lastMsg.content === 'string'
+ ? lastMsg.content
+ : JSON.stringify(lastMsg.content);
+ if (content && OpenlitConfig.captureMessageContent) {
+ const role = lastMsg.role || lastMsg._getType?.() || lastMsg.type || 'assistant';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ JSON.stringify([{ role, parts: [{ type: 'text', content }] }])
+ );
+ }
+ }
+ } catch { /* don't fail the span */ }
+}
diff --git a/sdk/typescript/src/instrumentation/llamaindex/index.ts b/sdk/typescript/src/instrumentation/llamaindex/index.ts
index 1cf7e036..b393faeb 100644
--- a/sdk/typescript/src/instrumentation/llamaindex/index.ts
+++ b/sdk/typescript/src/instrumentation/llamaindex/index.ts
@@ -1,22 +1,34 @@
+/**
+ * OpenLIT LlamaIndex Instrumentation
+ *
+ * Monkey-patches LlamaIndex JS classes to emit OTel-compliant telemetry.
+ * Mirrors the Python SDK: sdk/python/src/openlit/instrumentation/llamaindex/__init__.py
+ *
+ * Targets the `llamaindex` npm package (>=0.3.0).
+ * Patches: LLM classes, query engines, chat engines, retrievers, embeddings,
+ * index construction, document loaders, splitters, and synthesizers.
+ */
+
import {
InstrumentationBase,
InstrumentationModuleDefinition,
InstrumentationNodeModuleDefinition,
isWrapped,
} from '@opentelemetry/instrumentation';
-import { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { INSTRUMENTATION_PREFIX } from '../../constant';
import LlamaIndexWrapper from './wrapper';
-export interface LlamaIndexInstrumentationConfig extends InstrumentationConfig {}
-
export default class OpenlitLlamaIndexInstrumentation extends InstrumentationBase {
- constructor(config: LlamaIndexInstrumentationConfig = {}) {
+ constructor(config: InstrumentationConfig = {}) {
super(`${INSTRUMENTATION_PREFIX}/instrumentation-llamaindex`, '1.0.0', config);
}
- protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
- const module = new InstrumentationNodeModuleDefinition(
+ protected init():
+ | void
+ | InstrumentationModuleDefinition
+ | InstrumentationModuleDefinition[] {
+ const mainModule = new InstrumentationNodeModuleDefinition(
'llamaindex',
['>=0.3.0'],
(moduleExports) => {
@@ -24,106 +36,252 @@ export default class OpenlitLlamaIndexInstrumentation extends InstrumentationBas
return moduleExports;
},
(moduleExports) => {
- if (moduleExports !== undefined) {
- this._unpatch(moduleExports);
- }
- }
+ if (moduleExports) this._unpatch(moduleExports);
+ },
);
- return [module];
+
+ return [mainModule];
}
public manualPatch(llamaindex: any): void {
this._patch(llamaindex);
}
- protected _patch(moduleExports: any) {
+ // ---------------------------------------------------------------------------
+ // Patch helpers
+ // ---------------------------------------------------------------------------
+
+ /**
+ * Wrap an instance method on the first class found that exposes it.
+ * Silently skips classes that aren't exported or don't have the method.
+ */
+ private _patchProto(
+ moduleExports: any,
+ classNames: string[],
+ method: string,
+ wrapper: any,
+ ): void {
+ for (const name of classNames) {
+ const Cls = moduleExports[name];
+ if (Cls?.prototype?.[method] && !isWrapped(Cls.prototype[method])) {
+ try {
+ this._wrap(Cls.prototype, method, wrapper);
+ } catch { /* skip silently */ }
+ }
+ }
+ }
+
+ /**
+ * Wrap a static method on a class.
+ */
+ private _patchStatic(
+ Cls: any,
+ method: string,
+ wrapper: any,
+ ): void {
+ if (typeof Cls?.[method] === 'function' && !isWrapped(Cls[method])) {
+ try {
+ this._wrap(Cls, method, wrapper);
+ } catch { /* skip silently */ }
+ }
+ }
+
+ /**
+ * Unwrap an instance method if it's wrapped.
+ */
+ private _unwrapProto(
+ moduleExports: any,
+ classNames: string[],
+ method: string,
+ ): void {
+ for (const name of classNames) {
+ const Cls = moduleExports[name];
+ if (Cls?.prototype?.[method] && isWrapped(Cls.prototype[method])) {
+ try {
+ this._unwrap(Cls.prototype, method);
+ } catch { /* ignore */ }
+ }
+ }
+ }
+
+ /**
+ * Unwrap a static method if it's wrapped.
+ */
+ private _unwrapStatic(Cls: any, method: string): void {
+ if (Cls && typeof Cls[method] === 'function' && isWrapped(Cls[method])) {
+ try {
+ this._unwrap(Cls, method);
+ } catch { /* ignore */ }
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+ // Main patch — mirrors Python _instrument() operation lists
+ // ---------------------------------------------------------------------------
+
+ protected _patch(m: any): void {
try {
- // Patch query engines
- const queryEngineClasses = [
- 'RetrieverQueryEngine',
- 'BaseQueryEngine',
- 'QueryEngine',
+ const tracer = this.tracer;
+
+ // === LLM OPERATIONS (chat spans) ===
+ // Mirrors Python: LLM.chat, LLM.complete
+ const llmClasses = [
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
+ 'BaseLLM', 'LLM',
];
+ this._patchProto(m, llmClasses, 'chat',
+ LlamaIndexWrapper._patchLLMChat(tracer));
+ this._patchProto(m, llmClasses, 'complete',
+ LlamaIndexWrapper._patchLLMComplete(tracer));
- for (const className of queryEngineClasses) {
- const QueryEngineClass = moduleExports[className];
- if (QueryEngineClass?.prototype?.query) {
- if (isWrapped(QueryEngineClass.prototype.query)) {
- this._unwrap(QueryEngineClass.prototype, 'query');
- }
- this._wrap(
- QueryEngineClass.prototype,
- 'query',
- LlamaIndexWrapper._patchQueryEngineQuery(this.tracer)
- );
- break; // Only patch the first one found to avoid duplicates
- }
- }
+ // === QUERY ENGINE OPERATIONS (retrieval spans) ===
+ // Mirrors Python: RetrieverQueryEngine.query, TransformQueryEngine.query
+ const queryEngineClasses = [
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
+ ];
+ this._patchProto(m, queryEngineClasses, 'query',
+ LlamaIndexWrapper._patchQueryEngineQuery(tracer));
- // Patch chat engines
+ // === CHAT ENGINE OPERATIONS (invoke_workflow spans) ===
const chatEngineClasses = [
- 'ContextChatEngine',
- 'SimpleChatEngine',
- 'BaseChatEngine',
+ 'ContextChatEngine', 'SimpleChatEngine',
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
];
+ this._patchProto(m, chatEngineClasses, 'chat',
+ LlamaIndexWrapper._patchChatEngineChat(tracer));
- for (const className of chatEngineClasses) {
- const ChatEngineClass = moduleExports[className];
- if (ChatEngineClass?.prototype?.chat) {
- if (isWrapped(ChatEngineClass.prototype.chat)) {
- this._unwrap(ChatEngineClass.prototype, 'chat');
- }
- this._wrap(
- ChatEngineClass.prototype,
- 'chat',
- LlamaIndexWrapper._patchChatEngineChat(this.tracer)
- );
- break; // Only patch the first one found
- }
- }
+ // === RETRIEVER OPERATIONS (retrieval spans) ===
+ // Mirrors Python: VectorIndexRetriever.retrieve, BaseRetriever.retrieve
+ const retrieverClasses = [
+ 'VectorIndexRetriever', 'BaseRetriever', 'Retriever',
+ ];
+ this._patchProto(m, retrieverClasses, 'retrieve',
+ LlamaIndexWrapper._patchRetrieverRetrieve(tracer));
- // Patch base LLM chat and complete methods for lower-level tracing
- const llmClasses = ['OpenAI', 'Anthropic', 'Ollama', 'LLM', 'BaseLLM'];
- for (const className of llmClasses) {
- const LLMClass = moduleExports[className];
- if (!LLMClass?.prototype) continue;
-
- if (LLMClass.prototype.chat && !isWrapped(LLMClass.prototype.chat)) {
- this._wrap(
- LLMClass.prototype,
- 'chat',
- LlamaIndexWrapper._patchLLMChat(this.tracer)
- );
- }
- if (LLMClass.prototype.complete && !isWrapped(LLMClass.prototype.complete)) {
- this._wrap(
- LLMClass.prototype,
- 'complete',
- LlamaIndexWrapper._patchLLMComplete(this.tracer)
- );
+ // === EMBEDDING OPERATIONS (embeddings spans) ===
+ // Mirrors Python: BaseEmbedding.get_text_embedding_batch
+ const embeddingClasses = [
+ 'OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding',
+ ];
+ this._patchProto(m, embeddingClasses, 'getTextEmbedding',
+ LlamaIndexWrapper._patchEmbedding(tracer, 'embedding_generate'));
+ this._patchProto(m, embeddingClasses, 'getQueryEmbedding',
+ LlamaIndexWrapper._patchEmbedding(tracer, 'embedding_generate'));
+ this._patchProto(m, embeddingClasses, 'getTextEmbeddingsBatch',
+ LlamaIndexWrapper._patchEmbedding(tracer, 'embedding_generate'));
+
+ // === INDEX OPERATIONS (invoke_workflow spans) ===
+ // Mirrors Python: VectorStoreIndex.from_documents, from_vector_store
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
+ for (const name of indexClasses) {
+ const Cls = m[name];
+ if (Cls) {
+ this._patchStatic(Cls, 'fromDocuments',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'index_construct'));
+ this._patchStatic(Cls, 'fromVectorStore',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'index_construct'));
}
}
- } catch (e) {
- console.error('Error in LlamaIndex _patch method:', e);
- }
+
+ // Mirrors Python: BaseIndex.as_query_engine, BaseIndex.as_retriever
+ const indexProtoClasses = [
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
+ ];
+ this._patchProto(m, indexProtoClasses, 'asQueryEngine',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'query_engine_create'));
+ this._patchProto(m, indexProtoClasses, 'asRetriever',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'retriever_create'));
+
+ // === DOCUMENT OPERATIONS (framework / retrieval spans) ===
+ // Mirrors Python: SimpleDirectoryReader.load_data
+ this._patchProto(m, ['SimpleDirectoryReader'], 'loadData',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'document_load'));
+
+ // Mirrors Python: SentenceSplitter.get_nodes_from_documents
+ this._patchProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'document_split'));
+
+ // Mirrors Python: SentenceSplitter.split_text
+ this._patchProto(m, ['SentenceSplitter'], 'splitText',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'text_splitter_split'));
+
+ // === SYNTHESIZER OPERATIONS (chat spans) ===
+ // Mirrors Python: BaseSynthesizer.synthesize
+ const synthesizerClasses = [
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize',
+ 'BaseSynthesizer',
+ ];
+ this._patchProto(m, synthesizerClasses, 'synthesize',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'response_synthesize'));
+
+ // === POSTPROCESSOR OPERATIONS (framework spans) ===
+ this._patchProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes',
+ LlamaIndexWrapper._patchFrameworkMethod(tracer, 'postprocessor_process'));
+
+ } catch { /* graceful degradation — do not break the application */ }
}
- protected _unpatch(moduleExports: any) {
+ // ---------------------------------------------------------------------------
+ // Unpatch
+ // ---------------------------------------------------------------------------
+
+ protected _unpatch(m: any): void {
try {
- const allClasses = [
- 'RetrieverQueryEngine', 'BaseQueryEngine', 'QueryEngine',
- 'ContextChatEngine', 'SimpleChatEngine', 'BaseChatEngine',
- 'OpenAI', 'Anthropic', 'Ollama', 'LLM', 'BaseLLM',
+ const llmClasses = [
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
+ 'BaseLLM', 'LLM',
];
+ this._unwrapProto(m, llmClasses, 'chat');
+ this._unwrapProto(m, llmClasses, 'complete');
- for (const className of allClasses) {
- const Cls = moduleExports[className];
- if (Cls?.prototype) {
- if (isWrapped(Cls.prototype.query)) this._unwrap(Cls.prototype, 'query');
- if (isWrapped(Cls.prototype.chat)) this._unwrap(Cls.prototype, 'chat');
- if (isWrapped(Cls.prototype.complete)) this._unwrap(Cls.prototype, 'complete');
+ const queryEngineClasses = [
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
+ ];
+ this._unwrapProto(m, queryEngineClasses, 'query');
+
+ const chatEngineClasses = [
+ 'ContextChatEngine', 'SimpleChatEngine',
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
+ ];
+ this._unwrapProto(m, chatEngineClasses, 'chat');
+
+ const retrieverClasses = ['VectorIndexRetriever', 'BaseRetriever', 'Retriever'];
+ this._unwrapProto(m, retrieverClasses, 'retrieve');
+
+ const embeddingClasses = ['OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding'];
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbedding');
+ this._unwrapProto(m, embeddingClasses, 'getQueryEmbedding');
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbeddingsBatch');
+
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
+ for (const name of indexClasses) {
+ const Cls = m[name];
+ if (Cls) {
+ this._unwrapStatic(Cls, 'fromDocuments');
+ this._unwrapStatic(Cls, 'fromVectorStore');
}
}
+
+ const indexProtoClasses = [
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
+ ];
+ this._unwrapProto(m, indexProtoClasses, 'asQueryEngine');
+ this._unwrapProto(m, indexProtoClasses, 'asRetriever');
+
+ this._unwrapProto(m, ['SimpleDirectoryReader'], 'loadData');
+ this._unwrapProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments');
+ this._unwrapProto(m, ['SentenceSplitter'], 'splitText');
+
+ const synthesizerClasses = [
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize', 'BaseSynthesizer',
+ ];
+ this._unwrapProto(m, synthesizerClasses, 'synthesize');
+
+ this._unwrapProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes');
} catch { /* ignore */ }
}
}
diff --git a/sdk/typescript/src/instrumentation/llamaindex/wrapper.ts b/sdk/typescript/src/instrumentation/llamaindex/wrapper.ts
index fdb7b39d..c3aad874 100644
--- a/sdk/typescript/src/instrumentation/llamaindex/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/llamaindex/wrapper.ts
@@ -1,302 +1,846 @@
-import { SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+/**
+ * OpenLIT LlamaIndex Wrapper
+ *
+ * Mirrors Python SDK: sdk/python/src/openlit/instrumentation/llamaindex/
+ * Uses the same OPERATION_MAP and span semantics as the Python implementation.
+ *
+ * LLM operations get full provider-style telemetry (attributes, events, metrics).
+ * Framework operations (query engine, retriever, index, etc.) get framework-level spans.
+ */
+
+import { Tracer, SpanKind, context, trace, Span } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { runWithFrameworkLlm } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
-import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
-
-class LlamaIndexWrapper extends BaseWrapper {
- static aiSystem = 'llamaindex';
-
- // ---- Helpers ---------------------------------------------------------------
+import BaseWrapper from '../base-wrapper';
+
+/**
+ * Operation mapping matching Python SDK's OPERATION_MAP in
+ * sdk/python/src/openlit/instrumentation/llamaindex/utils.py
+ */
+const OPERATION_MAP: Record<string, string> = {
+ // Document Loading & Processing
+ document_load: SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE,
+ document_transform: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ document_split: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+
+ // Index Construction & Management
+ index_construct: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ index_insert: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ index_delete: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ index_build: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+
+ // Query Engine Operations
+ query_engine_create: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ query_engine_query: SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE,
+
+ // Retriever Operations
+ retriever_create: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ retriever_retrieve: SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE,
+
+ // LLM Operations
+ llm_chat: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ llm_complete: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+
+ // Embedding Operations
+ embedding_generate: SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+
+ // Response Synthesis
+ response_synthesize: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+
+ // Text Processing Components
+ text_splitter_split: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ node_parser_parse: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+
+ // Vector Store Components
+ vector_store_add: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ vector_store_delete: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ vector_store_query: SemanticConvention.GEN_AI_OPERATION_TYPE_RETRIEVE,
+
+ // Postprocessor
+ postprocessor_process: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+};
+
+export default class LlamaIndexWrapper {
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_LLAMAINDEX;
+
+ // ---------------------------------------------------------------------------
+ // Helpers (mirrors Python set_server_address_and_port / model extraction)
+ // ---------------------------------------------------------------------------
+
+ private static _extractModel(instance: any): string {
+ return instance?.model
+ || instance?.modelName
+ || instance?.metadata?.model
+ || instance?.llm?.model
+ || instance?._llm?.model
+ || instance?._responseSynthesizer?.llm?.model
+ || instance?._responseSynthesizer?._llm?.model
+ || 'unknown';
+ }
private static _extractServerInfo(instance: any): { address: string; port: number } {
- const baseUrl =
- instance?.session?.openai?.baseURL ||
- instance?._client?.baseURL ||
- instance?.clientOptions?.baseURL ||
- instance?.llm?.session?.openai?.baseURL ||
- instance?._llm?.session?.openai?.baseURL ||
- '';
- if (baseUrl) {
- try {
- const url = new URL(baseUrl);
- const port = url.port ? parseInt(url.port) : (url.protocol === 'https:' ? 443 : 80);
- return { address: url.hostname, port };
- } catch { /* ignore */ }
+ const candidates = [
+ instance?._client?.baseURL,
+ instance?.session?.openai?.baseURL,
+ instance?.clientOptions?.baseURL,
+ instance?.llm?._client?.baseURL,
+ instance?._llm?._client?.baseURL,
+ instance?.llm?.session?.openai?.baseURL,
+ instance?._llm?.session?.openai?.baseURL,
+ ];
+ for (const rawUrl of candidates) {
+ if (rawUrl) {
+ try {
+ const parsed = new URL(rawUrl);
+ return {
+ address: parsed.hostname,
+ port: parsed.port
+ ? parseInt(parsed.port, 10)
+ : (parsed.protocol === 'https:' ? 443 : 80),
+ };
+ } catch { /* try next */ }
+ }
}
- return { address: 'api.openai.com', port: 443 };
+ return { address: 'localhost', port: 8000 };
}
- // ---- LLM patches -----------------------------------------------------------
+ // ---------------------------------------------------------------------------
+ // LLM chat patch — full provider-style telemetry + frameworkLlmActive
+ // Mirrors Python: LLM.chat -> operation_type "chat"
+ // ---------------------------------------------------------------------------
static _patchLLMChat(tracer: Tracer): any {
- const genAIEndpoint = 'llamaindex.llm.chat';
+ const endpoint = 'llm_chat';
+ const operationType = OPERATION_MAP[endpoint];
+
return (originalMethod: (...args: any[]) => any) => {
- return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
+ return function (this: any, ...args: any[]) {
+ const requestModel = LlamaIndexWrapper._extractModel(this);
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
+ const spanName = `${operationType} ${requestModel}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: address,
+ [SemanticConvention.SERVER_PORT]: port,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
const startTime = Date.now();
- try {
- const response = await originalMethod.apply(this, args);
- const duration = (Date.now() - startTime) / 1000;
-
- const params = args[0] || {};
- const messages = params.messages || [];
- const modelId = this.model || this.modelName || this.metadata?.model || 'unknown';
- const aiSystem = LlamaIndexWrapper.aiSystem;
-
- const rawUsage = response?.raw?.usage || response?.usage || {};
- const promptTokens = rawUsage.prompt_tokens || rawUsage.input_tokens || 0;
- const completionTokens = rawUsage.completion_tokens || rawUsage.output_tokens || 0;
- const totalTokens = rawUsage.total_tokens || promptTokens + completionTokens;
- const finishReason = response?.raw?.choices?.[0]?.finish_reason || 'stop';
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, promptTokens, completionTokens);
-
- const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
-
- LlamaIndexWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem, serverAddress: address, serverPort: port });
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, address);
- span.setAttribute(SemanticConvention.SERVER_PORT, port);
-
- if (OpenlitConfig.traceContent) {
- const formattedMessages = messages.map((m: any) => ({
- role: m.role || 'user',
- content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content),
- }));
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(formattedMessages));
-
- const outputContent = response?.message?.content || response?.text || '';
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(outputContent, finishReason)
- );
- }
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem };
+ const onSuccess = (response: any) => {
+ try {
+ LlamaIndexWrapper._processLLMResponse(
+ span, response, requestModel, address, port, startTime, args, 'chat',
+ );
+ } catch { /* swallow telemetry errors */ }
return response;
- } catch (e: any) {
+ };
+
+ const onError = (e: any) => {
OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ throw e;
+ };
+
+ try {
+ const result = runWithFrameworkLlm(() => originalMethod.apply(this, args));
+ if (result && typeof (result as any).then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
}
});
};
};
}
+ // ---------------------------------------------------------------------------
+ // LLM complete patch — full provider-style telemetry + frameworkLlmActive
+ // Mirrors Python: LLM.complete -> operation_type "chat"
+ // ---------------------------------------------------------------------------
+
static _patchLLMComplete(tracer: Tracer): any {
- const genAIEndpoint = 'llamaindex.llm.complete';
+ const endpoint = 'llm_complete';
+ const operationType = OPERATION_MAP[endpoint];
+
return (originalMethod: (...args: any[]) => any) => {
- return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
+ return function (this: any, ...args: any[]) {
+ const requestModel = LlamaIndexWrapper._extractModel(this);
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
+ const spanName = `${operationType} ${requestModel}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: address,
+ [SemanticConvention.SERVER_PORT]: port,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
const startTime = Date.now();
- try {
- const response = await originalMethod.apply(this, args);
- const duration = (Date.now() - startTime) / 1000;
-
- const prompt = typeof args[0] === 'string' ? args[0] : args[0]?.prompt || '';
- const modelId = this.model || this.modelName || this.metadata?.model || 'unknown';
- const aiSystem = LlamaIndexWrapper.aiSystem;
-
- const rawUsage = response?.raw?.usage || response?.usage || {};
- const promptTokens = rawUsage.prompt_tokens || rawUsage.input_tokens || 0;
- const completionTokens = rawUsage.completion_tokens || rawUsage.output_tokens || 0;
- const totalTokens = rawUsage.total_tokens || promptTokens + completionTokens;
- const finishReason = response?.raw?.choices?.[0]?.finish_reason || 'stop';
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, promptTokens, completionTokens);
-
- const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
-
- LlamaIndexWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem, serverAddress: address, serverPort: port });
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, address);
- span.setAttribute(SemanticConvention.SERVER_PORT, port);
-
- if (OpenlitConfig.traceContent) {
- span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages([{ role: 'user', content: prompt }])
- );
- const outputContent = response?.text || '';
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(outputContent, finishReason)
- );
- }
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem };
+ const onSuccess = (response: any) => {
+ try {
+ LlamaIndexWrapper._processLLMResponse(
+ span, response, requestModel, address, port, startTime, args, 'complete',
+ );
+ } catch { /* swallow */ }
return response;
- } catch (e: any) {
+ };
+
+ const onError = (e: any) => {
OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ throw e;
+ };
+
+ try {
+ const result = runWithFrameworkLlm(() => originalMethod.apply(this, args));
+ if (result && typeof (result as any).then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
}
});
};
};
}
- // ---- Query engine patch ----------------------------------------------------
+ // ---------------------------------------------------------------------------
+ // Shared LLM response processor — attributes, events, metrics
+ // ---------------------------------------------------------------------------
+
+ private static _processLLMResponse(
+ span: Span,
+ response: any,
+ requestModel: string,
+ serverAddress: string,
+ serverPort: number,
+ startTime: number,
+ args: any[],
+ mode: 'chat' | 'complete',
+ ): void {
+ const endpoint = mode === 'chat' ? 'llm_chat' : 'llm_complete';
+ const duration = (Date.now() - startTime) / 1000;
+
+ const rawUsage = response?.raw?.usage || response?.usage || {};
+ const inputTokens = rawUsage.prompt_tokens || rawUsage.input_tokens || 0;
+ const outputTokens = rawUsage.completion_tokens || rawUsage.output_tokens || 0;
+ const finishReason = response?.raw?.choices?.[0]?.finish_reason || 'stop';
+ const responseModel = response?.raw?.model || requestModel;
+ const responseId = response?.raw?.id || '';
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(
+ requestModel, pricingInfo, inputTokens, outputTokens,
+ );
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ cost,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ if (responseModel) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
+ }
+ if (responseId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, responseId);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
+ if (inputTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ }
+ if (outputTokens) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+
+ let inputMessagesJson = '';
+ let outputMessagesJson = '';
+
+ if (OpenlitConfig.captureMessageContent) {
+ if (mode === 'chat') {
+ const messages = args[0]?.messages || (Array.isArray(args[0]) ? args[0] : []);
+ const formatted = (Array.isArray(messages) ? messages : [messages]).map((m: any) => ({
+ role: m.role || 'user',
+ content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content || ''),
+ }));
+ inputMessagesJson = OpenLitHelper.buildInputMessages(formatted);
+ const text = response?.message?.content || response?.text || '';
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(text, finishReason);
+ } else {
+ const prompt = typeof args[0] === 'string' ? args[0] : args[0]?.prompt || '';
+ inputMessagesJson = OpenLitHelper.buildInputMessages([{ role: 'user', content: prompt }]);
+ const text = response?.text || '';
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(text, finishReason);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
+
+ const eventAttrs: Record<string, any> = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: responseId,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (OpenlitConfig.captureMessageContent) {
+ eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ cost,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress,
+ serverPort,
+ });
+
+ span.end();
+ }
+
+ // ---------------------------------------------------------------------------
+ // Query engine query patch — retrieval span with source nodes
+ // Mirrors Python: RetrieverQueryEngine.query -> operation_type "retrieval"
+ // ---------------------------------------------------------------------------
static _patchQueryEngineQuery(tracer: Tracer): any {
- const genAIEndpoint = 'llamaindex.query_engine.query';
+ const endpoint = 'query_engine_query';
+ const operationType = OPERATION_MAP[endpoint];
+
return (originalMethod: (...args: any[]) => any) => {
- return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
+ return function (this: any, ...args: any[]) {
+ const requestModel = LlamaIndexWrapper._extractModel(this);
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(
+ this?.llm || this?._llm || this,
+ );
+ const spanName = `${operationType} ${endpoint}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
const startTime = Date.now();
- try {
- const response = await originalMethod.apply(this, args);
- const duration = (Date.now() - startTime) / 1000;
-
- const queryStr = typeof args[0] === 'string' ? args[0] : args[0]?.query || '';
-
- const llm = this.llm || this._llm;
- const modelId = llm?.model || llm?.modelName || llm?.metadata?.model || 'unknown';
- const aiSystem = LlamaIndexWrapper.aiSystem;
-
- const { address, port } = LlamaIndexWrapper._extractServerInfo(llm || this);
-
- LlamaIndexWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, aiSystem, serverAddress: address, serverPort: port });
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, address);
- span.setAttribute(SemanticConvention.SERVER_PORT, port);
-
- const sourceNodes = response.sourceNodes || response.source_nodes || [];
- if (sourceNodes.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_RETRIEVAL_SOURCE, JSON.stringify(
- sourceNodes.slice(0, 5).map((n: any) => ({
- id: n.node?.id_ || n.id_ || '',
- score: n.score,
- text: n.node?.text?.slice(0, 200) || '',
- }))
- ));
- }
- if (OpenlitConfig.traceContent) {
- span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages([{ role: 'user', content: queryStr }])
- );
- const responseText = typeof response.response === 'string'
- ? response.response
- : response.toString?.() || '';
+ const onSuccess = (response: any) => {
+ try {
+ const duration = (Date.now() - startTime) / 1000;
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(responseText, 'stop')
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration,
);
- }
- metricParams = { genAIEndpoint, model: modelId, aiSystem };
+ const sourceNodes = response?.sourceNodes || response?.source_nodes || [];
+ if (sourceNodes.length > 0) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
+ JSON.stringify(
+ sourceNodes.slice(0, 5).map((n: any) => ({
+ id: n.node?.id_ || n.id_ || '',
+ score: n.score,
+ text: n.node?.text?.slice(0, 200) || '',
+ })),
+ ),
+ );
+ }
+
+ if (OpenlitConfig.captureMessageContent) {
+ const queryStr = typeof args[0] === 'string'
+ ? args[0]
+ : args[0]?.query || args[0]?.queryStr || '';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages([{ role: 'user', content: queryStr }]),
+ );
+ const responseText = typeof response?.response === 'string'
+ ? response.response
+ : response?.message?.content || response?.toString?.() || '';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ OpenLitHelper.buildOutputMessages(responseText, 'stop'),
+ );
+ }
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ } catch { /* swallow */ }
+ span.end();
return response;
- } catch (e: any) {
+ };
+
+ const onError = (e: any) => {
OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ throw e;
+ };
+
+ try {
+ const result = originalMethod.apply(this, args);
+ if (result && typeof result.then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
}
});
};
};
}
- // ---- Chat engine patch -----------------------------------------------------
+ // ---------------------------------------------------------------------------
+ // Chat engine chat patch — framework span with chat content
+ // Mirrors Python: chat engine operations -> operation_type "invoke_workflow"
+ // ---------------------------------------------------------------------------
static _patchChatEngineChat(tracer: Tracer): any {
- const genAIEndpoint = 'llamaindex.chat_engine.chat';
+ const endpoint = 'chat_engine_chat';
+ const operationType = SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
+
return (originalMethod: (...args: any[]) => any) => {
- return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
+ return function (this: any, ...args: any[]) {
+ const requestModel = LlamaIndexWrapper._extractModel(this);
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(
+ this?.llm || this?._llm || this,
+ );
+ const workflowName = (this as any)?.constructor?.name || 'chat_engine';
+ const spanName = `${operationType} ${workflowName}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_WORKFLOW_NAME]: workflowName,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
const startTime = Date.now();
- try {
- const response = await originalMethod.apply(this, args);
- const duration = (Date.now() - startTime) / 1000;
- const messageInput = args[0];
- const message = typeof messageInput === 'string'
- ? messageInput
- : messageInput?.message || messageInput?.content || '';
+ const onSuccess = (response: any) => {
+ try {
+ const duration = (Date.now() - startTime) / 1000;
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ span.setAttribute(
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration,
+ );
+
+ if (OpenlitConfig.captureMessageContent) {
+ const messageInput = args[0];
+ const message = typeof messageInput === 'string'
+ ? messageInput
+ : messageInput?.message || messageInput?.content || '';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages([{ role: 'user', content: message }]),
+ );
+ const responseContent =
+ response?.message?.content
+ || (typeof response?.response === 'string' ? response.response : '')
+ || response?.toString?.() || '';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ OpenLitHelper.buildOutputMessages(responseContent, 'stop'),
+ );
+ }
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ } catch { /* swallow */ }
+ span.end();
+ return response;
+ };
+
+ const onError = (e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model: requestModel,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ };
- const llm = this.llm || this._llm;
- const modelId = llm?.model || llm?.modelName || llm?.metadata?.model || 'unknown';
- const aiSystem = LlamaIndexWrapper.aiSystem;
+ try {
+ const result = originalMethod.apply(this, args);
+ if (result && typeof result.then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
+ }
+ });
+ };
+ };
+ }
- const { address, port } = LlamaIndexWrapper._extractServerInfo(llm || this);
+ // ---------------------------------------------------------------------------
+ // Retriever retrieve patch — retrieval span
+ // Mirrors Python: BaseRetriever.retrieve -> operation_type "retrieval"
+ // ---------------------------------------------------------------------------
- LlamaIndexWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, aiSystem, serverAddress: address, serverPort: port });
+ static _patchRetrieverRetrieve(tracer: Tracer): any {
+ const endpoint = 'retriever_retrieve';
+ const operationType = OPERATION_MAP[endpoint];
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
- span.setAttribute(SemanticConvention.SERVER_ADDRESS, address);
- span.setAttribute(SemanticConvention.SERVER_PORT, port);
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
+ const spanName = `${operationType} ${endpoint}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ },
+ });
- if (OpenlitConfig.traceContent) {
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ const model = LlamaIndexWrapper._extractModel(this);
+
+ const onSuccess = (response: any) => {
+ try {
+ const duration = (Date.now() - startTime) / 1000;
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
span.setAttribute(
- SemanticConvention.GEN_AI_INPUT_MESSAGES,
- OpenLitHelper.buildInputMessages([{ role: 'user', content: message }])
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration,
);
- const responseContent =
- response?.message?.content ||
- (typeof response?.response === 'string' ? response.response : '') ||
- response?.toString?.() || '';
+ if (Array.isArray(response) && response.length > 0) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
+ JSON.stringify(
+ response.slice(0, 5).map((n: any) => ({
+ id: n.node?.id_ || n.id_ || '',
+ score: n.score,
+ text: n.node?.text?.slice(0, 200) || n.text?.slice(0, 200) || '',
+ })),
+ ),
+ );
+ }
+
+ if (OpenlitConfig.captureMessageContent) {
+ const queryStr = typeof args[0] === 'string'
+ ? args[0]
+ : args[0]?.query || args[0]?.queryStr || '';
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages([{ role: 'user', content: queryStr }]),
+ );
+ }
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ } catch { /* swallow */ }
+ span.end();
+ return response;
+ };
+
+ const onError = (e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ };
+
+ try {
+ const result = originalMethod.apply(this, args);
+ if (result && typeof result.then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
+ }
+ });
+ };
+ };
+ }
+
+ // ---------------------------------------------------------------------------
+ // Embedding patch — embeddings span
+ // Mirrors Python: BaseEmbedding.get_text_embedding_batch -> "embeddings"
+ // ---------------------------------------------------------------------------
+
+ static _patchEmbedding(tracer: Tracer, endpoint: string = 'embedding_generate'): any {
+ const operationType = OPERATION_MAP[endpoint] || SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING;
+
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const model = LlamaIndexWrapper._extractModel(this);
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
+ const spanName = `${operationType} ${endpoint}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: model,
+ [SemanticConvention.SERVER_ADDRESS]: address,
+ [SemanticConvention.SERVER_PORT]: port,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+
+ const onSuccess = (response: any) => {
+ try {
+ const duration = (Date.now() - startTime) / 1000;
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(responseContent, 'stop')
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration,
);
- }
- metricParams = { genAIEndpoint, model: modelId, aiSystem };
+ if (Array.isArray(response) && response.length > 0) {
+ if (Array.isArray(response[0])) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT,
+ response[0].length,
+ );
+ } else if (typeof response[0] === 'number') {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT,
+ response.length,
+ );
+ }
+ }
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ } catch { /* swallow */ }
+ span.end();
return response;
- } catch (e: any) {
+ };
+
+ const onError = (e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
throw e;
- } finally {
+ };
+
+ try {
+ const result = runWithFrameworkLlm(() => originalMethod.apply(this, args));
+ if (result && typeof (result as any).then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
+ }
+ });
+ };
+ };
+ }
+
+ // ---------------------------------------------------------------------------
+ // Generic framework method patch — for index, document, synthesizer, etc.
+ // Mirrors Python: common_llamaindex_logic with framework-level attributes
+ // ---------------------------------------------------------------------------
+
+ static _patchFrameworkMethod(tracer: Tracer, endpoint: string): any {
+ const operationType =
+ OPERATION_MAP[endpoint] || SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
+
+ return (originalMethod: (...args: any[]) => any) => {
+ return function (this: any, ...args: any[]) {
+ const { address, port } = LlamaIndexWrapper._extractServerInfo(this);
+ const spanName = `${operationType} ${endpoint}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: LlamaIndexWrapper.aiSystem,
+ },
+ });
+
+ return context.with(trace.setSpan(context.active(), span), () => {
+ const startTime = Date.now();
+ const model = LlamaIndexWrapper._extractModel(this);
+
+ const onSuccess = (response: any) => {
+ try {
+ const duration = (Date.now() - startTime) / 1000;
+
+ BaseWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ span.setAttribute(
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration,
+ );
+
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ });
+ } catch { /* swallow */ }
+ span.end();
+ return response;
+ };
+
+ const onError = (e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint: endpoint,
+ model,
+ aiSystem: LlamaIndexWrapper.aiSystem,
+ serverAddress: address,
+ serverPort: port,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
+ throw e;
+ };
+
+ try {
+ const result = originalMethod.apply(this, args);
+ if (result && typeof result.then === 'function') {
+ return (result as Promise<any>).then(onSuccess).catch(onError);
+ }
+ return onSuccess(result);
+ } catch (e: any) {
+ return onError(e);
}
});
};
};
}
}
-
-export default LlamaIndexWrapper;
diff --git a/sdk/typescript/src/instrumentation/milvus/wrapper.ts b/sdk/typescript/src/instrumentation/milvus/wrapper.ts
index 27067c30..7cf1bffe 100644
--- a/sdk/typescript/src/instrumentation/milvus/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/milvus/wrapper.ts
@@ -56,7 +56,7 @@ class MilvusWrapper extends BaseWrapper {
const resultCount = response?.results?.length || 0;
span.setAttribute(SemanticConvention.DB_N_RESULTS, resultCount);
- if (OpenlitConfig.traceContent && params.vectors) {
+ if (OpenlitConfig.captureMessageContent && params.vectors) {
const vectors = Array.isArray(params.vectors) ? params.vectors : [];
span.setAttribute(SemanticConvention.DB_QUERY_TEXT,
JSON.stringify(vectors.slice(0, 1).map((v: number[]) => v?.slice(0, 10))));
diff --git a/sdk/typescript/src/instrumentation/mistral/wrapper.ts b/sdk/typescript/src/instrumentation/mistral/wrapper.ts
index 04f8f5d1..3f2491a7 100644
--- a/sdk/typescript/src/instrumentation/mistral/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/mistral/wrapper.ts
@@ -1,25 +1,44 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: MistralWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: MistralWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: MistralWrapper.serverPort,
+ };
+}
+
class MistralWrapper extends BaseWrapper {
- static aiSystem = 'mistral';
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_MISTRAL;
static serverAddress = 'api.mistral.ai';
static serverPort = 443;
-
+
static _patchChatCompletionCreate(tracer: Tracer): any {
const genAIEndpoint = 'mistral.chat.completions';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'mistral-small-latest';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
- // Detect streaming: new Mistral SDK's chat.stream() returns an async iterable directly
const isStream = args[0]?.stream === true || typeof response[Symbol.asyncIterator] === 'function';
if (isStream) {
@@ -38,6 +57,14 @@ class MistralWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: MistralWrapper.aiSystem,
+ serverAddress: MistralWrapper.serverAddress,
+ serverPort: MistralWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -90,7 +117,7 @@ class MistralWrapper extends BaseWrapper {
let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
-
+
try {
const { messages } = args[0];
let { tools } = args[0];
@@ -111,13 +138,12 @@ class MistralWrapper extends BaseWrapper {
total_tokens: 0,
},
};
-
- let toolCalls: any[] = [];
-
+
+ const toolCalls: any[] = [];
+
for await (const chunk of response) {
timestamps.push(Date.now());
- // New Mistral SDK wraps each SSE event in { data: { ... } }
const chunkData = chunk.data ?? chunk;
result.id = chunkData.id || result.id;
@@ -125,20 +151,21 @@ class MistralWrapper extends BaseWrapper {
result.model = chunkData.model || result.model;
if (chunkData.choices && chunkData.choices[0]) {
- if (chunkData.choices[0].finish_reason) {
- result.choices[0].finish_reason = chunkData.choices[0].finish_reason;
+ const chunkFinishReason = chunkData.choices[0].finishReason ?? chunkData.choices[0].finish_reason;
+ if (chunkFinishReason) {
+ result.choices[0].finish_reason = chunkFinishReason;
}
- if (chunkData.choices[0].delta?.content) {
- result.choices[0].message.content += chunkData.choices[0].delta.content;
+ const delta = chunkData.choices[0].delta;
+ if (delta?.content) {
+ result.choices[0].message.content += delta.content;
}
- // Handle tool calls for streaming
- if (chunkData.choices[0].delta?.tool_calls) {
- const deltaTools = chunkData.choices[0].delta.tool_calls;
-
+ if (delta?.toolCalls || delta?.tool_calls) {
+ const deltaTools = delta.toolCalls || delta.tool_calls;
+
for (const tool of deltaTools) {
const idx = tool.index || 0;
-
+
while (toolCalls.length <= idx) {
toolCalls.push({
id: '',
@@ -146,7 +173,7 @@ class MistralWrapper extends BaseWrapper {
function: { name: '', arguments: '' }
});
}
-
+
if (tool.id) {
toolCalls[idx].id = tool.id;
toolCalls[idx].type = tool.type || 'function';
@@ -160,14 +187,14 @@ class MistralWrapper extends BaseWrapper {
toolCalls[idx].function.arguments += tool.function.arguments;
}
}
-
+
tools = true;
}
}
yield chunk;
}
-
+
if (toolCalls.length > 0) {
result.choices[0].message = {
...result.choices[0].message,
@@ -175,7 +202,6 @@ class MistralWrapper extends BaseWrapper {
} as any;
}
- // Estimate token usage if not provided
let promptTokens = 0;
for (const message of messages || []) {
promptTokens += OpenLitHelper.openaiTokens(message.content as string, result.model) ?? 0;
@@ -185,7 +211,7 @@ class MistralWrapper extends BaseWrapper {
result.choices[0].message.content ?? '',
result.model
);
-
+
if (completionTokens) {
result.usage = {
prompt_tokens: promptTokens,
@@ -195,8 +221,7 @@ class MistralWrapper extends BaseWrapper {
}
args[0].tools = tools;
-
- // Calculate TTFT and TBT
+
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -240,57 +265,67 @@ class MistralWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'mistral-small-latest';
const {
messages,
+ frequency_penalty = 0,
max_tokens = null,
- temperature = 0.7,
+ n = 1,
+ presence_penalty = 0,
+ seed = null,
+ stop = null,
+ temperature = 1,
top_p,
user,
stream = false,
- safe_prompt = false,
} = args[0];
- // Request Params attributes
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens || -1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
-
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ if (stop) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(stop) ? stop : [stop]);
}
- if (safe_prompt !== undefined) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SAFE_PROMPT, safe_prompt);
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
}
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
}
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
-
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- const model = result.model || 'mistral-small-latest';
- const responseModel = result.model || model;
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
-
- // Support both camelCase (new SDK) and snake_case (old SDK) usage fields
const promptTokens = result.usage?.promptTokens ?? result.usage?.prompt_tokens ?? 0;
const completionTokens = result.usage?.completionTokens ?? result.usage?.completion_tokens ?? 0;
- const totalTokens = result.usage?.totalTokens ?? result.usage?.total_tokens ?? 0;
- // Calculate cost of the operation
- const cost = OpenLitHelper.getChatModelCost(model, pricingInfo, promptTokens, completionTokens);
+ const responseModel = result.model || requestModel;
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+
+ const cost = OpenLitHelper.getChatModelCost(
+ requestModel,
+ pricingInfo,
+ promptTokens,
+ completionTokens
+ );
MistralWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: MistralWrapper.aiSystem,
@@ -298,16 +333,13 @@ class MistralWrapper extends BaseWrapper {
serverPort: MistralWrapper.serverPort,
});
- // Response model
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- // Token usage
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
-
- // TTFT and TBT metrics
+ const inputTokens = promptTokens;
+ const outputTokens = completionTokens;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -315,28 +347,25 @@ class MistralWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Finish reason
- if (result.choices[0].finish_reason) {
+ const finishReason = result.choices[0].finishReason ?? result.choices[0].finish_reason;
+ if (finishReason) {
span.setAttribute(
SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
- [result.choices[0].finish_reason]
+ [finishReason]
);
}
-
- // Output type
- const outputType = typeof result.choices[0].message.content === 'string'
- ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+
+ const outputType = typeof result.choices[0].message.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
: SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
- // Tool calls handling
if (result.choices[0].message.tool_calls) {
const toolCalls = result.choices[0].message.tool_calls;
const toolNames = toolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
const toolArgs = toolCalls.map((t: any) => t.function?.arguments || '').filter(Boolean);
- const toolTypes = toolCalls.map((t: any) => t.type || '').filter(Boolean);
-
+
if (toolNames.length > 0) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
}
@@ -344,28 +373,46 @@ class MistralWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
}
if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- }
- if (toolTypes.length > 0) {
- const toolTypesStr = toolTypes.join(', ');
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolTypesStr);
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, toolTypesStr);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
}
- // Content
- if (traceContent) {
- const completionContent = result.choices[0].message.content || '';
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
const toolCalls = result.choices[0].message.tool_calls;
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(completionContent, result.choices[0].finish_reason || 'stop', toolCalls)
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.choices[0].message.content || '',
+ finishReason || 'stop',
+ toolCalls
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: MistralWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: MistralWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason || 'stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: MistralWrapper.aiSystem,
@@ -374,34 +421,34 @@ class MistralWrapper extends BaseWrapper {
static _patchEmbedding(tracer: Tracer): any {
const genAIEndpoint = 'mistral.embeddings';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'mistral-embed';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams: BaseSpanAttributes | undefined;
try {
const response = await originalMethod.apply(this, args);
- const model = args[0].model || 'mistral-embed';
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- // Mistral SDK returns camelCase usage fields
+ const _responseModel = response.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const promptTokens = response.usage?.promptTokens ?? response.usage?.prompt_tokens ?? 0;
- const totalTokens = response.usage?.totalTokens ?? response.usage?.total_tokens ?? 0;
- const cost = OpenLitHelper.getEmbedModelCost(model, pricingInfo, promptTokens);
-
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING
- );
+ const cost = OpenLitHelper.getEmbedModelCost(requestModel, pricingInfo, promptTokens);
const { input, inputs, user, encoding_format = 'float' } = args[0];
const embeddingInput = input ?? inputs;
-
+
MistralWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: MistralWrapper.aiSystem,
@@ -409,26 +456,26 @@ class MistralWrapper extends BaseWrapper {
serverPort: MistralWrapper.serverPort,
});
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, [encoding_format]);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, 0);
- span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, 0);
-
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, [encoding_format]);
+ if (captureContent && embeddingInput) {
+ const formattedInput = typeof embeddingInput === 'string' ? embeddingInput : JSON.stringify(embeddingInput);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, formattedInput);
}
- if (traceContent && embeddingInput) {
- const inputArr = Array.isArray(embeddingInput) ? embeddingInput : [embeddingInput];
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(inputArr.map((c: string) => ({ role: 'user', content: c }))));
+
+ const embData = response?.data;
+ if (Array.isArray(embData) && embData.length > 0 && Array.isArray(embData[0].embedding)) {
+ span.setAttribute(SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT, embData[0].embedding.length);
}
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, promptTokens);
+ span.setAttribute(
+ SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
+ promptTokens
+ );
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: MistralWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/ollama/index.ts b/sdk/typescript/src/instrumentation/ollama/index.ts
index 5a10c399..3da8bfc9 100644
--- a/sdk/typescript/src/instrumentation/ollama/index.ts
+++ b/sdk/typescript/src/instrumentation/ollama/index.ts
@@ -38,17 +38,49 @@ export default class OpenlitOllamaInstrumentation extends InstrumentationBase {
protected _patch(moduleExports: any) {
try {
- if (isWrapped(moduleExports.Ollama.prototype.chat)) {
- this._unwrap(moduleExports.Ollama.prototype, 'chat');
+ const proto = moduleExports.Ollama.prototype;
+
+ if (isWrapped(proto.chat)) {
+ this._unwrap(proto, 'chat');
+ }
+ this._wrap(proto, 'chat', OllamaWrapper._patchChat(this.tracer));
+
+ if (typeof proto.generate === 'function') {
+ if (isWrapped(proto.generate)) {
+ this._unwrap(proto, 'generate');
+ }
+ this._wrap(proto, 'generate', OllamaWrapper._patchGenerate(this.tracer));
+ }
+
+ if (typeof proto.embed === 'function') {
+ if (isWrapped(proto.embed)) {
+ this._unwrap(proto, 'embed');
+ }
+ this._wrap(proto, 'embed', OllamaWrapper._patchEmbeddings(this.tracer));
}
- this._wrap(moduleExports.Ollama.prototype, 'chat', OllamaWrapper._patchChat(this.tracer));
+ if (typeof proto.embeddings === 'function') {
+ if (isWrapped(proto.embeddings)) {
+ this._unwrap(proto, 'embeddings');
+ }
+ this._wrap(proto, 'embeddings', OllamaWrapper._patchEmbeddings(this.tracer));
+ }
} catch (e) {
console.error('Error in _patch method:', e);
}
}
protected _unpatch(moduleExports: any) {
- this._unwrap(moduleExports.Ollama.prototype, 'chat');
+ const proto = moduleExports.Ollama.prototype;
+ this._unwrap(proto, 'chat');
+ if (typeof proto.generate === 'function') {
+ this._unwrap(proto, 'generate');
+ }
+ if (typeof proto.embed === 'function') {
+ this._unwrap(proto, 'embed');
+ }
+ if (typeof proto.embeddings === 'function') {
+ this._unwrap(proto, 'embeddings');
+ }
}
}
diff --git a/sdk/typescript/src/instrumentation/ollama/wrapper.ts b/sdk/typescript/src/instrumentation/ollama/wrapper.ts
index ea0b7549..91fd6ee2 100644
--- a/sdk/typescript/src/instrumentation/ollama/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/ollama/wrapper.ts
@@ -1,41 +1,65 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: OllamaWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: OllamaWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OllamaWrapper.serverPort,
+ };
+}
+
export default class OllamaWrapper extends BaseWrapper {
- static aiSystem = 'ollama';
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_OLLAMA;
static serverAddress = '127.0.0.1';
static serverPort = 11434;
+ // ──────────────────── Chat ────────────────────
+
static _patchChat(tracer: Tracer): any {
const genAIEndpoint = 'ollama.chat';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- const { stream = false } = args[0];
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'llama3';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
- if (!!stream) {
+ const { stream = false } = args[0];
+ if (stream) {
return OpenLitHelper.createStreamProxy(
response,
- OllamaWrapper._chatGenerator({
- args,
- genAIEndpoint,
- response,
- span,
- })
+ OllamaWrapper._chatGenerator({ args, genAIEndpoint, response, span })
);
}
-
return OllamaWrapper._chat({ args, genAIEndpoint, response, span });
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: OllamaWrapper.aiSystem,
+ serverAddress: OllamaWrapper.serverAddress,
+ serverPort: OllamaWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -53,8 +77,8 @@ export default class OllamaWrapper extends BaseWrapper {
genAIEndpoint: string;
response: any;
span: Span;
- }) {
- let metricParams: BaseSpanAttributes | undefined;
+ }): Promise<any> {
+ let metricParams;
try {
metricParams = await OllamaWrapper._chatCommonSetter({
args,
@@ -65,6 +89,7 @@ export default class OllamaWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -83,8 +108,8 @@ export default class OllamaWrapper extends BaseWrapper {
genAIEndpoint: string;
response: any;
span: Span;
- }) {
- let metricParams: BaseSpanAttributes | undefined;
+ }): AsyncGenerator<unknown, any, unknown> {
+ let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
try {
@@ -95,6 +120,7 @@ export default class OllamaWrapper extends BaseWrapper {
prompt_eval_count: 0,
eval_count: 0,
};
+ let toolCalls: any[] = [];
for await (const chunk of response) {
timestamps.push(Date.now());
@@ -103,15 +129,21 @@ export default class OllamaWrapper extends BaseWrapper {
result.message.content += chunk.message.content;
result.message.role = chunk.message.role || result.message.role;
}
+ if (chunk.message?.tool_calls) {
+ toolCalls = chunk.message.tool_calls;
+ }
if (chunk.done) {
result.done_reason = chunk.done_reason || '';
result.prompt_eval_count = chunk.prompt_eval_count || 0;
result.eval_count = chunk.eval_count || 0;
}
-
yield chunk;
}
+ if (toolCalls.length > 0) {
+ result.message.tool_calls = toolCalls;
+ }
+
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -127,9 +159,10 @@ export default class OllamaWrapper extends BaseWrapper {
ttft,
tbt,
});
- return response;
+ return result;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -153,68 +186,351 @@ export default class OllamaWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
- const {
- messages,
- max_tokens = null,
- seed = null,
- temperature = 1,
- top_p,
- top_k,
- user,
- stream = false,
- } = args[0];
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'llama3';
+ const { messages, stream = false } = args[0];
+ const options = args[0]?.options || {};
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
-
- const model = result.model || args[0].model;
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ if (options.temperature != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, options.temperature);
+ }
+ if (options.top_p != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, options.top_p);
+ }
+ if (options.top_k != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, options.top_k);
+ }
+ if (options.max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, options.max_tokens);
+ }
+ if (options.repeat_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, options.repeat_penalty);
+ }
+ if (options.seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(options.seed));
+ }
+ if (options.stop) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(options.stop) ? options.stop : [options.stop]
+ );
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
- const promptTokens = result.prompt_eval_count || 0;
- const completionTokens = result.eval_count || 0;
- const totalTokens = promptTokens + completionTokens;
+ if (captureContent) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages(messages || [])
+ );
+ }
- // Calculate cost of the operation
- const cost = OpenLitHelper.getChatModelCost(model, pricingInfo, promptTokens, completionTokens);
+ const responseModel = result.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = result.prompt_eval_count || 0;
+ const outputTokens = result.eval_count || 0;
+ const cost = OpenLitHelper.getChatModelCost(requestModel, pricingInfo, inputTokens, outputTokens);
OllamaWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
- user,
+ model: requestModel,
cost,
aiSystem: OllamaWrapper.aiSystem,
serverAddress: OllamaWrapper.serverAddress,
serverPort: OllamaWrapper.serverPort,
});
- // Response model
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, model);
-
- // Request Params attributes : Start
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, top_k);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, seed);
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
+ if (ttft > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ }
+ if (tbt > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Request Params attributes : End
-
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, totalTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, totalTokens);
if (result.done_reason) {
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.done_reason]);
}
- // TTFT and TBT metrics
+ const outputType = typeof result.message?.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ if (result.message?.tool_calls) {
+ const resultToolCalls = result.message.tool_calls;
+ const toolNames = resultToolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
+ const toolIds = resultToolCalls.map((t: any) => String(t.id || '')).filter(Boolean);
+ const toolArgs = resultToolCalls
+ .map((t: any) => String(t.function?.arguments || ''))
+ .filter(Boolean);
+
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
+ }
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const toolCalls = result.message?.tool_calls;
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.message?.content || '',
+ result.done_reason || 'stop',
+ toolCalls
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: OllamaWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OllamaWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.done_reason || 'stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
+ return {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: OllamaWrapper.aiSystem,
+ };
+ }
+
+ // ──────────────────── Generate (text_completion) ────────────────────
+
+ static _patchGenerate(tracer: Tracer): any {
+ const genAIEndpoint = 'ollama.generate';
+ return (originalMethod: (...args: any[]) => any) => {
+ return async function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'llama3';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, requestModel),
+ }, effectiveCtx);
+ return context
+ .with(trace.setSpan(effectiveCtx, span), async () => {
+ return originalMethod.apply(this, args);
+ })
+ .then((response: any) => {
+ const { stream = false } = args[0];
+ if (stream) {
+ return OpenLitHelper.createStreamProxy(
+ response,
+ OllamaWrapper._generateGenerator({ args, genAIEndpoint, response, span })
+ );
+ }
+ return OllamaWrapper._generate({ args, genAIEndpoint, response, span });
+ })
+ .catch((e: any) => {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: OllamaWrapper.aiSystem,
+ serverAddress: OllamaWrapper.serverAddress,
+ serverPort: OllamaWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ span.end();
+ throw e;
+ });
+ };
+ };
+ }
+
+ static async _generate({
+ args,
+ genAIEndpoint,
+ response,
+ span,
+ }: {
+ args: any[];
+ genAIEndpoint: string;
+ response: any;
+ span: Span;
+ }): Promise<any> {
+ let metricParams;
+ try {
+ metricParams = await OllamaWrapper._generateCommonSetter({
+ args,
+ genAIEndpoint,
+ result: response,
+ span,
+ });
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ }
+
+ static async *_generateGenerator({
+ args,
+ genAIEndpoint,
+ response,
+ span,
+ }: {
+ args: any[];
+ genAIEndpoint: string;
+ response: any;
+ span: Span;
+ }): AsyncGenerator<unknown, any, unknown> {
+ let metricParams;
+ const timestamps: number[] = [];
+ const startTime = Date.now();
+ try {
+ const result: any = {
+ model: '',
+ response: '',
+ done_reason: '',
+ prompt_eval_count: 0,
+ eval_count: 0,
+ };
+
+ for await (const chunk of response) {
+ timestamps.push(Date.now());
+ result.model = chunk.model || result.model;
+ if (chunk.response) {
+ result.response += chunk.response;
+ }
+ if (chunk.done) {
+ result.done_reason = chunk.done_reason || '';
+ result.prompt_eval_count = chunk.prompt_eval_count || 0;
+ result.eval_count = chunk.eval_count || 0;
+ }
+ yield chunk;
+ }
+
+ const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
+ let tbt = 0;
+ if (timestamps.length > 1) {
+ const timeDiffs = timestamps.slice(1).map((t, i) => t - timestamps[i]);
+ tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
+ }
+
+ metricParams = await OllamaWrapper._generateCommonSetter({
+ args,
+ genAIEndpoint,
+ result,
+ span,
+ ttft,
+ tbt,
+ });
+ return result;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ }
+
+ static async _generateCommonSetter({
+ args,
+ genAIEndpoint,
+ result,
+ span,
+ ttft = 0,
+ tbt = 0,
+ }: {
+ args: any[];
+ genAIEndpoint: string;
+ result: any;
+ span: Span;
+ ttft?: number;
+ tbt?: number;
+ }) {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'llama3';
+ const { prompt, stream = false } = args[0];
+ const options = args[0]?.options || {};
+
+ if (options.temperature != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, options.temperature);
+ }
+ if (options.top_p != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, options.top_p);
+ }
+ if (options.top_k != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, options.top_k);
+ }
+ if (options.max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, options.max_tokens);
+ }
+ if (options.repeat_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, options.repeat_penalty);
+ }
+ if (options.seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(options.seed));
+ }
+ if (options.stop) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(options.stop) ? options.stop : [options.stop]
+ );
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
+
+ if (captureContent) {
+ const inputMessages = [{ role: 'user', content: prompt || '' }];
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages(inputMessages)
+ );
+ }
+
+ const responseModel = result.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = result.prompt_eval_count || 0;
+ const outputTokens = result.eval_count || 0;
+ const cost = OpenLitHelper.getChatModelCost(requestModel, pricingInfo, inputTokens, outputTokens);
+
+ OllamaWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: OllamaWrapper.aiSystem,
+ serverAddress: OllamaWrapper.serverAddress,
+ serverPort: OllamaWrapper.serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -222,18 +538,114 @@ export default class OllamaWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- if (traceContent) {
- const { message = {} } = result;
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(message.content || '', result.done_reason || 'stop'));
+ if (result.done_reason) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.done_reason]);
+ }
+
+ const llmResponse = result.response || '';
+ const outputType = typeof llmResponse === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ : SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const inputMessages = [{ role: 'user', content: prompt || '' }];
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(llmResponse, result.done_reason || 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(inputMessages);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: OllamaWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OllamaWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.done_reason || 'stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
- user,
+ model: requestModel,
cost,
aiSystem: OllamaWrapper.aiSystem,
};
}
+
+ // ──────────────────── Embeddings ────────────────────
+
+ static _patchEmbeddings(tracer: Tracer): any {
+ const genAIEndpoint = 'ollama.embeddings';
+ return (originalMethod: (...args: any[]) => any) => {
+ return async function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'llama3';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ let metricParams: BaseSpanAttributes | undefined;
+ try {
+ const response = await originalMethod.apply(this, args);
+
+ const promptVal = args[0]?.input || args[0]?.prompt || '';
+ const promptText = typeof promptVal === 'string' ? promptVal : JSON.stringify(promptVal);
+ const inputTokens = OpenLitHelper.generalTokens(promptText);
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getEmbedModelCost(requestModel, pricingInfo, inputTokens);
+
+ OllamaWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: OllamaWrapper.aiSystem,
+ serverAddress: OllamaWrapper.serverAddress,
+ serverPort: OllamaWrapper.serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+
+ if (captureContent) {
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, promptText);
+ }
+
+ metricParams = {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: OllamaWrapper.aiSystem,
+ };
+
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ });
+ };
+ };
+ }
}
diff --git a/sdk/typescript/src/instrumentation/openai-agents/index.ts b/sdk/typescript/src/instrumentation/openai-agents/index.ts
new file mode 100644
index 00000000..c93ee255
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/openai-agents/index.ts
@@ -0,0 +1,205 @@
+/**
+ * OpenLIT OpenAI Agents Instrumentation
+ *
+ * Registers an OpenLITTracingProcessor with the @openai/agents SDK's
+ * tracing system, and wraps Agent construction to emit create_agent spans.
+ * Mirrors the Python SDK instrumentation in
+ * sdk/python/src/openlit/instrumentation/openai_agents/.
+ */
+
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+} from '@opentelemetry/instrumentation';
+import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { SpanContext, SpanKind, trace } from '@opentelemetry/api';
+
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import { applyCustomSpanAttributes } from '../../helpers';
+import { OpenLITTracingProcessor, AgentCreationRegistry } from './processor';
+
+// Minimum supported version of @openai/agents
+const SUPPORTED_VERSIONS = ['>=0.0.3'];
+
+class AgentCreationRegistryImpl implements AgentCreationRegistry {
+ private _contexts = new Map<string, SpanContext>();
+
+ register(agentName: string, spanContext: SpanContext): void {
+ this._contexts.set(agentName, spanContext);
+ }
+
+ get(agentName: string): SpanContext | undefined {
+ return this._contexts.get(agentName);
+ }
+}
+
+export default class OpenAIAgentsInstrumentation extends InstrumentationBase {
+ private _processor: OpenLITTracingProcessor | null = null;
+ private _registry = new AgentCreationRegistryImpl();
+
+ constructor(config: InstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-openai-agents`, '1.0.0', config);
+ }
+
+ protected init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void {
+ const agentsModule = new InstrumentationNodeModuleDefinition(
+ '@openai/agents',
+ SUPPORTED_VERSIONS,
+ (moduleExports: any) => {
+ this._patch(moduleExports);
+ return moduleExports;
+ },
+ (moduleExports: any) => {
+ this._unpatch(moduleExports);
+ return moduleExports;
+ },
+ );
+ return agentsModule;
+ }
+
+ public manualPatch(moduleExports: any): void {
+ this._patch(moduleExports);
+ }
+
+ private _patch(moduleExports: any): void {
+ try {
+ const tracer = this.tracer;
+
+ // Create processor and register with the agents SDK
+ this._processor = new OpenLITTracingProcessor(tracer, this._registry);
+
+ // Try set_trace_processors first (replaces default), fall back to addTraceProcessor
+ if (typeof moduleExports.setTraceProcessors === 'function') {
+ moduleExports.setTraceProcessors([this._processor]);
+ } else if (typeof moduleExports.addTraceProcessor === 'function') {
+ moduleExports.addTraceProcessor(this._processor);
+ }
+
+ // Wrap Agent constructor to emit create_agent spans
+ const AgentClass = moduleExports.Agent;
+ if (AgentClass && typeof AgentClass === 'function') {
+ this._wrapAgentConstructor(moduleExports, tracer);
+ }
+ } catch {
+ // Module may not be installed -- silently skip
+ }
+ }
+
+ private _wrapAgentConstructor(moduleExports: any, tracer: ReturnType<typeof trace.getTracer>): void {
+ const registry = this._registry;
+ const OriginalAgent = moduleExports.Agent;
+
+ if (!OriginalAgent || typeof OriginalAgent !== 'function') return;
+
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+
+ const patchedAgent = function (this: any, ...args: any[]) {
+ // Call original constructor
+ const instance = new OriginalAgent(...args);
+
+ try {
+ const config = args[0] ?? {};
+ const name = instance.name ?? config.name ?? 'agent';
+ const spanName = `create_agent ${name}`;
+
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ },
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_ID, String(Math.random().toString(36).slice(2)));
+
+ const model = instance.model ?? config.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ }
+
+ const instructions = instance.instructions ?? config.instructions;
+ if (instructions && captureContent) {
+ const formatted = typeof instructions === 'string'
+ ? JSON.stringify([{ type: 'text', content: instructions }])
+ : JSON.stringify([{ type: 'text', content: String(instructions) }]);
+ span.setAttribute(SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, formatted);
+ }
+
+ const tools = instance.tools ?? config.tools;
+ if (tools && Array.isArray(tools) && tools.length > 0) {
+ const toolDefs = tools.slice(0, 20).map((t: any) => {
+ const tName = t.name ?? t.__name__ ?? String(t);
+ return { type: 'function', name: String(tName) };
+ });
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_DEFINITIONS, JSON.stringify(toolDefs));
+ }
+
+ const handoffs = instance.handoffs ?? config.handoffs;
+ if (handoffs && Array.isArray(handoffs) && handoffs.length > 0) {
+ const handoffNames = handoffs.slice(0, 20).map((h: any) => {
+ const hName = h.name ?? String(h);
+ return String(hName);
+ });
+ span.setAttribute('gen_ai.agent.handoffs', JSON.stringify(handoffNames));
+ }
+
+ span.setAttribute(
+ SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT,
+ OpenlitConfig.environment ?? 'default',
+ );
+ span.setAttribute(
+ SemanticConvention.GEN_AI_APPLICATION_NAME,
+ OpenlitConfig.applicationName ?? 'default',
+ );
+
+ applyCustomSpanAttributes(span);
+
+ // Store span context in registry for later Links from invoke_agent spans
+ const creationCtx = span.spanContext();
+ registry.register(String(name), creationCtx);
+
+ span.end();
+ } catch {
+ // Swallow to avoid breaking agent construction
+ }
+
+ return instance;
+ };
+
+ // Preserve prototype chain and static properties
+ Object.setPrototypeOf(patchedAgent, OriginalAgent);
+ patchedAgent.prototype = OriginalAgent.prototype;
+ Object.defineProperty(patchedAgent, 'name', { value: OriginalAgent.name });
+
+ // ESM-to-CJS interop may define exports as getter-only properties;
+ // both defineProperty and assignment may fail for ESM Module Namespace objects.
+ try {
+ Object.defineProperty(moduleExports, 'Agent', {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: patchedAgent,
+ });
+ } catch {
+ try { moduleExports.Agent = patchedAgent; } catch { /* strict mode throws */ }
+ }
+ }
+
+ private _unpatch(moduleExports: any): void {
+ try {
+ if (this._processor) {
+ // Try to clear processors
+ if (typeof moduleExports?.setTraceProcessors === 'function') {
+ moduleExports.setTraceProcessors([]);
+ }
+ this._processor = null;
+ }
+ } catch {
+ // ignore
+ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/openai-agents/processor.ts b/sdk/typescript/src/instrumentation/openai-agents/processor.ts
new file mode 100644
index 00000000..bc5e8aaf
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/openai-agents/processor.ts
@@ -0,0 +1,332 @@
+/**
+ * OpenLIT OpenAI Agents TracingProcessor implementation.
+ *
+ * Integrates with the @openai/agents TracingProcessor interface.
+ * All span data fields are read at onSpanEnd (when fully populated).
+ * Compliant with OTel GenAI semantic conventions.
+ */
+
+import {
+ context as contextApi,
+ Span as OtelSpan,
+ SpanKind,
+ SpanStatusCode,
+ Link,
+ SpanContext,
+ trace,
+} from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+
+import SemanticConvention from '../../semantic-convention';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
+import OpenlitConfig from '../../config';
+import {
+ applyCustomSpanAttributes,
+ getServerAddressForProvider,
+ setFrameworkParentContext,
+ clearFrameworkParentContext,
+} from '../../helpers';
+import {
+ getOperationType,
+ getSpanKind,
+ generateSpanName,
+ processSpanEnd,
+ recordMetrics,
+} from './utils';
+
+const [OPENAI_SERVER_ADDRESS, OPENAI_SERVER_PORT] = getServerAddressForProvider('openai');
+
+const LLM_SPAN_TYPES = new Set(['response', 'generation']);
+
+interface SpanEntry {
+ otelSpan: OtelSpan;
+ startTime: number;
+}
+
+interface TraceEntry {
+ otelSpan: OtelSpan;
+ startTime: number;
+}
+
+export interface AgentCreationRegistry {
+ register(agentName: string, spanContext: SpanContext): void;
+ get(agentName: string): SpanContext | undefined;
+}
+
+/**
+ * TracingProcessor that emits OTel GenAI-compliant spans from
+ * the @openai/agents SDK tracing lifecycle.
+ *
+ * Thread-safe by design: each trace/span entry is keyed independently.
+ * LLM span types (response, generation) are skipped -- the OpenAI
+ * provider instrumentation handles those with richer telemetry.
+ */
+export class OpenLITTracingProcessor {
+ private _tracer: ReturnType<typeof trace.getTracer>;
+ private _agentCreationRegistry: AgentCreationRegistry | null;
+
+ // SDK span_id -> SpanEntry
+ private _otelSpans = new Map<string, SpanEntry>();
+ // SDK trace_id -> TraceEntry
+ private _rootSpans = new Map<string, TraceEntry>();
+ // trace_id -> group_id (conversation id)
+ private _traceGroupIds = new Map<string, string>();
+ // Agent handoff tracker (bounded Map)
+ private _handoffTracker = new Map<string, string>();
+
+ constructor(
+ tracer: ReturnType<typeof trace.getTracer>,
+ agentCreationRegistry: AgentCreationRegistry | null = null,
+ ) {
+ this._tracer = tracer;
+ this._agentCreationRegistry = agentCreationRegistry;
+ }
+
+ // ------------------------------------------------------------------
+ // Trace lifecycle
+ // ------------------------------------------------------------------
+ async onTraceStart(sdkTrace: any): Promise<void> {
+ try {
+ const traceId: string = sdkTrace.traceId ?? 'unknown';
+ const traceName: string = sdkTrace.name ?? 'workflow';
+ const groupId: string | null = sdkTrace.groupId ?? null;
+
+ const operation = SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
+ const spanName = `${operation} ${traceName}`;
+
+ const otelSpan = this._tracer.startSpan(spanName, {
+ kind: SpanKind.INTERNAL,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operation,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ },
+ });
+
+ const startTime = Date.now();
+ this._rootSpans.set(traceId, { otelSpan, startTime });
+ if (groupId) {
+ this._traceGroupIds.set(traceId, String(groupId));
+ }
+
+ setFrameworkParentContext(trace.setSpan(contextApi.active(), otelSpan));
+ } catch {
+ // swallow
+ }
+ }
+
+ async onTraceEnd(sdkTrace: any): Promise<void> {
+ try {
+ const traceId: string = sdkTrace.traceId ?? 'unknown';
+ const traceName: string = sdkTrace.name ?? 'workflow';
+
+ const entry = this._rootSpans.get(traceId);
+ this._rootSpans.delete(traceId);
+ const groupId = this._traceGroupIds.get(traceId) ?? null;
+ this._traceGroupIds.delete(traceId);
+
+ if (!entry) return;
+
+ const { otelSpan, startTime } = entry;
+ const endTime = Date.now();
+ const durationMs = endTime - startTime;
+
+ // Set common framework attributes
+ otelSpan.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ otelSpan.setAttribute(
+ SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ );
+ otelSpan.setAttribute(
+ SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ );
+ if (OPENAI_SERVER_ADDRESS) {
+ otelSpan.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ if (OPENAI_SERVER_PORT) {
+ otelSpan.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+ }
+ }
+ otelSpan.setAttribute(
+ SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT,
+ OpenlitConfig.environment ?? 'default',
+ );
+ otelSpan.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ otelSpan.setAttribute(
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,
+ durationMs / 1000,
+ );
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, traceName);
+
+ if (groupId) {
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, groupId);
+ }
+
+ applyCustomSpanAttributes(otelSpan);
+
+ // Error handling
+ const error = sdkTrace.error;
+ if (error) {
+ const errorType =
+ typeof error === 'object' && error !== null
+ ? (error as any).constructor?.name || (error as any).code || '_OTHER'
+ : '_OTHER';
+ const errorMsg =
+ typeof error === 'object' && error !== null
+ ? (error as any).message ?? String(error)
+ : String(error);
+ otelSpan.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: errorMsg });
+ } else {
+ otelSpan.setStatus({ code: SpanStatusCode.OK });
+ }
+
+ // Metrics
+ if (!OpenlitConfig.disableMetrics) {
+ recordMetrics(
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ durationMs / 1000,
+ null,
+ );
+ }
+
+ otelSpan.end();
+ clearFrameworkParentContext();
+ } catch {
+ // swallow
+ }
+ }
+
+ // ------------------------------------------------------------------
+ // Span lifecycle
+ // ------------------------------------------------------------------
+ async onSpanStart(sdkSpan: any): Promise<void> {
+ try {
+ const spanData = sdkSpan.spanData;
+ const spanType: string = spanData?.type ?? 'unknown';
+
+ // Skip LLM span types -- let the OpenAI provider instrumentation handle them
+ if (LLM_SPAN_TYPES.has(spanType)) return;
+
+ const traceId: string = sdkSpan.traceId ?? 'unknown';
+ const sdkSpanId: string | null = sdkSpan.spanId ?? null;
+ const parentSdkId: string | null = sdkSpan.parentId ?? null;
+
+ const operation = getOperationType(spanType);
+ const kind = getSpanKind(operation);
+ const spanName = generateSpanName(spanData);
+
+ // Find parent OTel span context
+ let parentCtx = contextApi.active();
+ if (parentSdkId && this._otelSpans.has(parentSdkId)) {
+ const parentEntry = this._otelSpans.get(parentSdkId)!;
+ parentCtx = trace.setSpan(contextApi.active(), parentEntry.otelSpan);
+ } else if (this._rootSpans.has(traceId)) {
+ const rootEntry = this._rootSpans.get(traceId)!;
+ parentCtx = trace.setSpan(contextApi.active(), rootEntry.otelSpan);
+ }
+
+ // Span links: connect invoke_agent back to create_agent
+ const links: Link[] = [];
+ if (spanType === 'agent' && this._agentCreationRegistry) {
+ const agentName = spanData.name;
+ if (agentName) {
+ const creationCtx = this._agentCreationRegistry.get(String(agentName));
+ if (creationCtx) {
+ links.push({ context: creationCtx, attributes: {} });
+ }
+ }
+ }
+
+ const otelSpan = this._tracer.startSpan(
+ spanName,
+ {
+ kind,
+ links,
+ attributes: {
+ [SemanticConvention.GEN_AI_OPERATION]: operation,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ },
+ },
+ parentCtx,
+ );
+
+ const startTime = Date.now();
+
+ if (sdkSpanId) {
+ this._otelSpans.set(sdkSpanId, { otelSpan, startTime });
+ }
+
+ setFrameworkParentContext(trace.setSpan(parentCtx, otelSpan));
+ } catch {
+ // swallow
+ }
+ }
+
+ async onSpanEnd(sdkSpan: any): Promise<void> {
+ try {
+ const spanData = sdkSpan.spanData;
+ const spanType: string = spanData?.type ?? 'unknown';
+
+ // Skip LLM span types
+ if (LLM_SPAN_TYPES.has(spanType)) return;
+
+ const sdkSpanId: string | null = sdkSpan.spanId ?? null;
+ const traceId: string = sdkSpan.traceId ?? 'unknown';
+
+ if (!sdkSpanId) return;
+ const entry = this._otelSpans.get(sdkSpanId);
+ this._otelSpans.delete(sdkSpanId);
+ if (!entry) return;
+
+ const { otelSpan, startTime } = entry;
+ const conversationId = this._traceGroupIds.get(traceId) ?? null;
+
+ processSpanEnd(
+ otelSpan,
+ sdkSpan,
+ startTime,
+ conversationId,
+ this._handoffTracker,
+ );
+
+ otelSpan.end();
+
+ // Restore parent context so subsequent provider spans nest correctly
+ const parentSdkId: string | null = sdkSpan.parentId ?? null;
+ if (parentSdkId && this._otelSpans.has(parentSdkId)) {
+ const parentEntry = this._otelSpans.get(parentSdkId)!;
+ setFrameworkParentContext(trace.setSpan(contextApi.active(), parentEntry.otelSpan));
+ } else if (this._rootSpans.has(traceId)) {
+ const rootEntry = this._rootSpans.get(traceId)!;
+ setFrameworkParentContext(trace.setSpan(contextApi.active(), rootEntry.otelSpan));
+ }
+ } catch {
+ // swallow
+ }
+ }
+
+ // ------------------------------------------------------------------
+ // Lifecycle management
+ // ------------------------------------------------------------------
+ async forceFlush(): Promise<void> {
+ try {
+ for (const [, { otelSpan }] of this._otelSpans) {
+ try { otelSpan.end(); } catch { /* ignore */ }
+ }
+ this._otelSpans.clear();
+
+ for (const [, { otelSpan }] of this._rootSpans) {
+ try { otelSpan.end(); } catch { /* ignore */ }
+ }
+ this._rootSpans.clear();
+ this._traceGroupIds.clear();
+ } catch {
+ // swallow
+ }
+ }
+
+ async shutdown(): Promise<void> {
+ await this.forceFlush();
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/openai-agents/utils.ts b/sdk/typescript/src/instrumentation/openai-agents/utils.ts
new file mode 100644
index 00000000..0dfa5bf9
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/openai-agents/utils.ts
@@ -0,0 +1,690 @@
+/**
+ * OpenAI Agents utilities for OTel GenAI semantic convention compliant telemetry.
+ *
+ * Maps SDK span types to OTel operation names, determines SpanKind,
+ * generates span names, and sets type-specific attributes on OTel spans.
+ *
+ * All attribute setting happens at on_span_end (when span data is fully
+ * populated), matching the Python SDK pattern.
+ */
+
+import { Span as OtelSpan, SpanKind, SpanStatusCode } from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+import SemanticConvention from '../../semantic-convention';
+import { SDK_NAME, SDK_VERSION } from '../../constant';
+import OpenlitConfig from '../../config';
+import Metrics from '../../otel/metrics';
+import { applyCustomSpanAttributes, getServerAddressForProvider } from '../../helpers';
+
+const [OPENAI_SERVER_ADDRESS, OPENAI_SERVER_PORT] = getServerAddressForProvider('openai');
+
+// SDK span_data.type -> gen_ai.operation.name
+const OPERATION_MAP: Record<string, string> = {
+ agent: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ generation: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ response: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ function: SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ handoff: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ guardrail: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ custom: SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ transcription: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ speech: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ speech_group: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ mcp_tools: SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+};
+
+// SpanKind per operation (OTel GenAI spec)
+const SPAN_KIND_MAP: Record<string, SpanKind> = {
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS]: SpanKind.INTERNAL,
+ [SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT]: SpanKind.CLIENT,
+};
+
+const MAX_HANDOFFS = 1000;
+
+export function getOperationType(spanType: string): string {
+ return OPERATION_MAP[spanType] ?? SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT;
+}
+
+export function getSpanKind(operationType: string): SpanKind {
+ return SPAN_KIND_MAP[operationType] ?? SpanKind.INTERNAL;
+}
+
+export function generateSpanName(spanData: any): string {
+ const spanType: string = spanData?.type ?? 'unknown';
+ const operation = getOperationType(spanType);
+
+ if (spanType === 'agent') {
+ const name = spanData.name ?? 'agent';
+ return `${operation} ${name}`;
+ }
+
+ if (spanType === 'generation' || spanType === 'response') {
+ const model = extractModelFromSpanData(spanData);
+ return model ? `${operation} ${model}` : operation;
+ }
+
+ if (spanType === 'function') {
+ const name = spanData.name ?? 'function';
+ return `${operation} ${name}`;
+ }
+
+ if (spanType === 'handoff') {
+ const toAgent = spanData.toAgent ?? spanData.to_agent ?? 'unknown';
+ return `${operation} ${toAgent}`;
+ }
+
+ if (spanType === 'guardrail') {
+ const name = spanData.name ?? 'guardrail';
+ return `${operation} ${name}`;
+ }
+
+ if (spanType === 'mcp_tools') {
+ return `${operation} mcp_list_tools`;
+ }
+
+ if (spanType === 'transcription') return `${operation} transcription`;
+ if (spanType === 'speech') return `${operation} speech`;
+ if (spanType === 'speech_group') return `${operation} speech_group`;
+
+ if (spanType === 'custom') {
+ const name = spanData.name ?? 'custom';
+ return `${operation} ${name}`;
+ }
+
+ return operation;
+}
+
+/**
+ * Set all OTel-compliant attributes on the OTel span using fully-populated SDK data.
+ * Called from on_span_end in the processor.
+ */
+export function processSpanEnd(
+ otelSpan: OtelSpan,
+ sdkSpan: any,
+ startTime: number,
+ conversationId: string | null,
+ handoffTracker: Map<string, string>,
+): void {
+ try {
+ const endTime = Date.now();
+ const spanData = sdkSpan.spanData;
+ const spanType: string = spanData?.type ?? 'unknown';
+ const operation = getOperationType(spanType);
+ const modelName = extractModelFromSpanData(spanData);
+
+ const updatedName = generateSpanName(spanData);
+ try {
+ otelSpan.updateName(updatedName);
+ } catch {
+ // updateName may not be available on all span implementations
+ }
+
+ setCommonFrameworkAttributes(otelSpan, operation, modelName, endTime - startTime);
+
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_OPERATION, operation);
+ otelSpan.setAttribute(
+ SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ );
+
+ if (conversationId) {
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_CONVERSATION_ID, conversationId);
+ }
+
+ if (modelName) {
+ otelSpan.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelName);
+ }
+
+ // Dispatch to type-specific handler
+ const captureContent = OpenlitConfig.captureMessageContent ?? true;
+ if (spanType === 'agent') {
+ setAgentAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'response') {
+ setResponseAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'generation') {
+ setGenerationAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'function') {
+ setFunctionAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'handoff') {
+ setHandoffAttributes(otelSpan, spanData, handoffTracker, sdkSpan.traceId ?? '');
+ } else if (spanType === 'guardrail') {
+ setGuardrailAttributes(otelSpan, spanData);
+ } else if (spanType === 'transcription') {
+ setTranscriptionAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'speech') {
+ setSpeechAttributes(otelSpan, spanData, captureContent);
+ } else if (spanType === 'mcp_tools') {
+ setMcpToolsAttributes(otelSpan, spanData);
+ } else if (spanType === 'custom') {
+ setCustomAttributes(otelSpan, spanData);
+ }
+
+ // Error handling
+ const error = sdkSpan.error;
+ if (error) {
+ const errorType =
+ typeof error === 'object' && error !== null
+ ? (error as any).constructor?.name || (error as any).code || '_OTHER'
+ : '_OTHER';
+ const errorMsg =
+ typeof error === 'object' && error !== null
+ ? (error as any).message ?? String(error)
+ : String(error);
+ otelSpan.setAttribute(SemanticConvention.ERROR_TYPE, errorType);
+ otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: errorMsg });
+ } else {
+ otelSpan.setStatus({ code: SpanStatusCode.OK });
+ }
+
+ // Metrics
+ if (!OpenlitConfig.disableMetrics) {
+ recordMetrics(operation, (endTime - startTime) / 1000, modelName);
+ }
+ } catch {
+ // Swallow to avoid breaking the agent run
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Common framework span attributes (mirrors Python common_framework_span_attributes)
+// ---------------------------------------------------------------------------
+function setCommonFrameworkAttributes(
+ span: OtelSpan,
+ operation: string,
+ modelName: string | null,
+ durationMs: number,
+): void {
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, SDK_VERSION);
+ span.setAttribute(
+ SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operation);
+ if (modelName) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, modelName);
+ }
+ if (OPENAI_SERVER_ADDRESS) {
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ if (OPENAI_SERVER_PORT) {
+ span.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+ }
+ }
+ span.setAttribute(
+ SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT,
+ OpenlitConfig.environment ?? 'default',
+ );
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName ?? 'default');
+ span.setAttribute(
+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,
+ durationMs / 1000,
+ );
+ applyCustomSpanAttributes(span);
+}
+
+// ---------------------------------------------------------------------------
+// Agent (invoke_agent)
+// ---------------------------------------------------------------------------
+function setAgentAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const name = spanData.name;
+ if (name) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ }
+
+ const agentId = spanData.agentId ?? spanData.agent_id;
+ if (agentId && typeof agentId === 'string') {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_ID, agentId);
+ }
+
+ const outputType = spanData.outputType ?? spanData.output_type;
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, mapOutputType(outputType));
+
+ if (captureContent) {
+ const tools: any[] | undefined = spanData.tools;
+ if (tools && tools.length > 0) {
+ const toolDefs = tools.slice(0, 20).map((t: any) => ({
+ type: 'function',
+ name: String(typeof t === 'string' ? t : t),
+ }));
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_DEFINITIONS, JSON.stringify(toolDefs));
+ }
+
+ const handoffs: any[] | undefined = spanData.handoffs;
+ if (handoffs && handoffs.length > 0) {
+ span.setAttribute(
+ 'gen_ai.agent.handoffs',
+ JSON.stringify(handoffs.slice(0, 20).map(String)),
+ );
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Response (chat -- Response API)
+// ---------------------------------------------------------------------------
+function setResponseAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const response = spanData.response;
+ if (!response) return;
+
+ const model = response.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(model));
+ }
+
+ const respId = response.id;
+ if (respId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, String(respId));
+ }
+
+ const usage = response.usage;
+ if (usage) {
+ const inputTokens = usage.input_tokens ?? usage.inputTokens;
+ const outputTokens = usage.output_tokens ?? usage.outputTokens;
+ if (inputTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ }
+ if (outputTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ }
+ }
+
+ const outputItems = response.output;
+ if (Array.isArray(outputItems)) {
+ const finishReasons: string[] = [];
+ for (const item of outputItems) {
+ const status = item.status;
+ if (status) finishReasons.push(String(status));
+ }
+ if (finishReasons.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, finishReasons);
+ }
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+
+ if (captureContent) {
+ captureResponseMessages(span, spanData, response);
+ }
+ } catch {
+ // swallow
+ }
+}
+
+function captureResponseMessages(span: OtelSpan, spanData: any, response: any): void {
+ try {
+ const rawInput = spanData.input;
+ if (rawInput) {
+ let messages: any[];
+ if (typeof rawInput === 'string') {
+ messages = [formatInputMessage('user', rawInput)];
+ } else if (Array.isArray(rawInput)) {
+ messages = [];
+ for (const item of rawInput.slice(0, 20)) {
+ if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
+ if (item.role) {
+ messages.push(item);
+ } else {
+ messages.push(formatInputMessage('user', item));
+ }
+ } else {
+ const role = String(item?.role ?? 'user');
+ const content = item?.content ?? String(item);
+ messages.push(formatInputMessage(role, content));
+ }
+ }
+ } else {
+ messages = [formatInputMessage('user', rawInput)];
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(messages));
+ }
+
+ const outputItems = response.output;
+ if (Array.isArray(outputItems)) {
+ const outMessages: any[] = [];
+ for (const item of outputItems.slice(0, 20)) {
+ const itemType = item.type;
+ if (itemType === 'message') {
+ const contentParts = item.content ?? [];
+ const textParts: string[] = [];
+ for (const part of contentParts) {
+ const text = part.text;
+ if (text) textParts.push(String(text));
+ }
+ if (textParts.length > 0) {
+ outMessages.push(formatOutputMessage(textParts.join(' ')));
+ }
+ } else if (itemType === 'function_call') {
+ outMessages.push({
+ role: 'assistant',
+ parts: [
+ {
+ type: 'tool_call',
+ name: item.name ?? 'unknown',
+ arguments: item.arguments ?? '',
+ },
+ ],
+ });
+ }
+ }
+ if (outMessages.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, JSON.stringify(outMessages));
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Generation (chat -- Chat Completions API)
+// ---------------------------------------------------------------------------
+function setGenerationAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const model = spanData.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(model));
+ }
+
+ const usage = spanData.usage;
+ if (usage && typeof usage === 'object') {
+ const inputTokens = usage.input_tokens ?? usage.inputTokens;
+ const outputTokens = usage.output_tokens ?? usage.outputTokens;
+ if (inputTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ }
+ if (outputTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ }
+ }
+
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+
+ if (captureContent) {
+ const rawInput = spanData.input;
+ if (rawInput) {
+ if (Array.isArray(rawInput)) {
+ const messages = rawInput.slice(0, 20).map((msg: any) =>
+ typeof msg === 'object' && msg !== null ? msg : formatInputMessage('user', msg),
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, JSON.stringify(messages));
+ } else {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ JSON.stringify([formatInputMessage('user', rawInput)]),
+ );
+ }
+ }
+
+ const rawOutput = spanData.output;
+ if (rawOutput) {
+ if (Array.isArray(rawOutput)) {
+ const messages = rawOutput.slice(0, 20).map((msg: any) =>
+ typeof msg === 'object' && msg !== null ? msg : formatOutputMessage(msg),
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, JSON.stringify(messages));
+ } else {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ JSON.stringify([formatOutputMessage(rawOutput)]),
+ );
+ }
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Function / Tool (execute_tool)
+// ---------------------------------------------------------------------------
+function setFunctionAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const name = spanData.name;
+ if (name) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, String(name));
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, 'function');
+
+ if (captureContent) {
+ const toolInput = spanData.input;
+ if (toolInput != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, String(toolInput));
+ }
+ const toolOutput = spanData.output;
+ if (toolOutput != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, String(toolOutput));
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Handoff (invoke_agent for target)
+// ---------------------------------------------------------------------------
+function setHandoffAttributes(
+ span: OtelSpan,
+ spanData: any,
+ handoffTracker: Map<string, string>,
+ traceId: string,
+): void {
+ try {
+ const toAgent = spanData.toAgent ?? spanData.to_agent;
+ const fromAgent = spanData.fromAgent ?? spanData.from_agent;
+
+ if (toAgent) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(toAgent));
+ const key = `${toAgent}:${traceId}`;
+ handoffTracker.set(key, fromAgent ? String(fromAgent) : 'unknown');
+ if (handoffTracker.size > MAX_HANDOFFS) {
+ const firstKey = handoffTracker.keys().next().value;
+ if (firstKey !== undefined) handoffTracker.delete(firstKey);
+ }
+ }
+
+ if (fromAgent) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_SOURCE, String(fromAgent));
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Guardrail (invoke_agent)
+// ---------------------------------------------------------------------------
+function setGuardrailAttributes(span: OtelSpan, spanData: any): void {
+ try {
+ const name = spanData.name;
+ if (name) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ }
+ const triggered = spanData.triggered;
+ if (triggered != null) {
+ span.setAttribute('gen_ai.guardrail.triggered', Boolean(triggered));
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Transcription (chat)
+// ---------------------------------------------------------------------------
+function setTranscriptionAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const model = spanData.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(model));
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+
+ if (captureContent) {
+ const output = spanData.output;
+ if (output) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ JSON.stringify([formatOutputMessage(output)]),
+ );
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Speech (chat)
+// ---------------------------------------------------------------------------
+function setSpeechAttributes(span: OtelSpan, spanData: any, captureContent: boolean): void {
+ try {
+ const model = spanData.model;
+ if (model) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, String(model));
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, String(model));
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'speech');
+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, OPENAI_SERVER_ADDRESS);
+ span.setAttribute(SemanticConvention.SERVER_PORT, OPENAI_SERVER_PORT);
+
+ if (captureContent) {
+ const textInput = spanData.input;
+ if (textInput) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ JSON.stringify([formatInputMessage('user', textInput)]),
+ );
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// MCP List Tools (execute_tool)
+// ---------------------------------------------------------------------------
+function setMcpToolsAttributes(span: OtelSpan, spanData: any): void {
+ try {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, 'mcp_list_tools');
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, 'function');
+
+ const server = spanData.server;
+ if (server) {
+ span.setAttribute('gen_ai.mcp.server', String(server));
+ }
+
+ const result = spanData.result;
+ if (result) {
+ const items = Array.isArray(result) ? result.slice(0, 50) : result;
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_RESULT, JSON.stringify(items));
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Custom (invoke_agent)
+// ---------------------------------------------------------------------------
+function setCustomAttributes(span: OtelSpan, spanData: any): void {
+ try {
+ const name = spanData.name;
+ if (name) {
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_NAME, String(name));
+ }
+ const data = spanData.data;
+ if (data && typeof data === 'object') {
+ try {
+ span.setAttribute('gen_ai.custom.data', JSON.stringify(data));
+ } catch {
+ // non-serialisable data
+ }
+ }
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Metrics
+// ---------------------------------------------------------------------------
+export function recordMetrics(
+ operationType: string,
+ durationSeconds: number,
+ requestModel: string | null,
+): void {
+ try {
+ const attributes: Record<string, string | number> = {
+ [SemanticConvention.GEN_AI_OPERATION]: operationType,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ [ATTR_SERVICE_NAME]: OpenlitConfig.applicationName ?? 'default',
+ [SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]: OpenlitConfig.environment ?? 'default',
+ };
+ if (requestModel) {
+ attributes[SemanticConvention.GEN_AI_REQUEST_MODEL] = requestModel;
+ }
+ if (OPENAI_SERVER_ADDRESS) {
+ attributes[SemanticConvention.SERVER_ADDRESS] = OPENAI_SERVER_ADDRESS;
+ }
+ if (OPENAI_SERVER_PORT) {
+ attributes[SemanticConvention.SERVER_PORT] = OPENAI_SERVER_PORT;
+ }
+
+ Metrics.genaiClientOperationDuration?.record(durationSeconds, attributes);
+ } catch {
+ // swallow
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Helpers
+// ---------------------------------------------------------------------------
+export function extractModelFromSpanData(spanData: any): string | null {
+ const model = spanData?.model;
+ if (model) return String(model);
+
+ const response = spanData?.response;
+ if (response) {
+ const rModel = response.model;
+ if (rModel) return String(rModel);
+ }
+
+ return null;
+}
+
+function mapOutputType(outputType: any): string {
+ if (outputType == null) return SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
+ const s = String(outputType).toLowerCase();
+ if (s.includes('dict') || s.includes('json')) return SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
+ return SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
+}
+
+function formatInputMessage(role: string, content: any): Record<string, any> {
+ return { role, parts: [{ type: 'text', content: String(content) }] };
+}
+
+function formatOutputMessage(content: any): Record<string, any> {
+ return {
+ role: 'assistant',
+ parts: [{ type: 'text', content: String(content) }],
+ };
+}
diff --git a/sdk/typescript/src/instrumentation/openai/index.ts b/sdk/typescript/src/instrumentation/openai/index.ts
index 05b47d59..2820a787 100644
--- a/sdk/typescript/src/instrumentation/openai/index.ts
+++ b/sdk/typescript/src/instrumentation/openai/index.ts
@@ -6,7 +6,6 @@ import {
} from '@opentelemetry/instrumentation';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { INSTRUMENTATION_PREFIX } from '../../constant';
-import OpenAI from 'openai';
import OpenAIWrapper from './wrapper';
export interface OpenAIInstrumentationConfig extends InstrumentationConfig {}
@@ -37,7 +36,7 @@ export default class OpenlitOpenAIInstrumentation extends InstrumentationBase {
this._patch(openai);
}
- protected _patch(moduleExports: typeof OpenAI) {
+ protected _patch(moduleExports: any) {
try {
if (isWrapped(moduleExports.OpenAI.Chat.Completions.prototype.create)) {
this._unwrap(moduleExports.OpenAI.Chat.Completions.prototype, 'create');
@@ -117,7 +116,7 @@ export default class OpenlitOpenAIInstrumentation extends InstrumentationBase {
}
}
- protected _unpatch(moduleExports: typeof OpenAI) {
+ protected _unpatch(moduleExports: any) {
this._unwrap(moduleExports.OpenAI.Chat.Completions.prototype, 'create');
this._unwrap(moduleExports.OpenAI.Embeddings.prototype, 'create');
this._unwrap(moduleExports.OpenAI.FineTuning.prototype, 'jobs');
diff --git a/sdk/typescript/src/instrumentation/openai/wrapper.ts b/sdk/typescript/src/instrumentation/openai/wrapper.ts
index 98000e45..5e32d2db 100644
--- a/sdk/typescript/src/instrumentation/openai/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/openai/wrapper.ts
@@ -1,9 +1,22 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_OPENAI,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: OpenAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OpenAIWrapper.serverPort,
+ };
+}
+
class OpenAIWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_OPENAI;
static serverAddress = 'api.openai.com';
@@ -12,9 +25,16 @@ class OpenAIWrapper extends BaseWrapper {
const genAIEndpoint = 'openai.resources.chat.completions';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'gpt-4o';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -36,7 +56,16 @@ class OpenAIWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: OpenAIWrapper.aiSystem,
+ serverAddress: OpenAIWrapper.serverAddress,
+ serverPort: OpenAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
+ throw e;
});
};
};
@@ -64,9 +93,9 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -120,7 +149,7 @@ class OpenAIWrapper extends BaseWrapper {
},
};
- let toolCalls: any[] = [];
+ const toolCalls: any[] = [];
for await (const chunk of response) {
timestamps.push(Date.now());
@@ -146,14 +175,12 @@ class OpenAIWrapper extends BaseWrapper {
result.choices[0].message.content += chunk.choices[0].delta.content;
}
- // Improved tool calls handling for streaming
if (chunk.choices[0]?.delta.tool_calls) {
const deltaTools = chunk.choices[0].delta.tool_calls;
for (const tool of deltaTools) {
const idx = tool.index || 0;
- // Extend array if needed
while (toolCalls.length <= idx) {
toolCalls.push({
id: '',
@@ -163,7 +190,6 @@ class OpenAIWrapper extends BaseWrapper {
}
if (tool.id) {
- // New tool call
toolCalls[idx].id = tool.id;
toolCalls[idx].type = tool.type || 'function';
if (tool.function?.name) {
@@ -173,7 +199,6 @@ class OpenAIWrapper extends BaseWrapper {
toolCalls[idx].function.arguments = tool.function.arguments;
}
} else if (tool.function?.arguments) {
- // Append arguments to existing tool call
toolCalls[idx].function.arguments += tool.function.arguments;
}
}
@@ -212,7 +237,6 @@ class OpenAIWrapper extends BaseWrapper {
args[0].tools = tools;
- // Calculate TTFT and TBT
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -232,9 +256,9 @@ class OpenAIWrapper extends BaseWrapper {
return result;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -256,7 +280,8 @@ class OpenAIWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'gpt-4o';
const {
messages,
frequency_penalty = 0,
@@ -269,44 +294,47 @@ class OpenAIWrapper extends BaseWrapper {
top_p,
user,
stream = false,
- tools,
+ tools: _tools,
+ service_tier,
} = args[0];
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens || -1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, seed ? String(seed) : '');
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
if (stop) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(stop) ? stop : [stop]);
}
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
+ }
+ if (service_tier && service_tier !== 'auto') {
+ span.setAttribute(SemanticConvention.OPENAI_REQUEST_SERVICE_TIER, service_tier);
}
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
}
- // Request Params attributes : End
-
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- const model = result.model || 'gpt-3.5-turbo';
- const responseModel = result.model || model;
+ const responseModel = result.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- // Calculate cost of the operation
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
result.usage.prompt_tokens,
result.usage.completion_tokens
@@ -314,7 +342,7 @@ class OpenAIWrapper extends BaseWrapper {
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -322,62 +350,34 @@ class OpenAIWrapper extends BaseWrapper {
serverPort: OpenAIWrapper.serverPort,
});
- // Response model
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- // OpenAI-specific attributes
+ span.setAttribute(SemanticConvention.OPENAI_API_TYPE, 'chat_completions');
if (result.system_fingerprint) {
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT, result.system_fingerprint);
+ span.setAttribute(SemanticConvention.OPENAI_RESPONSE_SYSTEM_FINGERPRINT, result.system_fingerprint);
}
if (result.service_tier) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER, result.service_tier);
+ span.setAttribute(SemanticConvention.OPENAI_RESPONSE_SERVICE_TIER, result.service_tier);
}
- // Token usage
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, result.usage.prompt_tokens);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
- result.usage.completion_tokens
- );
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, result.usage.total_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.usage.total_tokens);
+ const inputTokens = result.usage.prompt_tokens;
+ const outputTokens = result.usage.completion_tokens;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- // Enhanced token details
- if (result.usage.completion_tokens_details) {
- if (result.usage.completion_tokens_details.reasoning_tokens) {
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_REASONING_TOKENS,
- result.usage.completion_tokens_details.reasoning_tokens
- );
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_COMPLETION_TOKENS_DETAILS_REASONING,
- result.usage.completion_tokens_details.reasoning_tokens
- );
- }
- if (result.usage.completion_tokens_details.audio_tokens) {
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_COMPLETION_TOKENS_DETAILS_AUDIO,
- result.usage.completion_tokens_details.audio_tokens
- );
- }
+ if (result.usage.prompt_tokens_details?.cached_tokens) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS,
+ result.usage.prompt_tokens_details.cached_tokens
+ );
}
-
- if (result.usage.prompt_tokens_details) {
- if (result.usage.prompt_tokens_details.cached_tokens) {
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_PROMPT_TOKENS_DETAILS_CACHE_READ,
- result.usage.prompt_tokens_details.cached_tokens
- );
- }
- if (result.usage.prompt_tokens_details.audio_tokens) {
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_PROMPT_TOKENS_DETAILS_CACHE_WRITE,
- result.usage.prompt_tokens_details.audio_tokens
- );
- }
+ if (result.usage.prompt_tokens_details?.cache_creation_tokens) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS,
+ result.usage.prompt_tokens_details.cache_creation_tokens
+ );
}
- // TTFT and TBT metrics
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -385,7 +385,6 @@ class OpenAIWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Finish reason
if (result.choices[0].finish_reason) {
span.setAttribute(
SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
@@ -393,19 +392,16 @@ class OpenAIWrapper extends BaseWrapper {
);
}
- // Output type
const outputType = typeof result.choices[0].message.content === 'string'
? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
: SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
- // Tool calls handling
if (result.choices[0].message.tool_calls) {
const toolCalls = result.choices[0].message.tool_calls;
const toolNames = toolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
const toolArgs = toolCalls.map((t: any) => t.function?.arguments || '').filter(Boolean);
- const toolTypes = toolCalls.map((t: any) => t.type || '').filter(Boolean);
if (toolNames.length > 0) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
@@ -414,29 +410,46 @@ class OpenAIWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
}
if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- }
- if (toolTypes.length > 0) {
- const toolTypesStr = toolTypes.join(', ');
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolTypesStr);
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, toolTypesStr);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
}
- // Content
- if (traceContent) {
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
const toolCalls = result.choices[0].message.tool_calls;
- const outputJson = OpenLitHelper.buildOutputMessages(
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
result.choices[0].message.content || '',
result.choices[0].finish_reason || 'stop',
toolCalls
);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputJson);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: OpenAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OpenAIWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.choices[0].finish_reason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -445,34 +458,35 @@ class OpenAIWrapper extends BaseWrapper {
static _patchEmbedding(tracer: Tracer): any {
const genAIEndpoint = 'openai.resources.embeddings';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'text-embedding-ada-002';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams: BaseSpanAttributes | undefined;
try {
const response = await originalMethod.apply(this, args);
- const model = response.model || 'text-embedding-ada-002';
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const _responseModel = response.model || requestModel;
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost = OpenLitHelper.getEmbedModelCost(
- model,
+ requestModel,
pricingInfo,
response.usage.prompt_tokens
);
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING
- );
-
const { dimensions, encoding_format = 'float', input, user } = args[0];
- // Set base span attributes
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -481,37 +495,23 @@ class OpenAIWrapper extends BaseWrapper {
});
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
-
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS, [encoding_format]);
if (dimensions) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_EMBEDDING_DIMENSION, dimensions);
- }
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ span.setAttribute(SemanticConvention.GEN_AI_EMBEDDINGS_DIMENSION_COUNT, dimensions);
}
- if (traceContent) {
+ if (captureContent) {
const formattedInput = typeof input === 'string' ? input : JSON.stringify(input);
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, formattedInput);
}
- // Request Params attributes : End
span.setAttribute(
SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
response.usage.prompt_tokens
);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
- response.usage.total_tokens
- );
- span.setAttribute(
- SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
- response.usage.prompt_tokens
- );
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -537,13 +537,19 @@ class OpenAIWrapper extends BaseWrapper {
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'gpt-3.5-turbo';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_FINETUNING} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_FINETUNING, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
let metricParams;
try {
const response = await originalMethod.apply(this, args);
- const model = response.model || 'gpt-3.5-turbo';
const {
hyperparameters = {},
suffix = '',
@@ -552,23 +558,15 @@ class OpenAIWrapper extends BaseWrapper {
validation_file,
} = args[0];
- // Set base span attributes
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
aiSystem: OpenAIWrapper.aiSystem,
serverAddress: OpenAIWrapper.serverAddress,
serverPort: OpenAIWrapper.serverPort,
});
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_FINETUNING
- );
-
- // Request Params attributes : Start
-
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TRAINING_FILE, training_file);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_VALIDATION_FILE, validation_file);
span.setAttribute(
@@ -584,7 +582,6 @@ class OpenAIWrapper extends BaseWrapper {
hyperparameters?.n_epochs || 'auto'
);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FINETUNE_MODEL_SUFFIX, suffix);
- // Request Params attributes : End
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, response.id);
span.setAttribute(
@@ -593,10 +590,9 @@ class OpenAIWrapper extends BaseWrapper {
);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FINETUNE_STATUS, response.status);
- // Store metric parameters for use after span ends
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
aiSystem: OpenAIWrapper.aiSystem,
};
@@ -604,9 +600,9 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -618,11 +614,18 @@ class OpenAIWrapper extends BaseWrapper {
static _patchImageGenerate(tracer: Tracer): any {
const genAIEndpoint = 'openai.resources.images';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'dall-e-2';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams;
try {
const response = await originalMethod.apply(this, args);
@@ -636,23 +639,16 @@ class OpenAIWrapper extends BaseWrapper {
user,
} = args[0];
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE
- );
-
- const model = response.model || 'dall-e-2';
+ const responseModel = response.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
-
- // Calculate cost of the operation
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost =
(response.data?.length || 1) *
- OpenLitHelper.getImageModelCost(model, pricingInfo, size, quality);
+ OpenLitHelper.getImageModelCost(responseModel, pricingInfo, size, quality);
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -660,36 +656,29 @@ class OpenAIWrapper extends BaseWrapper {
serverPort: OpenAIWrapper.serverPort,
});
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE, size);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY, quality);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_STYLE, style);
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, prompt);
}
- // Request Params attributes : End
-
- let imagesCount = 0;
if (response.data) {
+ const imageUrls: string[] = [];
+ const revisedPrompts: string[] = [];
for (const items of response.data) {
- span.setAttribute(
- `${SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT}.${imagesCount}`,
- items.revised_prompt || ''
- );
-
- const attributeName = `${SemanticConvention.GEN_AI_RESPONSE_IMAGE}.${imagesCount}`;
- span.setAttribute(attributeName, items[response_format]);
-
- imagesCount++;
+ revisedPrompts.push(items.revised_prompt || '');
+ const value = items[response_format];
+ imageUrls.push(value && !String(value).startsWith('data:') ? value : '[base64_image_data]');
}
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_IMAGE, imageUrls);
+ span.setAttribute(SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT, revisedPrompts);
}
- // Store metric parameters for use after span ends
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -698,9 +687,9 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -712,11 +701,18 @@ class OpenAIWrapper extends BaseWrapper {
static _patchImageVariation(tracer: Tracer): any {
const genAIEndpoint = 'openai.resources.images';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'dall-e-2';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams;
try {
const response = await originalMethod.apply(this, args);
@@ -730,24 +726,18 @@ class OpenAIWrapper extends BaseWrapper {
user,
} = args[0];
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE
- );
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, response.created);
- const model = response.model || 'dall-e-2';
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const responseModel = response.model || requestModel;
- // Calculate cost of the operation
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
const cost =
(response.data?.length || 1) *
- OpenLitHelper.getImageModelCost(model, pricingInfo, size, quality);
+ OpenLitHelper.getImageModelCost(responseModel, pricingInfo, size, quality);
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -755,35 +745,29 @@ class OpenAIWrapper extends BaseWrapper {
serverPort: OpenAIWrapper.serverPort,
});
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE, size);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY, quality);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_STYLE, style);
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, prompt);
}
- // Request Params attributes : End
- let imagesCount = 0;
if (response.data) {
+ const imageUrls: string[] = [];
+ const revisedPrompts: string[] = [];
for (const items of response.data) {
- span.setAttribute(
- `${SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT}.${imagesCount}`,
- items.revised_prompt || ''
- );
-
- const attributeName = `${SemanticConvention.GEN_AI_RESPONSE_IMAGE}.${imagesCount}`;
- span.setAttribute(attributeName, items[response_format]);
-
- imagesCount++;
+ revisedPrompts.push(items.revised_prompt || '');
+ const value = items[response_format];
+ imageUrls.push(value && !String(value).startsWith('data:') ? value : '[base64_image_data]');
}
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_IMAGE, imageUrls);
+ span.setAttribute(SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT, revisedPrompts);
}
- // Store metric parameters for use after span ends
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -792,9 +776,9 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -806,32 +790,32 @@ class OpenAIWrapper extends BaseWrapper {
static _patchAudioCreate(tracer: Tracer): any {
const genAIEndpoint = 'openai.resources.audio.speech';
- const traceContent = OpenlitConfig.traceContent;
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'tts-1';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO, requestModel),
+ }, effectiveCtx);
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams;
try {
const response = await originalMethod.apply(this, args);
const { input, user, voice, response_format = 'mp3', speed = 1 } = args[0];
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO
- );
-
- const model = response.model || 'tts-1';
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const responseModel = response.model || requestModel;
- // Calculate cost of the operation
- const cost = OpenLitHelper.getAudioModelCost(model, pricingInfo, input);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getAudioModelCost(responseModel, pricingInfo, input);
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -839,7 +823,6 @@ class OpenAIWrapper extends BaseWrapper {
serverPort: OpenAIWrapper.serverPort,
});
- // Request Params attributes : Start
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE, voice);
span.setAttribute(
SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
@@ -847,15 +830,13 @@ class OpenAIWrapper extends BaseWrapper {
);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SPEED, speed);
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, input);
}
- // Request Params attributes : End
- // Store metric parameters for use after span ends
metricParams = {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -864,9 +845,9 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
- // Record metrics after span has ended if parameters are available
if (metricParams) {
BaseWrapper.recordMetrics(span, metricParams);
}
@@ -880,9 +861,16 @@ class OpenAIWrapper extends BaseWrapper {
const genAIEndpoint = 'openai.resources.responses';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'gpt-4o';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -904,7 +892,16 @@ class OpenAIWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: OpenAIWrapper.aiSystem,
+ serverAddress: OpenAIWrapper.serverAddress,
+ serverPort: OpenAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
+ throw e;
});
};
};
@@ -932,6 +929,7 @@ class OpenAIWrapper extends BaseWrapper {
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -956,7 +954,6 @@ class OpenAIWrapper extends BaseWrapper {
const startTime = Date.now();
try {
- const { input } = args[0];
const result = {
id: '',
model: '',
@@ -973,7 +970,7 @@ class OpenAIWrapper extends BaseWrapper {
};
let llmResponse = '';
- let responseTools: any[] = [];
+ const responseTools: any[] = [];
for await (const chunk of response) {
timestamps.push(Date.now());
@@ -1015,7 +1012,6 @@ class OpenAIWrapper extends BaseWrapper {
yield chunk;
}
- // Construct output array
if (llmResponse) {
result.output.push({
type: 'message',
@@ -1027,7 +1023,6 @@ class OpenAIWrapper extends BaseWrapper {
result.output.push(...responseTools);
}
- // Calculate TTFT and TBT
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -1047,6 +1042,7 @@ class OpenAIWrapper extends BaseWrapper {
return result;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ throw e;
} finally {
span.end();
if (metricParams) {
@@ -1070,7 +1066,8 @@ class OpenAIWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'gpt-4o';
const {
input,
temperature = 1.0,
@@ -1080,40 +1077,33 @@ class OpenAIWrapper extends BaseWrapper {
stream = false,
} = args[0];
- // Normalize Responses API input to messages array for buildInputMessages
const responsesMessages = typeof input === 'string'
? [{ role: 'user', content: input }]
: (Array.isArray(input) ? input : []);
- // Request Params attributes
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_output_tokens || -1);
+ if (max_output_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_output_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
if (reasoning?.effort) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_REASONING_EFFORT, reasoning.effort);
}
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(responsesMessages));
}
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
-
- const model = result.model || 'gpt-4o';
- const responseModel = result.model || model;
+ const responseModel = result.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- // Calculate cost
const inputTokens = result.usage?.input_tokens || 0;
const outputTokens = result.usage?.output_tokens || 0;
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
inputTokens,
outputTokens
@@ -1121,7 +1111,7 @@ class OpenAIWrapper extends BaseWrapper {
OpenAIWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user: '',
cost,
aiSystem: OpenAIWrapper.aiSystem,
@@ -1129,23 +1119,19 @@ class OpenAIWrapper extends BaseWrapper {
serverPort: OpenAIWrapper.serverPort,
});
- // Response attributes
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [result.status || 'completed']);
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ span.setAttribute(SemanticConvention.OPENAI_API_TYPE, 'responses');
if (result.service_tier) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER, result.service_tier);
+ span.setAttribute(SemanticConvention.OPENAI_RESPONSE_SERVICE_TIER, result.service_tier);
}
- // Token usage
span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, inputTokens + outputTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, inputTokens + outputTokens);
- // Reasoning tokens
if (result.usage?.output_tokens_details?.reasoning_tokens) {
span.setAttribute(
SemanticConvention.GEN_AI_USAGE_REASONING_TOKENS,
@@ -1153,7 +1139,6 @@ class OpenAIWrapper extends BaseWrapper {
);
}
- // TTFT and TBT metrics
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -1161,7 +1146,6 @@ class OpenAIWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Extract completion text from output
let completionText = '';
if (result.output && Array.isArray(result.output)) {
for (const item of result.output) {
@@ -1175,13 +1159,11 @@ class OpenAIWrapper extends BaseWrapper {
}
}
- // Tool calls handling for Responses API
const toolCalls = result.tools || [];
if (toolCalls.length > 0) {
const toolNames = toolCalls.map((t: any) => t.name || '').filter(Boolean);
const toolIds = toolCalls.map((t: any) => t.call_id || '').filter(Boolean);
const toolArgs = toolCalls.map((t: any) => t.arguments || '').filter(Boolean);
- const toolTypes = toolCalls.map((t: any) => t.type || '').filter(Boolean);
if (toolNames.length > 0) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
@@ -1190,24 +1172,41 @@ class OpenAIWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
}
if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs.join(', '));
- }
- if (toolTypes.length > 0) {
- const toolTypesStr = toolTypes.join(', ');
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolTypesStr);
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, toolTypesStr);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
}
- // Content
- if (traceContent) {
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(completionText, result.status || 'stop'));
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(completionText, result.status || 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(responsesMessages);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: OpenAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: OpenAIWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.status || 'completed'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user: '',
cost,
aiSystem: OpenAIWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/pinecone/wrapper.ts b/sdk/typescript/src/instrumentation/pinecone/wrapper.ts
index 16f882ea..71ec6b26 100644
--- a/sdk/typescript/src/instrumentation/pinecone/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/pinecone/wrapper.ts
@@ -58,7 +58,7 @@ class PineconeWrapper extends BaseWrapper {
const matchCount = response?.matches?.length || 0;
span.setAttribute(SemanticConvention.DB_N_RESULTS, matchCount);
- if (OpenlitConfig.traceContent && params.vector) {
+ if (OpenlitConfig.captureMessageContent && params.vector) {
span.setAttribute(SemanticConvention.DB_QUERY_TEXT, JSON.stringify(params.vector?.slice(0, 10)));
}
@@ -103,7 +103,7 @@ class PineconeWrapper extends BaseWrapper {
`${dbOperation} ${namespace} vectors_count=${records.length}`
);
- if (OpenlitConfig.traceContent && records.length > 0) {
+ if (OpenlitConfig.captureMessageContent && records.length > 0) {
span.setAttribute(SemanticConvention.DB_QUERY_TEXT, JSON.stringify(records.map((r: any) => r.id)));
}
diff --git a/sdk/typescript/src/instrumentation/qdrant/wrapper.ts b/sdk/typescript/src/instrumentation/qdrant/wrapper.ts
index 3edb283a..9a026544 100644
--- a/sdk/typescript/src/instrumentation/qdrant/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/qdrant/wrapper.ts
@@ -52,7 +52,7 @@ class QdrantWrapper extends BaseWrapper {
const resultCount = Array.isArray(response) ? response.length : 0;
span.setAttribute(SemanticConvention.DB_N_RESULTS, resultCount);
- if (OpenlitConfig.traceContent && params.vector) {
+ if (OpenlitConfig.captureMessageContent && params.vector) {
const vectorPreview = Array.isArray(params.vector)
? JSON.stringify(params.vector.slice(0, 10))
: String(params.vector);
diff --git a/sdk/typescript/src/instrumentation/replicate/wrapper.ts b/sdk/typescript/src/instrumentation/replicate/wrapper.ts
index 65637472..774f59e1 100644
--- a/sdk/typescript/src/instrumentation/replicate/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/replicate/wrapper.ts
@@ -1,8 +1,21 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
-import BaseWrapper from '../base-wrapper';
+import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: ReplicateWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: ReplicateWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: ReplicateWrapper.serverPort,
+ };
+}
class ReplicateWrapper extends BaseWrapper {
static aiSystem = SemanticConvention.GEN_AI_SYSTEM_REPLICATE;
@@ -13,14 +26,30 @@ class ReplicateWrapper extends BaseWrapper {
const genAIEndpoint = 'replicate.run';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const identifier = typeof args[0] === 'string' ? args[0] : '';
+ const requestModel = identifier.split(':')[0] || identifier;
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => ReplicateWrapper._run({ args, genAIEndpoint, response, span }))
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: ReplicateWrapper.aiSystem,
+ serverAddress: ReplicateWrapper.serverAddress,
+ serverPort: ReplicateWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -39,28 +68,18 @@ class ReplicateWrapper extends BaseWrapper {
response: any;
span: Span;
}): Promise<any> {
- let metricParams;
+ let metricParams: BaseSpanAttributes | undefined;
try {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
- // args[0] is the model identifier: "owner/model" or "owner/model:version"
- // args[1] is { input: { prompt, ... }, ... }
const identifier = typeof args[0] === 'string' ? args[0] : '';
const options = args[1] || {};
const input = options.input || {};
const prompt: string = input.prompt || '';
+ const requestModel = identifier.split(':')[0] || identifier;
- // Derive a clean model name from the identifier (strip version hash)
- const model = identifier.split(':')[0] || identifier;
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- if (traceContent && prompt) {
- span.setAttribute(SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT, prompt);
- }
-
- // Determine output type and content
let outputText = '';
let outputType = SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
@@ -78,28 +97,58 @@ class ReplicateWrapper extends BaseWrapper {
const promptTokens = OpenLitHelper.generalTokens(prompt) ?? 0;
const completionTokens = OpenLitHelper.generalTokens(outputText) ?? 0;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(model, pricingInfo, promptTokens, completionTokens);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(requestModel, pricingInfo, promptTokens, completionTokens);
ReplicateWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
cost,
aiSystem: ReplicateWrapper.aiSystem,
serverAddress: ReplicateWrapper.serverAddress,
serverPort: ReplicateWrapper.serverPort,
});
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, requestModel);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, promptTokens);
span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, promptTokens + completionTokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, promptTokens + completionTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ const messages = prompt ? [{ role: 'user', content: prompt }] : [];
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(outputText, 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
- if (traceContent && outputText) {
- span.setAttribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT, outputText);
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: ReplicateWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: ReplicateWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: promptTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: completionTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
- metricParams = { genAIEndpoint, model, cost, aiSystem: ReplicateWrapper.aiSystem };
+ metricParams = {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: ReplicateWrapper.aiSystem,
+ };
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
diff --git a/sdk/typescript/src/instrumentation/strands/index.ts b/sdk/typescript/src/instrumentation/strands/index.ts
new file mode 100644
index 00000000..49331998
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/strands/index.ts
@@ -0,0 +1,98 @@
+/**
+ * OpenLIT Strands Agents Instrumentation
+ *
+ * Registers a StrandsSpanProcessor with the global TracerProvider to
+ * enrich Strands' native OTel spans with OpenLIT attributes, content
+ * capture, inference log events, and metrics -- without monkey-patching.
+ *
+ * Mirrors: sdk/python/src/openlit/instrumentation/strands/__init__.py
+ */
+
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+} from '@opentelemetry/instrumentation';
+import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { trace } from '@opentelemetry/api';
+
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import { StrandsSpanProcessor } from './processor';
+
+const SUPPORTED_VERSIONS = ['>=0.1.0'];
+
+export default class StrandsInstrumentation extends InstrumentationBase {
+ private _processor: StrandsSpanProcessor | null = null;
+
+ constructor(config: InstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-strands`, '1.0.0', config);
+ }
+
+ protected init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void {
+ return new InstrumentationNodeModuleDefinition(
+ '@strands-agents/sdk',
+ SUPPORTED_VERSIONS,
+ (moduleExports: any) => {
+ this._patch(moduleExports);
+ return moduleExports;
+ },
+ (moduleExports: any) => {
+ this._unpatch();
+ return moduleExports;
+ },
+ );
+ }
+
+ override enable(): void {
+ super.enable();
+ // Always register the processor eagerly so it works with both
+ // CJS require hooks and ESM imports (where the module definition
+ // hook may not fire because the module was already loaded).
+ this._registerProcessor('unknown');
+ }
+
+ public manualPatch(_moduleExports?: any): void {
+ this._registerProcessor('unknown');
+ }
+
+ private _patch(moduleExports: any): void {
+ try {
+ let version = 'unknown';
+ try {
+ version = moduleExports?.version || 'unknown';
+ } catch {
+ // ignore
+ }
+ this._registerProcessor(version);
+ } catch {
+ // ignore
+ }
+ }
+
+ private _registerProcessor(strandsVersion: string): void {
+ if (this._processor) return;
+
+ this._processor = new StrandsSpanProcessor(strandsVersion);
+
+ const provider = trace.getTracerProvider() as any;
+ const actual = provider._delegate || provider;
+
+ const activeProcessor = actual._activeSpanProcessor;
+ if (activeProcessor && Array.isArray(activeProcessor._spanProcessors)) {
+ activeProcessor._spanProcessors.unshift(this._processor);
+ } else if (typeof actual.addSpanProcessor === 'function') {
+ actual.addSpanProcessor(this._processor);
+ }
+ }
+
+ private _unpatch(): void {
+ if (this._processor) {
+ try {
+ this._processor.shutdown();
+ } catch {
+ // ignore
+ }
+ this._processor = null;
+ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/strands/processor.ts b/sdk/typescript/src/instrumentation/strands/processor.ts
new file mode 100644
index 00000000..3a76ad83
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/strands/processor.ts
@@ -0,0 +1,594 @@
+/**
+ * Strands Agents SpanProcessor.
+ *
+ * Enriches Strands' native OTel spans with OpenLIT-specific attributes,
+ * extracts content from span events into span attributes, emits
+ * gen_ai.client.inference.operation.details log events for chat spans,
+ * and records OpenLIT metrics.
+ *
+ * Provider-level chat spans (OpenAI, Anthropic, etc.) are suppressed
+ * when they occur inside a Strands chat span via the shared
+ * frameworkLlmActive flag.
+ *
+ * Mirrors: sdk/python/src/openlit/instrumentation/strands/processor.py
+ */
+
+import { Context, SpanKind, SpanStatusCode } from '@opentelemetry/api';
+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';
+import type { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
+import type { Span } from '@opentelemetry/api';
+
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, {
+ applyCustomSpanAttributes,
+ setFrameworkLlmActive,
+ resetFrameworkLlmActive,
+} from '../../helpers';
+import {
+ extractContentFromEvents,
+ inferProviderName,
+ inferServerAddress,
+ truncateContent,
+ truncateMessageContent,
+ recordStrandsMetrics,
+ emitStrandsInferenceEvent,
+} from './utils';
+
+const STRANDS_TRACER_SCOPES = new Set([
+ 'strands.telemetry.tracer',
+ 'strands-agents',
+]);
+
+/**
+ * Enriches Strands-generated spans with OpenLIT telemetry.
+ * Added to the TracerProvider so it receives all spans; non-Strands
+ * spans are ignored via the _isStrandsSpan() check.
+ */
+export class StrandsSpanProcessor implements SpanProcessor {
+ private _strandsVersion: string;
+ private _chatSpanIds = new Set<string>();
+ private _chatInfo = new Map<string, Record<string, any>>();
+
+ constructor(strandsVersion: string = 'unknown') {
+ this._strandsVersion = strandsVersion;
+ }
+
+ // -----------------------------------------------------------------
+ // Span detection
+ // -----------------------------------------------------------------
+
+ private static _isStrandsSpan(span: any): boolean {
+ const scope = span.instrumentationLibrary;
+ if (scope && STRANDS_TRACER_SCOPES.has(scope.name)) {
+ return true;
+ }
+ const attrs = span.attributes || {};
+ const system = attrs['gen_ai.system'] || '';
+ const provider = attrs['gen_ai.provider.name'] || '';
+ return (
+ system === SemanticConvention.GEN_AI_SYSTEM_STRANDS ||
+ system === 'strands-agents' ||
+ provider === SemanticConvention.GEN_AI_SYSTEM_STRANDS ||
+ provider === 'strands-agents'
+ );
+ }
+
+ // -----------------------------------------------------------------
+ // Attribute mutation helpers (span is read-only after onEnd)
+ // -----------------------------------------------------------------
+
+ private static _setAttr(span: any, key: string, value: any): void {
+ try {
+ if (span.attributes) {
+ span.attributes[key] = value;
+ }
+ } catch {
+ // ignore
+ }
+ }
+
+ private static _setAttrs(span: any, mapping: Record<string, any>): void {
+ try {
+ if (span.attributes) {
+ Object.assign(span.attributes, mapping);
+ }
+ } catch {
+ // ignore
+ }
+ }
+
+ private static _setSpanName(span: any, name: string): void {
+ try {
+ if ('_name' in span) span._name = name;
+ if ('name' in span) span.name = name;
+ } catch {
+ // ignore
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // SpanProcessor API
+ // -----------------------------------------------------------------
+
+ onStart(span: Span, _parentContext: Context): void {
+ if (!StrandsSpanProcessor._isStrandsSpan(span as any)) return;
+
+ try {
+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, 'openlit');
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, this._strandsVersion);
+ span.setAttribute(
+ SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT,
+ OpenlitConfig.environment || 'default',
+ );
+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName || 'default');
+ applyCustomSpanAttributes(span);
+ } catch {
+ // ignore
+ }
+
+ const spanName = (span as any).name || '';
+ if (spanName === 'chat') {
+ try {
+ (span as any)._kind = SpanKind.CLIENT;
+ } catch {
+ // ignore
+ }
+ try {
+ setFrameworkLlmActive();
+ const spanId = span.spanContext().spanId;
+ this._chatSpanIds.add(spanId);
+ } catch {
+ // ignore
+ }
+ }
+ }
+
+ onEnd(span: ReadableSpan): void {
+ if (!StrandsSpanProcessor._isStrandsSpan(span)) return;
+
+ const spanId = span.spanContext().spanId;
+ if (this._chatSpanIds.has(spanId)) {
+ this._chatSpanIds.delete(spanId);
+ try {
+ resetFrameworkLlmActive();
+ } catch {
+ // ignore
+ }
+ }
+
+ try {
+ this._processSpan(span);
+ } catch {
+ // ignore
+ }
+ }
+
+ shutdown(): Promise<void> {
+ return Promise.resolve();
+ }
+
+ forceFlush(): Promise<void> {
+ return Promise.resolve();
+ }
+
+ // -----------------------------------------------------------------
+ // Core processing (mirrors Python _process_span)
+ // -----------------------------------------------------------------
+
+ private _processSpan(span: ReadableSpan): void {
+ const attrs = span.attributes || {};
+ let operation = String(attrs[SemanticConvention.GEN_AI_OPERATION] || '');
+
+ // Normalize agent id: agent_name-span_id_hex
+ const agentName = attrs[SemanticConvention.GEN_AI_AGENT_NAME] as string | undefined;
+ if (agentName && !attrs[SemanticConvention.GEN_AI_AGENT_ID]) {
+ const spanIdHex = span.spanContext().spanId;
+ StrandsSpanProcessor._setAttr(
+ span,
+ SemanticConvention.GEN_AI_AGENT_ID,
+ `${agentName}-${spanIdHex}`,
+ );
+ }
+
+ // Normalize gen_ai.system → gen_ai.provider.name
+ const genAiSystem = String(attrs['gen_ai.system'] || '');
+ if (genAiSystem && !attrs[SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]) {
+ const provider =
+ genAiSystem === 'strands-agents' || genAiSystem === 'strands_agents'
+ ? SemanticConvention.GEN_AI_SYSTEM_STRANDS
+ : genAiSystem;
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, provider);
+ }
+
+ // Normalize Strands-native cache token keys → OTel standard keys
+ const cacheKeyMap: [string, string][] = [
+ ['gen_ai.usage.cache_read_input_tokens', SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS],
+ ['gen_ai.usage.cache_write_input_tokens', SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS],
+ ];
+ for (const [strandsKey, otelKey] of cacheKeyMap) {
+ const val = attrs[strandsKey];
+ if (val != null && !attrs[otelKey]) {
+ StrandsSpanProcessor._setAttr(span, otelKey, val);
+ }
+ }
+
+ // Remap Strands-native system_prompt → gen_ai.system_instructions
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT) {
+ const systemPrompt = attrs['system_prompt'] as string | undefined;
+ if (systemPrompt && !attrs[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS]) {
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS, systemPrompt);
+ }
+ }
+
+ // Duration (HrTime → seconds)
+ let duration = 0;
+ if (span.endTime && span.startTime) {
+ const endNs = span.endTime[0] * 1e9 + span.endTime[1];
+ const startNs = span.startTime[0] * 1e9 + span.startTime[1];
+ duration = (endNs - startNs) / 1e9;
+ }
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION, duration);
+
+ // Server address / port (inferred from model name)
+ const modelName = String(attrs[SemanticConvention.GEN_AI_REQUEST_MODEL] || '');
+ let serverAddress = String(attrs[SemanticConvention.SERVER_ADDRESS] || '');
+ let serverPort = Number(attrs[SemanticConvention.SERVER_PORT] || 0);
+ if (!serverAddress && modelName) {
+ [serverAddress, serverPort] = inferServerAddress(modelName);
+ if (serverAddress) {
+ StrandsSpanProcessor._setAttrs(span, {
+ [SemanticConvention.SERVER_ADDRESS]: serverAddress,
+ [SemanticConvention.SERVER_PORT]: serverPort,
+ });
+ }
+ }
+
+ // Normalize multi-agent operation names to invoke_workflow
+ if (operation === 'invoke_swarm' || operation === 'invoke_graph') {
+ const workflowName = String(attrs[SemanticConvention.GEN_AI_AGENT_NAME] || '');
+ StrandsSpanProcessor._setAttrs(span, {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
+ [SemanticConvention.GEN_AI_WORKFLOW_NAME]: workflowName,
+ });
+ operation = SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK;
+ }
+
+ // Output type for agent / workflow spans
+ if (
+ operation === SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT ||
+ operation === SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK
+ ) {
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ }
+
+ // Tool type and tool call id
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS) {
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_TOOL_TYPE, 'function');
+ if (!attrs[SemanticConvention.GEN_AI_TOOL_CALL_ID]) {
+ const tid =
+ attrs['tool_use_id'] ||
+ attrs['toolUseId'] ||
+ attrs['gen_ai.tool.call.id'] ||
+ StrandsSpanProcessor._extractToolCallIdFromSpanEvents(span);
+ if (tid) {
+ StrandsSpanProcessor._setAttr(span, SemanticConvention.GEN_AI_TOOL_CALL_ID, String(tid));
+ }
+ }
+ }
+
+ // OTel-compliant span names
+ this._setOtelCompliantSpanName(span, operation);
+
+ // Chat span enrichment: match provider span attributes
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT) {
+ this._enrichChatSpan(span, attrs, modelName);
+ this._storeChatInfoForParent(span, modelName);
+ }
+
+ // Propagate recommended attrs from child chat spans to invoke_agent
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT) {
+ this._enrichAgentFromChildren(span);
+ }
+
+ // Content capture: extract from events → span attributes
+ if (OpenlitConfig.captureMessageContent) {
+ this._extractAndSetContent(span, operation);
+ }
+
+ // Emit inference log event for chat spans
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT) {
+ this._emitChatInferenceEvent(span, attrs, serverAddress, serverPort);
+ }
+
+ // Record OpenLIT metrics
+ if (!OpenlitConfig.disableMetrics && operation) {
+ recordStrandsMetrics(operation, duration, modelName, serverAddress, serverPort);
+ }
+
+ // Set error type if missing (low-cardinality per OTel spec)
+ if (span.status && span.status.code === SpanStatusCode.ERROR) {
+ const currentAttrs = span.attributes || {};
+ if (!currentAttrs[SemanticConvention.ERROR_TYPE]) {
+ StrandsSpanProcessor._setAttr(
+ span,
+ SemanticConvention.ERROR_TYPE,
+ '_OTHER',
+ );
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // OTel-compliant span naming
+ // -----------------------------------------------------------------
+
+ private _setOtelCompliantSpanName(span: ReadableSpan, operation: string): void {
+ if (
+ operation !== SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT &&
+ operation !== SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS &&
+ operation !== SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK
+ ) {
+ return;
+ }
+ try {
+ const attrs = span.attributes || {};
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT) {
+ const name = attrs[SemanticConvention.GEN_AI_AGENT_NAME];
+ if (name) StrandsSpanProcessor._setSpanName(span, `invoke_agent ${name}`);
+ } else if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS) {
+ const name = attrs[SemanticConvention.GEN_AI_TOOL_NAME];
+ if (name) StrandsSpanProcessor._setSpanName(span, `execute_tool ${name}`);
+ } else if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK) {
+ const name = attrs[SemanticConvention.GEN_AI_WORKFLOW_NAME];
+ if (name) StrandsSpanProcessor._setSpanName(span, `invoke_workflow ${name}`);
+ }
+ } catch {
+ // ignore
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Chat span enrichment (parity with provider spans)
+ // -----------------------------------------------------------------
+
+ private _enrichChatSpan(span: ReadableSpan, attrs: Record<string, any>, modelName: string): void {
+ const enrichments: Record<string, any> = {};
+
+ // Span name: "chat" → "chat {model}"
+ if (modelName) {
+ StrandsSpanProcessor._setSpanName(span, `chat ${modelName}`);
+ }
+
+ // Override gen_ai.provider.name with actual provider for chat spans
+ const provider = modelName ? inferProviderName(modelName) : '';
+ if (provider) {
+ enrichments[SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL] = provider;
+ }
+
+ // response.model: fall back to request model
+ if (!attrs[SemanticConvention.GEN_AI_RESPONSE_MODEL] && modelName) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_MODEL] = modelName;
+ }
+
+ // response.id: extract from events
+ if (!attrs[SemanticConvention.GEN_AI_RESPONSE_ID]) {
+ const responseId = StrandsSpanProcessor._extractResponseId(span);
+ if (responseId) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_ID] = responseId;
+ }
+ }
+
+ // Finish reasons from output events
+ const [, outputMsgs] = extractContentFromEvents(span, 'chat');
+ if (outputMsgs && outputMsgs.length > 0) {
+ const finishReasons = outputMsgs
+ .filter((m: any) => typeof m === 'object' && m.finish_reason)
+ .map((m: any) => m.finish_reason);
+ if (finishReasons.length > 0) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = finishReasons;
+ }
+ }
+
+ enrichments[SemanticConvention.GEN_AI_OUTPUT_TYPE] = SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
+
+ // Token totals and cost
+ const inputTokens = Number(attrs['gen_ai.usage.input_tokens'] || 0);
+ const outputTokens = Number(attrs['gen_ai.usage.output_tokens'] || 0);
+ if (inputTokens || outputTokens) {
+ enrichments[SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE] = inputTokens + outputTokens;
+ }
+ if (OpenlitConfig.pricingInfo && modelName) {
+ const cost = OpenLitHelper.getChatModelCost(modelName, OpenlitConfig.pricingInfo, inputTokens, outputTokens);
+ enrichments[SemanticConvention.GEN_AI_USAGE_COST] = cost;
+ }
+
+ if (Object.keys(enrichments).length > 0) {
+ StrandsSpanProcessor._setAttrs(span, enrichments);
+ }
+ }
+
+ private _storeChatInfoForParent(span: ReadableSpan, modelName: string): void {
+ try {
+ const parentId = (span as any).parentSpanId;
+ if (!parentId) return;
+
+ const finalAttrs = span.attributes || {};
+ const info: Record<string, any> = {
+ responseModel: finalAttrs[SemanticConvention.GEN_AI_RESPONSE_MODEL] || modelName,
+ responseId: finalAttrs[SemanticConvention.GEN_AI_RESPONSE_ID],
+ finishReasons: finalAttrs[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON],
+ inputTokens: finalAttrs['gen_ai.usage.input_tokens'] || 0,
+ outputTokens: finalAttrs['gen_ai.usage.output_tokens'] || 0,
+ };
+ this._chatInfo.set(parentId, info);
+ } catch {
+ // ignore
+ }
+ }
+
+ private _enrichAgentFromChildren(span: ReadableSpan): void {
+ try {
+ const spanId = span.spanContext().spanId;
+ const info = this._chatInfo.get(spanId);
+ this._chatInfo.delete(spanId);
+ if (!info) return;
+
+ const enrichments: Record<string, any> = {};
+ const current = span.attributes || {};
+
+ if (info.responseModel && !current[SemanticConvention.GEN_AI_RESPONSE_MODEL]) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_MODEL] = info.responseModel;
+ }
+ if (info.responseId && !current[SemanticConvention.GEN_AI_RESPONSE_ID]) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_ID] = info.responseId;
+ }
+ if (info.finishReasons && !current[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]) {
+ enrichments[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = info.finishReasons;
+ }
+ if (Object.keys(enrichments).length > 0) {
+ StrandsSpanProcessor._setAttrs(span, enrichments);
+ }
+ } catch {
+ // ignore
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Static extraction helpers
+ // -----------------------------------------------------------------
+
+ private static _extractResponseId(span: ReadableSpan): string {
+ for (const event of span.events || []) {
+ const ea = event.attributes || {};
+ const rid = ea['gen_ai.response.id'] || ea['response_id'];
+ if (rid) return String(rid);
+ }
+ return '';
+ }
+
+ private static _extractToolCallIdFromSpanEvents(span: ReadableSpan): string | null {
+ for (const event of span.events || []) {
+ if (event.name === 'gen_ai.tool.message') {
+ const ea = event.attributes || {};
+ const tid = ea['id'] || ea[SemanticConvention.GEN_AI_TOOL_CALL_ID];
+ if (tid) return String(tid);
+ }
+ }
+ for (const event of span.events || []) {
+ const ea = event.attributes || {};
+ const tid =
+ ea[SemanticConvention.GEN_AI_TOOL_CALL_ID] ||
+ ea['tool_use_id'] ||
+ ea['toolUseId'] ||
+ ea['gen_ai.tool.call.id'];
+ if (tid) return String(tid);
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------
+ // Content extraction → span attributes
+ // -----------------------------------------------------------------
+
+ private _extractAndSetContent(span: ReadableSpan, operation: string): void {
+ try {
+ const [inputMsgs, outputMsgs, systemInstr] = extractContentFromEvents(span, operation);
+ const additions: Record<string, any> = {};
+
+ if (operation === SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS) {
+ if (inputMsgs.length > 0) {
+ const first = inputMsgs[0];
+ const parts = (typeof first === 'object' && first.parts) ? first.parts : [];
+ if (parts.length > 0) {
+ const arguments_ = parts[0].arguments || parts[0].response || '';
+ additions[SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS] = truncateContent(
+ typeof arguments_ === 'string' ? arguments_ : JSON.stringify(arguments_),
+ );
+ }
+ }
+ if (outputMsgs.length > 0) {
+ additions[SemanticConvention.GEN_AI_TOOL_CALL_RESULT] = truncateContent(
+ JSON.stringify(outputMsgs),
+ );
+ }
+ } else {
+ if (inputMsgs.length > 0) {
+ truncateMessageContent(inputMsgs);
+ additions[SemanticConvention.GEN_AI_INPUT_MESSAGES] = JSON.stringify(inputMsgs);
+ }
+ if (outputMsgs.length > 0) {
+ truncateMessageContent(outputMsgs);
+ additions[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = JSON.stringify(outputMsgs);
+ }
+ if (systemInstr) {
+ additions[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS] = truncateContent(String(systemInstr));
+ }
+ }
+
+ if (Object.keys(additions).length > 0) {
+ StrandsSpanProcessor._setAttrs(span, additions);
+ }
+ } catch {
+ // ignore
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Chat inference log event
+ // -----------------------------------------------------------------
+
+ private _emitChatInferenceEvent(
+ span: ReadableSpan,
+ attrs: Record<string, any>,
+ serverAddress: string,
+ serverPort: number,
+ ): void {
+ try {
+ const [inputMsgs, outputMsgs, systemInstr] = extractContentFromEvents(span, 'chat');
+
+ const extra: Record<string, any> = {};
+
+ const inputTokens = attrs['gen_ai.usage.input_tokens'];
+ const outputTokens = attrs['gen_ai.usage.output_tokens'];
+ if (inputTokens != null) extra.inputTokens = inputTokens;
+ if (outputTokens != null) extra.outputTokens = outputTokens;
+
+ const cacheRead =
+ attrs[SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] ||
+ attrs['gen_ai.usage.cache_read_input_tokens'];
+ const cacheWrite =
+ attrs[SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] ||
+ attrs['gen_ai.usage.cache_write_input_tokens'];
+ if (cacheRead != null) extra.cacheReadInputTokens = cacheRead;
+ if (cacheWrite != null) extra.cacheCreationInputTokens = cacheWrite;
+
+ const responseId =
+ attrs[SemanticConvention.GEN_AI_RESPONSE_ID] ||
+ StrandsSpanProcessor._extractResponseId(span);
+ if (responseId) extra.responseId = responseId;
+
+ if (systemInstr) extra.systemInstructions = systemInstr;
+
+ if (outputMsgs.length > 0) {
+ const finishReasons = outputMsgs
+ .filter((m: any) => typeof m === 'object' && m.finish_reason)
+ .map((m: any) => m.finish_reason);
+ if (finishReasons.length > 0) extra.finishReasons = finishReasons;
+ }
+
+ extra.inputMessages = inputMsgs;
+ extra.outputMessages = outputMsgs;
+
+ emitStrandsInferenceEvent(
+ span,
+ String(attrs[SemanticConvention.GEN_AI_REQUEST_MODEL] || ''),
+ serverAddress,
+ serverPort,
+ extra,
+ );
+ } catch {
+ // ignore
+ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/strands/utils.ts b/sdk/typescript/src/instrumentation/strands/utils.ts
new file mode 100644
index 00000000..0b152b4d
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/strands/utils.ts
@@ -0,0 +1,337 @@
+/**
+ * Strands Agents instrumentation utilities.
+ *
+ * Provides model-to-provider mapping, server address inference, content
+ * extraction from Strands native span events, inference event emission,
+ * and metrics recording.
+ *
+ * Mirrors: sdk/python/src/openlit/instrumentation/strands/utils.py
+ */
+
+import { Attributes } from '@opentelemetry/api';
+import SemanticConvention from '../../semantic-convention';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, { getServerAddressForProvider } from '../../helpers';
+import Metrics from '../../otel/metrics';
+
+// -------------------------------------------------------------------------
+// Model prefix → provider mapping (mirrors Python _MODEL_PREFIX_TO_PROVIDER)
+// -------------------------------------------------------------------------
+
+const MODEL_PREFIX_TO_PROVIDER: [string, string][] = [
+ ['anthropic.', 'aws.bedrock'],
+ ['amazon.', 'aws.bedrock'],
+ ['meta.', 'aws.bedrock'],
+ ['us.anthropic.', 'aws.bedrock'],
+ ['us.amazon.', 'aws.bedrock'],
+ ['us.meta.', 'aws.bedrock'],
+ ['eu.anthropic.', 'aws.bedrock'],
+ ['eu.amazon.', 'aws.bedrock'],
+ ['eu.meta.', 'aws.bedrock'],
+ ['gpt-', 'openai'],
+ ['o1', 'openai'],
+ ['o3', 'openai'],
+ ['o4', 'openai'],
+ ['claude', 'anthropic'],
+ ['gemini', 'google'],
+ ['mistral', 'mistral_ai'],
+ ['command', 'cohere'],
+ ['deepseek', 'deepseek'],
+];
+
+export function inferServerAddress(modelName: string): [string, number] {
+ if (!modelName) return ['', 0];
+ const lower = modelName.toLowerCase();
+ for (const [prefix, provider] of MODEL_PREFIX_TO_PROVIDER) {
+ if (lower.startsWith(prefix)) {
+ return getServerAddressForProvider(provider);
+ }
+ }
+ return ['', 0];
+}
+
+export function inferProviderName(modelName: string): string {
+ if (!modelName) return '';
+ const lower = modelName.toLowerCase();
+ for (const [prefix, provider] of MODEL_PREFIX_TO_PROVIDER) {
+ if (lower.startsWith(prefix)) {
+ return provider;
+ }
+ }
+ return '';
+}
+
+// -------------------------------------------------------------------------
+// Content extraction from Strands span events
+// -------------------------------------------------------------------------
+
+function safeJsonParse(value: any): any {
+ if (typeof value === 'string') {
+ try {
+ return JSON.parse(value);
+ } catch {
+ return value;
+ }
+ }
+ return value;
+}
+
+/**
+ * Convert Strands Bedrock-style content blocks to OTel message parts.
+ */
+function convertStrandsContentToParts(content: any): any[] {
+ let blocks = safeJsonParse(content);
+ if (!Array.isArray(blocks)) {
+ blocks = blocks ? [blocks] : [];
+ }
+
+ const parts: any[] = [];
+ for (const block of blocks) {
+ if (typeof block === 'object' && block !== null) {
+ if ('text' in block) {
+ parts.push({ type: 'text', content: block.text });
+ } else if ('toolUse' in block) {
+ const tu = block.toolUse;
+ parts.push({
+ type: 'tool_call',
+ id: tu.toolUseId || '',
+ name: tu.name || '',
+ arguments: tu.input || {},
+ });
+ } else if ('toolResult' in block) {
+ const tr = block.toolResult;
+ parts.push({
+ type: 'tool_call_response',
+ id: tr.toolUseId || '',
+ response: tr.content || '',
+ });
+ } else {
+ for (const [key, value] of Object.entries(block)) {
+ parts.push({ type: key, content: value });
+ }
+ }
+ } else if (typeof block === 'string') {
+ parts.push({ type: 'text', content: block });
+ }
+ }
+
+ return parts.length > 0 ? parts : [{ type: 'text', content: String(content) }];
+}
+
+/**
+ * Extract message content from Strands span events.
+ *
+ * Handles both legacy named events (gen_ai.user.message, gen_ai.choice, etc.)
+ * and the gen_ai.client.inference.operation.details event convention.
+ *
+ * Returns [inputMessages, outputMessages, systemInstructions].
+ */
+export function extractContentFromEvents(
+ span: any,
+ operation: string
+): [any[], any[], string | null] {
+ const inputMsgs: any[] = [];
+ const outputMsgs: any[] = [];
+ let systemInstructions: string | null = null;
+
+ for (const event of span.events || []) {
+ const ea = event.attributes || {};
+
+ if (event.name === SemanticConvention.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS) {
+ if (ea[SemanticConvention.GEN_AI_INPUT_MESSAGES]) {
+ const raw = safeJsonParse(ea[SemanticConvention.GEN_AI_INPUT_MESSAGES]);
+ if (Array.isArray(raw)) inputMsgs.push(...raw);
+ else if (raw) inputMsgs.push(raw);
+ }
+ if (ea[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]) {
+ const raw = safeJsonParse(ea[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]);
+ if (Array.isArray(raw)) outputMsgs.push(...raw);
+ else if (raw) outputMsgs.push(raw);
+ }
+ if (ea[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS]) {
+ systemInstructions = String(ea[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS]);
+ }
+ continue;
+ }
+
+ if (event.name === 'gen_ai.system.message') {
+ systemInstructions = String(ea.content || '');
+ } else if (event.name === 'gen_ai.user.message') {
+ const content = ea.content || '';
+ const parts = convertStrandsContentToParts(content);
+ inputMsgs.push({ role: 'user', parts });
+ } else if (event.name === 'gen_ai.assistant.message') {
+ const content = ea.content || '';
+ const parts = convertStrandsContentToParts(content);
+ inputMsgs.push({ role: 'assistant', parts });
+ } else if (event.name === 'gen_ai.tool.message') {
+ const content = ea.content || '';
+ const toolId = ea.id || '';
+ if (operation === 'execute_tool') {
+ inputMsgs.push({
+ role: 'tool',
+ parts: [{
+ type: 'tool_call',
+ id: toolId,
+ name: '',
+ arguments: safeJsonParse(content),
+ }],
+ });
+ } else {
+ inputMsgs.push({
+ role: 'tool',
+ parts: [{
+ type: 'tool_call_response',
+ id: toolId,
+ response: safeJsonParse(content),
+ }],
+ });
+ }
+ } else if (event.name === 'gen_ai.choice') {
+ const message = ea.message || '';
+ const finishReason = ea.finish_reason || '';
+ if (operation === 'execute_tool') {
+ outputMsgs.push({
+ role: 'tool',
+ parts: convertStrandsContentToParts(message),
+ });
+ } else {
+ const parts = convertStrandsContentToParts(message);
+ const entry: any = { role: 'assistant', parts };
+ if (finishReason) entry.finish_reason = String(finishReason);
+ outputMsgs.push(entry);
+ }
+ }
+ }
+
+ return [inputMsgs, outputMsgs, systemInstructions];
+}
+
+// -------------------------------------------------------------------------
+// Content truncation
+// -------------------------------------------------------------------------
+
+export function truncateContent(content: string): string {
+ const maxLen = OpenlitConfig.maxContentLength;
+ if (maxLen && content.length > maxLen) {
+ return content.substring(0, maxLen) + '...';
+ }
+ return content;
+}
+
+export function truncateMessageContent(messages: any[]): void {
+ for (const msg of messages) {
+ if (msg.parts && Array.isArray(msg.parts)) {
+ for (const part of msg.parts) {
+ if (part.content && typeof part.content === 'string') {
+ part.content = truncateContent(part.content);
+ }
+ if (part.response && typeof part.response === 'string') {
+ part.response = truncateContent(part.response);
+ }
+ if (part.arguments && typeof part.arguments === 'string') {
+ part.arguments = truncateContent(part.arguments);
+ }
+ }
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+// Metrics recording (mirrors Python record_strands_metrics)
+// -------------------------------------------------------------------------
+
+export function recordStrandsMetrics(
+ operation: string,
+ duration: number,
+ modelName: string,
+ serverAddress: string,
+ serverPort: number
+): void {
+ try {
+ const attributes: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: operation,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_STRANDS,
+ 'service.name': OpenlitConfig.applicationName || 'default',
+ 'deployment.environment': OpenlitConfig.environment || 'default',
+ };
+ if (modelName && modelName !== 'unknown') {
+ attributes[SemanticConvention.GEN_AI_REQUEST_MODEL] = modelName;
+ }
+ if (serverAddress) {
+ attributes[SemanticConvention.SERVER_ADDRESS] = serverAddress;
+ }
+ if (serverPort) {
+ attributes[SemanticConvention.SERVER_PORT] = serverPort;
+ }
+
+ Metrics.genaiClientOperationDuration?.record(duration, attributes);
+ } catch {
+ // ignore
+ }
+}
+
+// -------------------------------------------------------------------------
+// Inference event emission (mirrors Python emit_strands_inference_event)
+// -------------------------------------------------------------------------
+
+export function emitStrandsInferenceEvent(
+ span: any,
+ requestModel: string,
+ serverAddress: string,
+ serverPort: number,
+ extra: Record<string, any> = {}
+): void {
+ try {
+ if (OpenlitConfig.disableEvents) return;
+
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ };
+
+ if (requestModel) {
+ eventAttrs[SemanticConvention.GEN_AI_REQUEST_MODEL] = requestModel;
+ }
+ if (serverAddress) {
+ eventAttrs[SemanticConvention.SERVER_ADDRESS] = serverAddress;
+ }
+ if (serverPort) {
+ eventAttrs[SemanticConvention.SERVER_PORT] = serverPort;
+ }
+
+ if (extra.inputTokens != null) {
+ eventAttrs[SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS] = extra.inputTokens;
+ }
+ if (extra.outputTokens != null) {
+ eventAttrs[SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS] = extra.outputTokens;
+ }
+ if (extra.cacheReadInputTokens != null) {
+ eventAttrs[SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] = extra.cacheReadInputTokens;
+ }
+ if (extra.cacheCreationInputTokens != null) {
+ eventAttrs[SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] = extra.cacheCreationInputTokens;
+ }
+ if (extra.responseId) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID] = extra.responseId;
+ }
+ if (extra.finishReasons) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = extra.finishReasons;
+ }
+ if (extra.systemInstructions) {
+ eventAttrs[SemanticConvention.GEN_AI_SYSTEM_INSTRUCTIONS] = extra.systemInstructions;
+ }
+
+ if (OpenlitConfig.captureMessageContent) {
+ if (extra.inputMessages) {
+ eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = JSON.stringify(extra.inputMessages);
+ }
+ if (extra.outputMessages) {
+ eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = JSON.stringify(extra.outputMessages);
+ }
+ }
+
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ } catch {
+ // ignore
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/together/wrapper.ts b/sdk/typescript/src/instrumentation/together/wrapper.ts
index cae1ca7d..7abca83a 100644
--- a/sdk/typescript/src/instrumentation/together/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/together/wrapper.ts
@@ -1,21 +1,41 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
-import OpenLitHelper from '../../helpers';
+import OpenLitHelper, { isFrameworkLlmActive, getFrameworkParentContext } from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: TogetherWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: TogetherWrapper.serverPort,
+ };
+}
+
class TogetherWrapper extends BaseWrapper {
- static aiSystem = 'together';
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_TOGETHER;
static serverAddress = 'api.together.xyz';
static serverPort = 443;
-
+
static _patchChatCompletionCreate(tracer: Tracer): any {
const genAIEndpoint = 'together.chat.completions';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+ const requestModel = args[0]?.model || 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
+ }, effectiveCtx);
return context
- .with(trace.setSpan(context.active(), span), async () => {
+ .with(trace.setSpan(effectiveCtx, span), async () => {
return originalMethod.apply(this, args);
})
.then((response: any) => {
@@ -37,6 +57,14 @@ class TogetherWrapper extends BaseWrapper {
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: TogetherWrapper.aiSystem,
+ serverAddress: TogetherWrapper.serverAddress,
+ serverPort: TogetherWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
});
@@ -89,12 +117,13 @@ class TogetherWrapper extends BaseWrapper {
let metricParams;
const timestamps: number[] = [];
const startTime = Date.now();
-
+
try {
const { messages } = args[0];
+ let { tools } = args[0];
const result = {
id: '0',
- model: args[0].model || '', // model is not in Together streaming chunks
+ model: args[0].model || '',
choices: [
{
index: 0,
@@ -109,12 +138,11 @@ class TogetherWrapper extends BaseWrapper {
},
};
- let toolCalls: any[] = [];
+ const toolCalls: any[] = [];
for await (const chunk of response) {
timestamps.push(Date.now());
- // id is only present on the first chunk
if (chunk.id) result.id = chunk.id;
if (chunk.choices[0]?.finish_reason) {
@@ -124,21 +152,20 @@ class TogetherWrapper extends BaseWrapper {
result.choices[0].message.content += chunk.choices[0].delta.content;
}
- // Handle tool calls for streaming
if (chunk.choices[0]?.delta?.tool_calls) {
const deltaTools = chunk.choices[0].delta.tool_calls;
-
+
for (const tool of deltaTools) {
const idx = tool.index || 0;
-
+
while (toolCalls.length <= idx) {
toolCalls.push({
id: '',
type: 'function',
- function: { name: '', arguments: '' }
+ function: { name: '', arguments: '' },
});
}
-
+
if (tool.id) {
toolCalls[idx].id = tool.id;
toolCalls[idx].type = tool.type || 'function';
@@ -152,20 +179,20 @@ class TogetherWrapper extends BaseWrapper {
toolCalls[idx].function.arguments += tool.function.arguments;
}
}
-
+
+ tools = true;
}
yield chunk;
}
-
+
if (toolCalls.length > 0) {
result.choices[0].message = {
...result.choices[0].message,
- tool_calls: toolCalls
+ tool_calls: toolCalls,
} as any;
}
- // Fall back to token estimation if usage wasn't returned in the stream
if (!result.usage.prompt_tokens && !result.usage.completion_tokens) {
let promptTokens = 0;
for (const message of messages || []) {
@@ -184,7 +211,8 @@ class TogetherWrapper extends BaseWrapper {
}
}
- // Calculate TTFT and TBT
+ args[0].tools = tools;
+
const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
if (timestamps.length > 1) {
@@ -228,56 +256,60 @@ class TogetherWrapper extends BaseWrapper {
ttft?: number;
tbt?: number;
}) {
- const traceContent = OpenlitConfig.traceContent;
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const requestModel = args[0]?.model || 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo';
const {
messages,
frequency_penalty = 0,
max_tokens = null,
+ n = 1,
presence_penalty = 0,
+ seed = null,
stop = null,
- temperature = 0.7,
+ temperature = 1,
top_p,
top_k,
user,
stream = false,
} = args[0];
- // Request Params attributes
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, top_p || 1);
- if (top_k !== undefined) {
+ if (top_k != null) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, top_k);
}
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens || -1);
+ if (max_tokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ if (presence_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, presence_penalty);
+ }
+ if (frequency_penalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, frequency_penalty);
+ }
+ if (seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(seed));
+ }
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, stream);
if (stop) {
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(stop) ? stop : [stop]);
}
- if (user) {
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_USER, user);
+ if (n && n !== 1) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_CHOICE_COUNT, n);
}
- if (traceContent) {
+ if (captureContent) {
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages || []));
}
- span.setAttribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT
- );
-
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, result.id);
- const model = result.model || args[0].model || 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo';
- const responseModel = result.model || model;
+ const responseModel = result.model || requestModel;
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
- // Calculate cost of the operation
const cost = OpenLitHelper.getChatModelCost(
- model,
+ requestModel,
pricingInfo,
result.usage.prompt_tokens,
result.usage.completion_tokens
@@ -285,7 +317,7 @@ class TogetherWrapper extends BaseWrapper {
TogetherWrapper.setBaseSpanAttributes(span, {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: TogetherWrapper.aiSystem,
@@ -293,19 +325,13 @@ class TogetherWrapper extends BaseWrapper {
serverPort: TogetherWrapper.serverPort,
});
- // Response model
span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
- // Token usage
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, result.usage.prompt_tokens);
- span.setAttribute(
- SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
- result.usage.completion_tokens
- );
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, result.usage.total_tokens);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, result.usage.total_tokens);
-
- // TTFT and TBT metrics
+ const inputTokens = result.usage.prompt_tokens;
+ const outputTokens = result.usage.completion_tokens;
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
if (ttft > 0) {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
}
@@ -313,28 +339,24 @@ class TogetherWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
}
- // Finish reason
if (result.choices[0].finish_reason) {
span.setAttribute(
SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[result.choices[0].finish_reason]
);
}
-
- // Output type
- const outputType = typeof result.choices[0].message.content === 'string'
- ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+
+ const outputType = typeof result.choices[0].message.content === 'string'
+ ? SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
: SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON;
span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
- // Tool calls handling
if (result.choices[0].message.tool_calls) {
const toolCalls = result.choices[0].message.tool_calls;
const toolNames = toolCalls.map((t: any) => t.function?.name || '').filter(Boolean);
const toolIds = toolCalls.map((t: any) => t.id || '').filter(Boolean);
const toolArgs = toolCalls.map((t: any) => t.function?.arguments || '').filter(Boolean);
- const toolTypes = toolCalls.map((t: any) => t.type || '').filter(Boolean);
-
+
if (toolNames.length > 0) {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
}
@@ -342,28 +364,46 @@ class TogetherWrapper extends BaseWrapper {
span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
}
if (toolArgs.length > 0) {
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- }
- if (toolTypes.length > 0) {
- const toolTypesStr = toolTypes.join(', ');
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE, toolTypesStr);
- span.setAttribute(SemanticConvention.GEN_AI_TOOL_TYPE_OTEL, toolTypesStr);
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
}
}
- // Content
- if (traceContent) {
- const completionContent = result.choices[0].message.content || '';
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
const toolCalls = result.choices[0].message.tool_calls;
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(completionContent, result.choices[0].finish_reason || 'stop', toolCalls)
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.choices[0].message.content || '',
+ result.choices[0].finish_reason || 'stop',
+ toolCalls
);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages || []);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: TogetherWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: TogetherWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_ID]: result.id,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [result.choices[0].finish_reason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
}
return {
genAIEndpoint,
- model,
+ model: requestModel,
user,
cost,
aiSystem: TogetherWrapper.aiSystem,
diff --git a/sdk/typescript/src/instrumentation/vercel-ai/wrapper.ts b/sdk/typescript/src/instrumentation/vercel-ai/wrapper.ts
index 9dac50e3..fc3542d3 100644
--- a/sdk/typescript/src/instrumentation/vercel-ai/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/vercel-ai/wrapper.ts
@@ -1,119 +1,88 @@
-import { Span, SpanKind, Tracer, context, trace } from '@opentelemetry/api';
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
import OpenlitConfig from '../../config';
import OpenLitHelper from '../../helpers';
import SemanticConvention from '../../semantic-convention';
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+function spanCreationAttrs(
+ operationName: string,
+ requestModel: string
+): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: VercelAIWrapper.aiSystem,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: VercelAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: VercelAIWrapper.serverPort,
+ };
+}
+
class VercelAIWrapper extends BaseWrapper {
- static aiSystem = 'vercel_ai';
-
- static _getProviderFromModel(model: any): string {
- if (!model) return VercelAIWrapper.aiSystem;
- const provider = model.provider || '';
- if (provider.startsWith('openai')) return SemanticConvention.GEN_AI_SYSTEM_OPENAI;
- if (provider.startsWith('anthropic')) return SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC;
- if (provider.startsWith('google')) return SemanticConvention.GEN_AI_SYSTEM_VERTEXAI;
- if (provider.startsWith('mistral')) return SemanticConvention.GEN_AI_SYSTEM_MISTRAL;
- if (provider.startsWith('cohere')) return SemanticConvention.GEN_AI_SYSTEM_COHERE;
- if (provider.startsWith('amazon') || provider.startsWith('aws')) return SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK;
- return VercelAIWrapper.aiSystem;
- }
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_VERCEL_AI;
+ static serverAddress = 'vercel.ai';
+ static serverPort = 443;
static _patchGenerateText(tracer: Tracer): any {
- const genAIEndpoint = 'ai.generateText';
+ const genAIEndpoint = 'vercel_ai.generateText';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
- try {
- const response = await originalMethod.apply(this, args);
- const params = args[0] || {};
- const model = params.model;
- const modelId = model?.modelId || 'unknown';
- const aiSystem = VercelAIWrapper._getProviderFromModel(model);
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(
- modelId,
- pricingInfo,
- response.usage?.promptTokens || 0,
- response.usage?.completionTokens || 0
- );
-
- VercelAIWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem });
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.maxTokens || -1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, params.temperature ?? 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, params.topP ?? 1);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, response.usage?.promptTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage?.completionTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, response.usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, response.usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [response.finishReason || 'stop']);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
-
- if (response.toolCalls?.length > 0) {
- const toolNames = response.toolCalls.map((t: any) => t.toolName || '').filter(Boolean);
- const toolArgs = response.toolCalls.map((t: any) => JSON.stringify(t.args || {}));
- if (toolNames.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
- if (toolArgs.length > 0) span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ARGUMENTS, toolArgs);
- }
-
- if (OpenlitConfig.traceContent) {
- const messages = params.messages || (params.prompt ? [{ role: 'user', content: params.prompt }] : []);
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages));
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(response.text || '', response.finishReason || 'stop', response.toolCalls)
- );
- }
-
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem };
- return response;
- } catch (e: any) {
+ const params = args[0] || {};
+ const modelId = params.model?.modelId || 'unknown';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, modelId),
+ });
+ return context
+ .with(trace.setSpan(context.active(), span), async () => {
+ return originalMethod.apply(this, args);
+ })
+ .then((response: any) => {
+ return VercelAIWrapper._chatComplete({
+ args,
+ genAIEndpoint,
+ response,
+ span,
+ outputType: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ });
+ })
+ .catch((e: any) => {
OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
- }
- });
+ throw e;
+ });
};
};
}
static _patchStreamText(tracer: Tracer): any {
- const genAIEndpoint = 'ai.streamText';
+ const genAIEndpoint = 'vercel_ai.streamText';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ const params = args[0] || {};
+ const modelId = params.model?.modelId || 'unknown';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, modelId),
+ });
const startTime = Date.now();
const chunkTimestamps: number[] = [];
try {
- const response = await originalMethod.apply(this, args);
- const params = args[0] || {};
- const model = params.model;
- const modelId = model?.modelId || 'unknown';
- const aiSystem = VercelAIWrapper._getProviderFromModel(model);
-
- // Set request attributes immediately
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, true);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.maxTokens || -1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, params.temperature ?? 1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, params.topP ?? 1);
-
- if (OpenlitConfig.traceContent) {
- const messages = params.messages || (params.prompt ? [{ role: 'user', content: params.prompt }] : []);
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages));
- }
+ const response = await context.with(
+ trace.setSpan(context.active(), span),
+ async () => originalMethod.apply(this, args)
+ );
- // Intercept textStream to capture per-chunk timestamps for TTFT/TBT
try {
const originalTextStream = response.textStream as ReadableStream<string>;
if (originalTextStream && typeof originalTextStream.getReader === 'function') {
@@ -139,12 +108,12 @@ class VercelAIWrapper extends BaseWrapper {
});
}
} catch (_) {
- // Stream interception failed; TTFT/TBT won't be captured from textStream
+ // Stream interception is best-effort; TTFT/TBT won't be captured
}
- // Observe stream completion via usage promise
Promise.resolve(response.usage)
.then(async (usage: any) => {
+ let metricParams;
try {
const ttft = chunkTimestamps.length > 0 ? (chunkTimestamps[0] - startTime) / 1000 : 0;
let tbt = 0;
@@ -153,51 +122,65 @@ class VercelAIWrapper extends BaseWrapper {
tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
}
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(
- modelId,
- pricingInfo,
- usage?.promptTokens || 0,
- usage?.completionTokens || 0
- );
-
- VercelAIWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem });
-
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, usage?.promptTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, usage?.completionTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
- if (ttft > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
- if (tbt > 0) span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
-
const finishReason = await Promise.resolve(response.finishReason).catch(() => 'stop');
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason || 'stop']);
-
- if (OpenlitConfig.traceContent) {
- const text = await Promise.resolve(response.text).catch(() => '');
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(text || '', finishReason || 'stop')
- );
- }
-
- BaseWrapper.recordMetrics(span, { genAIEndpoint, model: modelId, cost, aiSystem });
+ const text = await Promise.resolve(response.text).catch(() => '');
+ const toolCalls = await Promise.resolve(response.toolCalls).catch(() => undefined);
+ const responseDetails = await Promise.resolve(response.response).catch(() => undefined);
+
+ const result = {
+ usage: {
+ promptTokens: usage?.promptTokens || 0,
+ completionTokens: usage?.completionTokens || 0,
+ },
+ finishReason: finishReason || 'stop',
+ text: text || '',
+ toolCalls,
+ response: responseDetails,
+ };
+
+ metricParams = await VercelAIWrapper._chatCommonSetter({
+ args,
+ genAIEndpoint,
+ result,
+ span,
+ isStream: true,
+ outputType: SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT,
+ ttft,
+ tbt,
+ });
} catch (e: any) {
OpenLitHelper.handleException(span, e);
} finally {
span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
}
})
.catch((e: any) => {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
});
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
throw e;
}
@@ -206,98 +189,108 @@ class VercelAIWrapper extends BaseWrapper {
}
static _patchGenerateObject(tracer: Tracer): any {
- const genAIEndpoint = 'ai.generateObject';
+ const genAIEndpoint = 'vercel_ai.generateObject';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
- return context.with(trace.setSpan(context.active(), span), async () => {
- let metricParams: BaseSpanAttributes | undefined;
- try {
- const response = await originalMethod.apply(this, args);
- const params = args[0] || {};
- const model = params.model;
- const modelId = model?.modelId || 'unknown';
- const aiSystem = VercelAIWrapper._getProviderFromModel(model);
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getChatModelCost(
- modelId,
- pricingInfo,
- response.usage?.promptTokens || 0,
- response.usage?.completionTokens || 0
- );
-
- VercelAIWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem });
-
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.maxTokens || -1);
- span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, params.temperature ?? 1);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, response.usage?.promptTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, response.usage?.completionTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, response.usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, response.usage?.totalTokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [response.finishReason || 'stop']);
- span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON);
-
- if (OpenlitConfig.traceContent) {
- const messages = params.messages || (params.prompt ? [{ role: 'user', content: params.prompt }] : []);
- span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, OpenLitHelper.buildInputMessages(messages));
- span.setAttribute(
- SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
- OpenLitHelper.buildOutputMessages(JSON.stringify(response.object || {}), response.finishReason || 'stop')
- );
- }
-
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem };
- return response;
- } catch (e: any) {
+ const params = args[0] || {};
+ const modelId = params.model?.modelId || 'unknown';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, modelId),
+ });
+ return context
+ .with(trace.setSpan(context.active(), span), async () => {
+ return originalMethod.apply(this, args);
+ })
+ .then((response: any) => {
+ const result = {
+ ...response,
+ text: JSON.stringify(response.object || {}),
+ };
+ return VercelAIWrapper._chatComplete({
+ args,
+ genAIEndpoint,
+ response,
+ span,
+ outputType: SemanticConvention.GEN_AI_OUTPUT_TYPE_JSON,
+ resultOverride: result,
+ });
+ })
+ .catch((e: any) => {
OpenLitHelper.handleException(span, e);
- throw e;
- } finally {
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
span.end();
- if (metricParams) BaseWrapper.recordMetrics(span, metricParams);
- }
- });
+ throw e;
+ });
};
};
}
static _patchEmbed(tracer: Tracer): any {
- const genAIEndpoint = 'ai.embed';
+ const genAIEndpoint = 'vercel_ai.embed';
return (originalMethod: (...args: any[]) => any) => {
return async function (this: any, ...args: any[]) {
- const span = tracer.startSpan(genAIEndpoint, { kind: SpanKind.CLIENT });
+ const params = args[0] || {};
+ const modelId = params.model?.modelId || 'unknown';
+ const spanName = `${SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} ${modelId}`;
+ const span = tracer.startSpan(spanName, {
+ kind: SpanKind.CLIENT,
+ attributes: spanCreationAttrs(SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, modelId),
+ });
return context.with(trace.setSpan(context.active(), span), async () => {
+ const captureContent = OpenlitConfig.captureMessageContent;
let metricParams: BaseSpanAttributes | undefined;
try {
const response = await originalMethod.apply(this, args);
- const params = args[0] || {};
- const model = params.model;
- const modelId = model?.modelId || 'unknown';
- const aiSystem = VercelAIWrapper._getProviderFromModel(model);
-
- const pricingInfo = await OpenlitConfig.updatePricingJson(OpenlitConfig.pricing_json);
- const cost = OpenLitHelper.getEmbedModelCost(modelId, pricingInfo, response.usage?.tokens || 0);
- VercelAIWrapper.setBaseSpanAttributes(span, { genAIEndpoint, model: modelId, cost, aiSystem });
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const inputTokens = response.usage?.tokens || 0;
+ const cost = OpenLitHelper.getEmbedModelCost(modelId, pricingInfo, inputTokens);
+
+ VercelAIWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ });
- span.setAttribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING);
span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
- span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, modelId);
- span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, response.usage?.tokens || 0);
- span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, response.usage?.tokens || 0);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
- if (OpenlitConfig.traceContent && params.value !== undefined) {
+ if (captureContent && params.value !== undefined) {
const inputStr = typeof params.value === 'string' ? params.value : JSON.stringify(params.value);
span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputStr);
}
- metricParams = { genAIEndpoint, model: modelId, cost, aiSystem };
+ metricParams = {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ };
return response;
} catch (e: any) {
OpenLitHelper.handleException(span, e);
+ metricParams = {
+ genAIEndpoint,
+ model: modelId,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ };
throw e;
} finally {
span.end();
@@ -307,6 +300,201 @@ class VercelAIWrapper extends BaseWrapper {
};
};
}
+
+ static async _chatComplete({
+ args,
+ genAIEndpoint,
+ response,
+ span,
+ outputType,
+ resultOverride,
+ }: {
+ args: any[];
+ genAIEndpoint: string;
+ response: any;
+ span: Span;
+ outputType: string;
+ resultOverride?: any;
+ }): Promise<any> {
+ let metricParams;
+ try {
+ metricParams = await VercelAIWrapper._chatCommonSetter({
+ args,
+ genAIEndpoint,
+ result: resultOverride || response,
+ span,
+ isStream: false,
+ outputType,
+ });
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ }
+
+ static async _chatCommonSetter({
+ args,
+ genAIEndpoint,
+ result,
+ span,
+ isStream,
+ outputType,
+ ttft = 0,
+ tbt = 0,
+ }: {
+ args: any[];
+ genAIEndpoint: string;
+ result: any;
+ span: Span;
+ isStream: boolean;
+ outputType: string;
+ ttft?: number;
+ tbt?: number;
+ }) {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const params = args[0] || {};
+ const modelId = params.model?.modelId || 'unknown';
+
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, params.temperature ?? 1);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, params.topP ?? 1);
+ if (params.maxTokens != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, params.maxTokens);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, isStream);
+ if (params.seed != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_SEED, Number(params.seed));
+ }
+ if (params.frequencyPenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, params.frequencyPenalty);
+ }
+ if (params.presencePenalty) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, params.presencePenalty);
+ }
+ if (params.stopSequences) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
+ Array.isArray(params.stopSequences) ? params.stopSequences : [params.stopSequences]
+ );
+ }
+ if (params.topK != null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, params.topK);
+ }
+
+ const messages = params.messages || (params.prompt ? [{ role: 'user', content: params.prompt }] : []);
+
+ if (captureContent) {
+ span.setAttribute(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ OpenLitHelper.buildInputMessages(messages, params.system)
+ );
+ }
+
+ const responseId = result.response?.id;
+ const responseModel = result.response?.modelId || modelId;
+ const inputTokens = result.usage?.promptTokens || 0;
+ const outputTokens = result.usage?.completionTokens || 0;
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(modelId, pricingInfo, inputTokens, outputTokens);
+
+ VercelAIWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ });
+
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, responseModel);
+ if (responseId) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ID, responseId);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+
+ const finishReason = result.finishReason || 'stop';
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, outputType);
+
+ if (ttft > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ }
+ if (tbt > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt);
+ }
+
+ if (result.toolCalls?.length > 0) {
+ const toolNames = result.toolCalls.map((t: any) => t.toolName || '').filter(Boolean);
+ const toolIds = result.toolCalls.map((t: any) => t.toolCallId || '').filter(Boolean);
+ const toolArgs = result.toolCalls.map((t: any) => JSON.stringify(t.args || {})).filter(Boolean);
+
+ if (toolNames.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_NAME, toolNames.join(', '));
+ }
+ if (toolIds.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
+ }
+ if (toolArgs.length > 0) {
+ span.setAttribute(SemanticConvention.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
+ }
+ }
+
+ const normalizedToolCalls = result.toolCalls?.map((t: any) => ({
+ id: t.toolCallId || '',
+ name: t.toolName || '',
+ arguments: t.args || {},
+ }));
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(
+ result.text || '',
+ finishReason,
+ normalizedToolCalls
+ );
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ inputMessagesJson = OpenLitHelper.buildInputMessages(messages, params.system);
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: modelId,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: responseModel,
+ [SemanticConvention.SERVER_ADDRESS]: VercelAIWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: VercelAIWrapper.serverPort,
+ [SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
+ [SemanticConvention.GEN_AI_OUTPUT_TYPE]: outputType,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ };
+ if (responseId) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_ID] = responseId;
+ }
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
+ return {
+ genAIEndpoint,
+ model: modelId,
+ cost,
+ aiSystem: VercelAIWrapper.aiSystem,
+ serverAddress: VercelAIWrapper.serverAddress,
+ serverPort: VercelAIWrapper.serverPort,
+ };
+ }
}
export default VercelAIWrapper;
diff --git a/sdk/typescript/src/llm/anthropic.ts b/sdk/typescript/src/llm/anthropic.ts
index c7c5a4b8..bcde9ed6 100644
--- a/sdk/typescript/src/llm/anthropic.ts
+++ b/sdk/typescript/src/llm/anthropic.ts
@@ -1,5 +1,3 @@
-import Anthropic from '@anthropic-ai/sdk';
-
export async function llmResponseAnthropic({
prompt,
model,
@@ -9,6 +7,15 @@ export async function llmResponseAnthropic({
model?: string;
apiKey?: string;
}): Promise<string> {
+ let Anthropic: any;
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ Anthropic = require('@anthropic-ai/sdk').default;
+ } catch {
+ throw new Error(
+ "openlit guard/eval features require the '@anthropic-ai/sdk' package. Install it with: npm install @anthropic-ai/sdk"
+ );
+ }
const client = new Anthropic({ apiKey });
const usedModel = model || 'claude-3-opus-20240229';
const response = await client.messages.create({
@@ -29,7 +36,7 @@ export async function llmResponseAnthropic({
}
return response.content
.filter((p: { type: string; text?: unknown }) : p is { type: 'text'; text: string } => p.type === 'text' && typeof p.text === 'string')
- .map(p => p.text)
+ .map((p: { text: string }) => p.text)
.join(' ');
}
return '';
diff --git a/sdk/typescript/src/llm/openai.ts b/sdk/typescript/src/llm/openai.ts
index e9444ce4..edae8060 100644
--- a/sdk/typescript/src/llm/openai.ts
+++ b/sdk/typescript/src/llm/openai.ts
@@ -1,5 +1,3 @@
-import OpenAI from 'openai';
-
export async function llmResponseOpenAI({
prompt,
model,
@@ -11,6 +9,15 @@ export async function llmResponseOpenAI({
apiKey?: string;
baseUrl?: string;
}): Promise<string> {
+ let OpenAI: any;
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ OpenAI = require('openai').default;
+ } catch {
+ throw new Error(
+ "openlit guard/eval features require the 'openai' package. Install it with: npm install openai"
+ );
+ }
const client = new OpenAI({
apiKey,
baseURL: baseUrl || 'https://api.openai.com/v1',
diff --git a/sdk/typescript/src/otel/__tests__/metrics.test.ts b/sdk/typescript/src/otel/__tests__/metrics.test.ts
index 659983cb..f302f4a1 100644
--- a/sdk/typescript/src/otel/__tests__/metrics.test.ts
+++ b/sdk/typescript/src/otel/__tests__/metrics.test.ts
@@ -1,29 +1,28 @@
import Metrics from '../metrics';
import SemanticConvention from '../../semantic-convention';
import { defaultResource } from '@opentelemetry/resources';
-import { ConsoleMetricExporter } from '@opentelemetry/sdk-metrics';
+
+const setupOpts = {
+ resource: defaultResource(),
+ otlpEndpoint: 'http://localhost:4318',
+ environment: 'default',
+ applicationName: 'default',
+ disableBatch: false,
+ captureMessageContent: true,
+ disableMetrics: false,
+ disableEvents: false,
+};
describe('Metrics creation', () => {
beforeEach(() => {
- Metrics.setup({ resource: defaultResource(), otlpEndpoint: 'http://localhost:4318' }); // Ensure metrics are initialized
- });
-
- it('should create genaiRequests counter and allow increment', () => {
- expect(Metrics.genaiRequests).toBeDefined();
- expect(typeof Metrics.genaiRequests.add).toBe('function');
- expect(() => Metrics.genaiRequests.add(1, { [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
- });
-
- it('should create genaiPromptTokens counter and allow increment', () => {
- expect(Metrics.genaiPromptTokens).toBeDefined();
- expect(typeof Metrics.genaiPromptTokens.add).toBe('function');
- expect(() => Metrics.genaiPromptTokens.add(42, { [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
+ Metrics.resetForTesting();
+ Metrics.setup(setupOpts as any);
});
- it('should create genaiCompletionTokens counter and allow increment', () => {
- expect(Metrics.genaiCompletionTokens).toBeDefined();
- expect(typeof Metrics.genaiCompletionTokens.add).toBe('function');
- expect(() => Metrics.genaiCompletionTokens.add(24, { [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
+ it('should create genaiClientUsageTokens histogram and allow record', () => {
+ expect(Metrics.genaiClientUsageTokens).toBeDefined();
+ expect(typeof Metrics.genaiClientUsageTokens.record).toBe('function');
+ expect(() => Metrics.genaiClientUsageTokens.record(42, { [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
});
it('should create genaiClientOperationDuration histogram and allow record', () => {
@@ -37,17 +36,4 @@ describe('Metrics creation', () => {
expect(typeof Metrics.genaiCost.record).toBe('function');
expect(() => Metrics.genaiCost.record(0.99, { [SemanticConvention.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
});
-
- it('should throw an error when allowConsoleExporterFallback is not set and fallback is required', () => {
- expect(() => {
- Metrics.handleExporterFallback(new Error('Simulated OTLPMetricExporter failure'), false);
- }).toThrow('[Metrics] Failed to initialize OTLPMetricExporter and fallback to ConsoleMetricExporter is disabled. Set allowConsoleExporterFallback=true to enable fallback (not recommended for production).');
- });
-
- it('should use ConsoleMetricExporter when allowConsoleExporterFallback is set to true', () => {
- expect(() => {
- const exporter = Metrics.handleExporterFallback(new Error('Simulated OTLPMetricExporter failure'), true);
- expect(exporter).toBeInstanceOf(ConsoleMetricExporter);
- }).not.toThrow();
- });
});
diff --git a/sdk/typescript/src/otel/events.ts b/sdk/typescript/src/otel/events.ts
new file mode 100644
index 00000000..ddd0b5e1
--- /dev/null
+++ b/sdk/typescript/src/otel/events.ts
@@ -0,0 +1,88 @@
+import { logs } from '@opentelemetry/api-logs';
+import {
+ LoggerProvider,
+ BatchLogRecordProcessor,
+ SimpleLogRecordProcessor,
+ ConsoleLogRecordExporter,
+ LogRecordProcessor,
+} from '@opentelemetry/sdk-logs';
+import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
+import { SetupEventsOptions } from '../types';
+import { parseExporters } from './utils';
+
+let EVENTS_SET = false;
+
+export default class Events {
+ static loggerProvider: LoggerProvider;
+ static logger: ReturnType<typeof logs.getLogger>;
+
+ static setup(options: SetupEventsOptions) {
+ try {
+ if (!EVENTS_SET) {
+ const existingProvider = logs.getLoggerProvider();
+ const isSDKProvider =
+ existingProvider &&
+ typeof (existingProvider as any).forceFlush === 'function' &&
+ existingProvider.constructor.name !== 'NoopLoggerProvider';
+
+ if (isSDKProvider) {
+ this.loggerProvider = existingProvider as unknown as LoggerProvider;
+ } else {
+ this.loggerProvider = Events.buildLoggerProvider(options);
+ logs.setGlobalLoggerProvider(this.loggerProvider);
+ }
+
+ this.logger = this.loggerProvider.getLogger('openlit');
+ EVENTS_SET = true;
+ }
+
+ return this.logger;
+ } catch (e) {
+ console.error('[Events] Failed to initialize events:', e);
+ return null;
+ }
+ }
+
+ private static buildLoggerProvider(options: SetupEventsOptions): LoggerProvider {
+ const exporterList = parseExporters('OTEL_LOGS_EXPORTER');
+ const processors: LogRecordProcessor[] = [];
+
+ if (exporterList) {
+ for (const name of exporterList) {
+ if (name === 'otlp') {
+ processors.push(Events.createOTLPProcessor(options));
+ } else if (name === 'console') {
+ processors.push(new SimpleLogRecordProcessor(new ConsoleLogRecordExporter()));
+ }
+ }
+ } else {
+ if (options.otlpEndpoint) {
+ processors.push(Events.createOTLPProcessor(options));
+ } else {
+ processors.push(new SimpleLogRecordProcessor(new ConsoleLogRecordExporter()));
+ }
+ }
+
+ return new LoggerProvider({
+ resource: options.resource,
+ processors,
+ });
+ }
+
+ private static createOTLPProcessor(
+ options: SetupEventsOptions
+ ): BatchLogRecordProcessor | SimpleLogRecordProcessor {
+ const url = (options.otlpEndpoint || '') + '/v1/logs';
+ const exporter = new OTLPLogExporter({
+ url,
+ headers: options.otlpHeaders as Record<string, string> | undefined,
+ });
+ return options.disableBatch
+ ? new SimpleLogRecordProcessor(exporter)
+ : new BatchLogRecordProcessor(exporter);
+ }
+
+ static resetForTesting() {
+ EVENTS_SET = false;
+ }
+}
diff --git a/sdk/typescript/src/otel/metrics.ts b/sdk/typescript/src/otel/metrics.ts
index f14e5cb7..54fb12a5 100644
--- a/sdk/typescript/src/otel/metrics.ts
+++ b/sdk/typescript/src/otel/metrics.ts
@@ -7,6 +7,7 @@ import { metrics } from '@opentelemetry/api';
import SemanticConvention from '../semantic-convention';
import { SetupMetricsOptions } from '../types';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
+import { parseExporters } from './utils';
const DB_CLIENT_OPERATION_DURATION_BUCKETS = [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10];
@@ -24,6 +25,8 @@ const GEN_AI_CLIENT_TOKEN_USAGE_BUCKETS = [
1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864,
];
+let METER_SET = false;
+
export default class Metrics {
static meterProvider: MeterProvider;
static meter: ReturnType<typeof metrics.getMeter>;
@@ -41,16 +44,12 @@ export default class Metrics {
static dbClientOperationDuration: ReturnType<
ReturnType<typeof metrics.getMeter>['createHistogram']
>;
- static genaiRequests: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
- static genaiPromptTokens: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
- static genaiCompletionTokens: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
- static genaiReasoningTokens: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
static genaiCost: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
static dbRequests: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
static initializeMetrics() {
this.genaiClientUsageTokens = this.meter.createHistogram(
- SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
+ SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
{
description: 'Measures number of input and output tokens used',
unit: '{token}',
@@ -123,31 +122,6 @@ export default class Metrics {
},
}
);
- this.genaiRequests = this.meter.createCounter(SemanticConvention.GEN_AI_REQUESTS, {
- description: 'Number of requests to GenAI',
- unit: '1',
- });
- this.genaiPromptTokens = this.meter.createCounter(
- SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
- {
- description: 'Number of prompt tokens processed.',
- unit: '1',
- }
- );
- this.genaiCompletionTokens = this.meter.createCounter(
- SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
- {
- description: 'Number of completion tokens processed.',
- unit: '1',
- }
- );
- this.genaiReasoningTokens = this.meter.createCounter(
- SemanticConvention.GEN_AI_USAGE_REASONING_TOKENS,
- {
- description: 'Number of reasoning thought tokens processed.',
- unit: '1',
- }
- );
this.genaiCost = this.meter.createHistogram(SemanticConvention.GEN_AI_USAGE_COST, {
description: 'The distribution of GenAI request costs.',
unit: 'USD',
@@ -158,53 +132,88 @@ export default class Metrics {
});
}
- static handleExporterFallback(err: Error, allowConsoleExporterFallback: boolean): ConsoleMetricExporter {
- if (allowConsoleExporterFallback) {
- console.warn(
- '[Metrics] Falling back to ConsoleMetricExporter. WARNING: ConsoleMetricExporter may expose sensitive data in logs. Do NOT use in production!',
- err
- );
- return new ConsoleMetricExporter();
- } else {
- throw new Error(
- '[Metrics] Failed to initialize OTLPMetricExporter and fallback to ConsoleMetricExporter is disabled. Set allowConsoleExporterFallback=true to enable fallback (not recommended for production).'
- );
- }
- }
-
static setup(options: SetupMetricsOptions) {
if (options.meter) {
this.meter = options.meter;
this.initializeMetrics();
return this.meter;
}
+
try {
- let metricExporter: OTLPMetricExporter | ConsoleMetricExporter;
- try {
- const url = options.otlpEndpoint + '/v1/metrics';
- metricExporter = new OTLPMetricExporter({
- url,
- headers: options.otlpHeaders as Record<string, string> | undefined,
- });
- } catch (err) {
- metricExporter = this.handleExporterFallback(err as Error, options.allowConsoleExporterFallback ?? false);
+ if (!METER_SET) {
+ const existingProvider = metrics.getMeterProvider();
+ const isSDKProvider =
+ existingProvider &&
+ typeof (existingProvider as any).getMeter === 'function' &&
+ existingProvider.constructor.name !== 'NoopMeterProvider';
+
+ if (isSDKProvider) {
+ this.meterProvider = existingProvider as unknown as MeterProvider;
+ } else {
+ const readers = Metrics.buildMetricReaders(options);
+ this.meterProvider = new MeterProvider({
+ resource: options.resource,
+ readers,
+ });
+ metrics.setGlobalMeterProvider(this.meterProvider);
+ this.metricReaders.push(...(readers as PeriodicExportingMetricReader[]));
+ }
+
+ this.meter = this.meterProvider.getMeter('openlit', '1.0.0');
+ this.initializeMetrics();
+ METER_SET = true;
}
- const metricReader = new PeriodicExportingMetricReader({
- exportIntervalMillis: options.exportIntervalMillis || 60000,
- exporter: metricExporter,
- });
- this.meterProvider = new MeterProvider({
- resource: options.resource,
- readers: [metricReader],
- });
- metrics.setGlobalMeterProvider(this.meterProvider);
- this.meter = this.meterProvider.getMeter('openlit', '1.0.0');
- this.metricReaders.push(metricReader);
- this.initializeMetrics();
+
return this.meter;
} catch (e) {
console.error('[Metrics] Failed to initialize metrics:', e);
return null;
}
}
+
+ private static buildMetricReaders(options: SetupMetricsOptions) {
+ const readers: PeriodicExportingMetricReader[] = [];
+ const exporterList = parseExporters('OTEL_METRICS_EXPORTER');
+
+ if (exporterList) {
+ for (const name of exporterList) {
+ if (name === 'otlp') {
+ readers.push(Metrics.createOTLPReader(options));
+ } else if (name === 'console') {
+ readers.push(Metrics.createConsoleReader(options));
+ }
+ }
+ } else {
+ if (options.otlpEndpoint) {
+ readers.push(Metrics.createOTLPReader(options));
+ } else {
+ readers.push(Metrics.createConsoleReader(options));
+ }
+ }
+
+ return readers;
+ }
+
+ private static createOTLPReader(options: SetupMetricsOptions): PeriodicExportingMetricReader {
+ const url = (options.otlpEndpoint || '') + '/v1/metrics';
+ const exporter = new OTLPMetricExporter({
+ url,
+ headers: options.otlpHeaders as Record<string, string> | undefined,
+ });
+ return new PeriodicExportingMetricReader({
+ exportIntervalMillis: options.exportIntervalMillis || 60000,
+ exporter,
+ });
+ }
+
+ private static createConsoleReader(options: SetupMetricsOptions): PeriodicExportingMetricReader {
+ return new PeriodicExportingMetricReader({
+ exportIntervalMillis: options.exportIntervalMillis || 60000,
+ exporter: new ConsoleMetricExporter(),
+ });
+ }
+
+ static resetForTesting() {
+ METER_SET = false;
+ }
}
diff --git a/sdk/typescript/src/otel/tracing.ts b/sdk/typescript/src/otel/tracing.ts
index cea933f9..64ecfc04 100644
--- a/sdk/typescript/src/otel/tracing.ts
+++ b/sdk/typescript/src/otel/tracing.ts
@@ -1,3 +1,4 @@
+import { trace } from '@opentelemetry/api';
import { SetupTracerOptions } from '../types';
import {
NodeTracerProvider,
@@ -10,49 +11,105 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import Instrumentations from '../instrumentation';
import OpenlitConfig from '../config';
+import { parseExporters } from './utils';
+
+let TRACER_SET = false;
export default class Tracing {
static traceProvider: NodeTracerProvider;
- static traceExporter: OTLPTraceExporter;
- static async setup(options: SetupTracerOptions) {
+ static traceExporter: OTLPTraceExporter | undefined;
+
+ static setup(options: SetupTracerOptions) {
if (options.tracer) return options.tracer;
+
try {
- const consoleSpanExporter = new ConsoleSpanExporter();
- const url = options.otlpEndpoint + "/v1/traces";
- const otlpTraceExporter = new OTLPTraceExporter({
- url,
- headers: options.otlpHeaders as Record<string, string> | undefined,
- });
-
- const spanProcessors = [
- new SimpleSpanProcessor(consoleSpanExporter),
- options.disableBatch
- ? new SimpleSpanProcessor(otlpTraceExporter as SpanExporter)
- : new BatchSpanProcessor(otlpTraceExporter as SpanExporter),
- ];
-
- this.traceProvider = new NodeTracerProvider({
- resource: options.resource,
- spanProcessors,
- });
-
- OpenlitConfig.updateConfig({
- ...options,
- tracer: options.tracer || Tracing.traceProvider,
- });
-
- Instrumentations.setup(
- Tracing.traceProvider,
- options?.disabledInstrumentations,
- options?.instrumentations
- );
-
- this.traceExporter = otlpTraceExporter;
-
- this.traceProvider.register();
+ if (!TRACER_SET) {
+ const existingProvider = trace.getTracerProvider();
+ const isSDKProvider =
+ existingProvider &&
+ typeof (existingProvider as any).addSpanProcessor === 'function';
+
+ if (isSDKProvider) {
+ // Reuse existing SDK TracerProvider
+ this.traceProvider = existingProvider as unknown as NodeTracerProvider;
+ } else {
+ const spanProcessors = Tracing.buildSpanProcessors(options);
+
+ this.traceProvider = new NodeTracerProvider({
+ resource: options.resource,
+ spanProcessors,
+ });
+
+ this.traceProvider.register();
+ }
+
+ OpenlitConfig.updateConfig({
+ ...options,
+ tracer: options.tracer || Tracing.traceProvider,
+ });
+
+ Instrumentations.setup(
+ Tracing.traceProvider,
+ options?.disabledInstrumentors,
+ options?.instrumentations
+ );
+
+ TRACER_SET = true;
+ }
+
+ return trace.getTracer('openlit');
} catch (e) {
console.error('[Traces] Failed to initialize traces:', e);
return null;
}
}
+
+ private static buildSpanProcessors(options: SetupTracerOptions) {
+ const processors: (SimpleSpanProcessor | BatchSpanProcessor)[] = [];
+ const exporterList = parseExporters('OTEL_TRACES_EXPORTER');
+
+ if (exporterList) {
+ for (const name of exporterList) {
+ if (name === 'otlp') {
+ const exporter = Tracing.createOTLPExporter(options);
+ this.traceExporter = exporter;
+ processors.push(Tracing.wrapProcessor(exporter, options.disableBatch));
+ } else if (name === 'console') {
+ processors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));
+ }
+ }
+ } else {
+ // Default: OTLP if endpoint is set, otherwise Console
+ if (options.otlpEndpoint) {
+ const exporter = Tracing.createOTLPExporter(options);
+ this.traceExporter = exporter;
+ processors.push(Tracing.wrapProcessor(exporter, options.disableBatch));
+ } else {
+ processors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));
+ }
+ }
+
+ return processors;
+ }
+
+ private static createOTLPExporter(options: SetupTracerOptions): OTLPTraceExporter {
+ const url = (options.otlpEndpoint || '') + '/v1/traces';
+ return new OTLPTraceExporter({
+ url,
+ headers: options.otlpHeaders as Record<string, string> | undefined,
+ });
+ }
+
+ private static wrapProcessor(
+ exporter: SpanExporter,
+ disableBatch: boolean
+ ): SimpleSpanProcessor | BatchSpanProcessor {
+ return disableBatch
+ ? new SimpleSpanProcessor(exporter)
+ : new BatchSpanProcessor(exporter);
+ }
+
+ static resetForTesting() {
+ TRACER_SET = false;
+ }
}
diff --git a/sdk/typescript/src/otel/utils.ts b/sdk/typescript/src/otel/utils.ts
new file mode 100644
index 00000000..12a02cc2
--- /dev/null
+++ b/sdk/typescript/src/otel/utils.ts
@@ -0,0 +1,26 @@
+/**
+ * Parse a comma-separated OTel exporter env var into an array of exporter names.
+ * Returns null if the env var is not set (caller uses default logic).
+ * Matches Python's parse_exporters() in __helpers.py.
+ */
+export function parseExporters(envVarName: string): string[] | null {
+ const val = process.env[envVarName];
+ if (!val) return null;
+ return val
+ .split(',')
+ .map((e) => e.trim().toLowerCase())
+ .filter(Boolean);
+}
+
+/**
+ * Parse a boolean-like env var (true/1/yes -> true, false/0/no -> false).
+ * Returns undefined if the env var is not set.
+ */
+export function parseBoolEnv(envVarName: string): boolean | undefined {
+ const val = process.env[envVarName];
+ if (val === undefined || val === '') return undefined;
+ const lower = val.trim().toLowerCase();
+ if (['true', '1', 'yes'].includes(lower)) return true;
+ if (['false', '0', 'no'].includes(lower)) return false;
+ return undefined;
+}
diff --git a/sdk/typescript/src/semantic-convention.ts b/sdk/typescript/src/semantic-convention.ts
index 649e9525..5fc2319c 100644
--- a/sdk/typescript/src/semantic-convention.ts
+++ b/sdk/typescript/src/semantic-convention.ts
@@ -31,10 +31,7 @@ export default class SemanticConvention {
static GEN_AI_RESPONSE_MODEL = 'gen_ai.response.model';
static GEN_AI_INPUT_MESSAGES = 'gen_ai.input.messages';
static GEN_AI_OUTPUT_MESSAGES = 'gen_ai.output.messages';
- /** Legacy */
- static GEN_AI_SYSTEM_INSTRUCTIONS = 'gen_ai.system.instructions';
- /** OTel standard */
- static GEN_AI_SYSTEM_INSTRUCTIONS_OTEL = 'gen_ai.system_instructions';
+ static GEN_AI_SYSTEM_INSTRUCTIONS = 'gen_ai.system_instructions';
static GEN_AI_TOOL_DEFINITIONS = 'gen_ai.tool.definitions';
static GEN_AI_EMBEDDINGS_DIMENSION_COUNT = 'gen_ai.embeddings.dimension.count';
static GEN_AI_TOKEN_TYPE = 'gen_ai.token.type';
@@ -66,6 +63,7 @@ export default class SemanticConvention {
static GEN_AI_ASSISTANT_MESSAGE = 'gen_ai.assistant.message';
static GEN_AI_TOOL_MESSAGE = 'gen_ai.tools.message';
static GEN_AI_CHOICE = 'gen_ai.choice';
+ static GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS = 'gen_ai.client.inference.operation.details';
// ----- GenAI General (OpenLIT + OTel) -----
static GEN_AI_ENDPOINT = 'gen_ai.endpoint';
@@ -123,8 +121,14 @@ export default class SemanticConvention {
static GEN_AI_RESPONSE_IMAGE_SIZE = 'gen_ai.request.image_size';
static GEN_AI_RESPONSE_IMAGE_QUALITY = 'gen_ai.request.image_quality';
static GEN_AI_RESPONSE_IMAGE_STYLE = 'gen_ai.request.image_style';
- static GEN_AI_REQUEST_SERVICE_TIER = 'gen_ai.request.service_tier';
- static GEN_AI_RESPONSE_SERVICE_TIER = 'gen_ai.response.service_tier';
+
+ // OpenAI-specific attributes (openai.* namespace per OTel semconv)
+ static OPENAI_REQUEST_SERVICE_TIER = 'openai.request.service_tier';
+ static OPENAI_RESPONSE_SERVICE_TIER = 'openai.response.service_tier';
+ static OPENAI_RESPONSE_SYSTEM_FINGERPRINT = 'openai.response.system_fingerprint';
+ static OPENAI_API_TYPE = 'openai.api.type';
+
+ /** @deprecated Use OPENAI_RESPONSE_SYSTEM_FINGERPRINT for OpenAI */
static GEN_AI_RESPONSE_SYSTEM_FINGERPRINT = 'gen_ai.response.system_fingerprint';
// GenAI Content
@@ -159,6 +163,12 @@ export default class SemanticConvention {
static GEN_AI_AGENT_ID = 'gen_ai.agent.id';
static GEN_AI_AGENT_DESCRIPTION = 'gen_ai.agent.description';
static GEN_AI_AGENT_VERSION = 'gen_ai.agent.version';
+ static GEN_AI_AGENT_SOURCE = 'gen_ai.agent.source';
+ static GEN_AI_AGENT_ACTION_TOOL = 'gen_ai.agent.action.tool';
+ static GEN_AI_AGENT_ACTION_TOOL_INPUT = 'gen_ai.agent.action.tool_input';
+ static GEN_AI_AGENT_ACTION_LOG = 'gen_ai.agent.action.log';
+ static GEN_AI_AGENT_FINISH_OUTPUT = 'gen_ai.agent.finish.output';
+ static GEN_AI_AGENT_FINISH_LOG = 'gen_ai.agent.finish.log';
// Workflow / framework
static GEN_AI_WORKFLOW_INPUT = 'gen_ai.workflow.input';
@@ -196,7 +206,7 @@ export default class SemanticConvention {
static GEN_AI_SYSTEM_HUGGING_FACE = 'huggingface';
static GEN_AI_SYSTEM_REPLICATE = 'replicate';
static GEN_AI_SYSTEM_OPENAI = 'openai';
- static GEN_AI_SYSTEM_AZURE_OPENAI = 'az.ai.openai';
+ static GEN_AI_SYSTEM_AZURE_OPENAI = 'azure.ai.openai';
static GEN_AI_SYSTEM_ANTHROPIC = 'anthropic';
static GEN_AI_SYSTEM_COHERE = 'cohere';
static GEN_AI_SYSTEM_MISTRAL = 'mistral_ai';
@@ -204,7 +214,34 @@ export default class SemanticConvention {
static GEN_AI_SYSTEM_VERTEXAI = 'vertex_ai';
static GEN_AI_SYSTEM_LANGCHAIN = 'langchain';
static GEN_AI_SYSTEM_VERCEL_AI = 'vercel_ai';
+ static GEN_AI_SYSTEM_OLLAMA = 'ollama';
+ static GEN_AI_SYSTEM_GOOGLE_AI_STUDIO = 'gcp.gemini';
+ static GEN_AI_SYSTEM_GROQ = 'groq';
+ static GEN_AI_SYSTEM_AZURE_AI_INFERENCE = 'azure.ai.inference';
static GEN_AI_SYSTEM_LLAMAINDEX = 'llamaindex';
+ static GEN_AI_SYSTEM_TOGETHER = 'together';
+ static GEN_AI_SYSTEM_LANGGRAPH = 'langgraph';
+ static GEN_AI_SYSTEM_OPENAI_AGENTS = 'openai_agents';
+ static GEN_AI_SYSTEM_MASTRA = 'mastra';
+ static GEN_AI_SYSTEM_CLAUDE_AGENT_SDK = 'claude_agent_sdk';
+ static GEN_AI_SYSTEM_GOOGLE_ADK = 'google_adk';
+ static GEN_AI_SYSTEM_STRANDS = 'strands_agents';
+
+ static GEN_AI_OPERATION_TYPE_CREATE_AGENT = 'create_agent';
+
+ // Graph attributes (LangGraph)
+ static GEN_AI_GRAPH_NODES = 'gen_ai.graph.nodes';
+ static GEN_AI_GRAPH_NODE_COUNT = 'gen_ai.graph.node_count';
+ static GEN_AI_GRAPH_EDGES = 'gen_ai.graph.edges';
+ static GEN_AI_GRAPH_EDGE_COUNT = 'gen_ai.graph.edge_count';
+ static GEN_AI_GRAPH_EXECUTED_NODES = 'gen_ai.graph.executed_nodes';
+ static GEN_AI_GRAPH_STATUS = 'gen_ai.graph.status';
+ static GEN_AI_GRAPH_MESSAGE_COUNT = 'gen_ai.graph.message_count';
+ static GEN_AI_GRAPH_TOTAL_CHUNKS = 'gen_ai.graph.total_chunks';
+
+ // Execution attributes (LangGraph)
+ static GEN_AI_EXECUTION_MODE = 'gen_ai.execution.mode';
+ static GEN_AI_CHECKPOINT_ID = 'gen_ai.checkpoint.id';
// Vector DB
static DB_REQUESTS = 'db.total.requests';
diff --git a/sdk/typescript/src/types.ts b/sdk/typescript/src/types.ts
index e683f696..a74caafd 100644
--- a/sdk/typescript/src/types.ts
+++ b/sdk/typescript/src/types.ts
@@ -1,23 +1,15 @@
-// import { Instrumentation } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { metrics } from '@opentelemetry/api';
-export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'together' | 'ollama' | 'vercel-ai' | 'langchain' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus';
+export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'together' | 'ollama' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk';
export type OpenlitInstrumentations = Partial<Record<InstrumentationType, any>>;
export type PricingObject = Record<string, Record<string, unknown>>;
/**
- * environment (string): Deployment environment of the application.
- * applicationName (string): Name of the application using openLIT.
- * pricingInfo (Object): Pricing information.
- * tracer (any): Tracer instance for OpenTelemetry.
- * otlpEndpoint (string): Endpoint for OTLP.
- * otlpHeaders (Object): Headers for OTLP.
- * disableBatch (boolean): Flag to disable batch span processing in tracing.
- * traceContent (boolean): Flag to enable or disable tracing of content.
+ * Internal config interface used by OpenlitConfig.
*/
export interface OpenlitConfigInterface {
environment?: string;
@@ -27,24 +19,69 @@ export interface OpenlitConfigInterface {
otlpEndpoint?: string;
otlpHeaders?: Record<string, unknown>;
disableBatch?: boolean;
- traceContent?: boolean;
- pricing_json?: string | PricingObject;
+ captureMessageContent?: boolean;
+ pricingJson?: string | PricingObject;
+ disableMetrics?: boolean;
+ disableEvents?: boolean;
+ maxContentLength?: number | null;
+ customSpanAttributes?: Record<string, string> | null;
}
+/**
+ * Public init() options.
+ *
+ * Names match the Python SDK's init() parameters in camelCase form:
+ * Python: application_name → JS: applicationName
+ * Python: otlp_endpoint → JS: otlpEndpoint
+ * Python: otlp_headers → JS: otlpHeaders
+ * Python: disable_batch → JS: disableBatch
+ * Python: capture_message_content → JS: captureMessageContent
+ * Python: disabled_instrumentors → JS: disabledInstrumentors
+ * Python: disable_metrics → JS: disableMetrics
+ * Python: disable_events → JS: disableEvents
+ * Python: pricing_json → JS: pricingJson
+ * Python: max_content_length → JS: maxContentLength
+ * Python: custom_span_attributes → JS: customSpanAttributes
+ */
export type OpenlitOptions = {
- environment?: OpenlitConfigInterface['environment'];
- applicationName?: OpenlitConfigInterface['applicationName'];
- tracer?: OpenlitConfigInterface['tracer'];
- otlpEndpoint?: OpenlitConfigInterface['otlpEndpoint'];
- otlpHeaders?: OpenlitConfigInterface['otlpHeaders'];
- disableBatch?: OpenlitConfigInterface['disableBatch'];
- traceContent?: OpenlitConfigInterface['traceContent'];
- disabledInstrumentations?: string[];
+ environment?: string;
+ applicationName?: string;
+ tracer?: NodeTracerProvider;
+ otlpEndpoint?: string;
+ otlpHeaders?: Record<string, unknown>;
+ disableBatch?: boolean;
+ captureMessageContent?: boolean;
+ disabledInstrumentors?: string[];
instrumentations?: OpenlitInstrumentations;
- pricing_json?: OpenlitConfigInterface['pricing_json'];
+ disableMetrics?: boolean;
+ disableEvents?: boolean;
+ pricingJson?: string | PricingObject;
+ maxContentLength?: number | null;
+ customSpanAttributes?: Record<string, string> | null;
+
};
-export type SetupTracerOptions = OpenlitOptions & {
+/**
+ * Resolved options used internally after merging args, env vars, and defaults.
+ */
+export interface ResolvedOptions {
+ environment: string;
+ applicationName: string;
+ tracer?: NodeTracerProvider;
+ otlpEndpoint?: string;
+ otlpHeaders?: Record<string, unknown>;
+ disableBatch: boolean;
+ captureMessageContent: boolean;
+ disabledInstrumentors?: string[];
+ instrumentations?: OpenlitInstrumentations;
+ disableMetrics: boolean;
+ disableEvents: boolean;
+ pricingJson?: string | PricingObject;
+ maxContentLength?: number | null;
+ customSpanAttributes?: Record<string, string> | null;
+}
+
+export type SetupTracerOptions = ResolvedOptions & {
resource: Resource;
};
@@ -53,9 +90,10 @@ export type MeterType = ReturnType<typeof metrics.getMeter>;
export type SetupMetricsOptions = SetupTracerOptions & {
meter?: MeterType;
exportIntervalMillis?: number;
- allowConsoleExporterFallback?: boolean;
};
+export type SetupEventsOptions = SetupTracerOptions;
+
export interface BaseOpenlitOptions {
url?: string;
apiKey?: string;
diff --git a/sdk/typescript/tsconfig.tsbuildinfo b/sdk/typescript/tsconfig.tsbuildinfo
index 0ab6ed92..97e8c297 100644
--- a/sdk/typescript/tsconfig.tsbuildinfo
+++ b/sdk/typescript/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/config.ts","./src/constant.ts","./src/helpers.ts","./src/index.ts","./src/prompt-hub.ts","./src/semantic-convention.ts","./src/types.ts","./src/evals/all.ts","./src/evals/base.ts","./src/evals/bias.ts","./src/evals/hallucination.ts","./src/evals/index.ts","./src/evals/metrics.ts","./src/evals/toxicity.ts","./src/evals/types.ts","./src/evals/utils.ts","./src/evals/__tests__/anthropic.test.ts","./src/evals/__tests__/base.test.ts","./src/evals/__tests__/core.test.ts","./src/evals/__tests__/metrics.test.ts","./src/evals/__tests__/openai.test.ts","./src/evals/__tests__/providers.test.ts","./src/evals/__tests__/utils.test.ts","./src/evals/llm/anthropic.ts","./src/evals/llm/openai.ts","./src/evals/llm/providers.ts","./src/features/base.ts","./src/features/prompt-hub.ts","./src/features/vault.ts","./src/guard/all.ts","./src/guard/base.ts","./src/guard/index.ts","./src/guard/prompt-injection.ts","./src/guard/sensitive-topic.ts","./src/guard/topic-restriction.ts","./src/guard/types.ts","./src/guard/utils.ts","./src/guard/__tests__/gaurd.test.ts","./src/guard/__tests__/utils.test.ts","./src/instrumentation/base-wrapper.ts","./src/instrumentation/index.ts","./src/instrumentation/__tests__/anthropic-wrapper.test.ts","./src/instrumentation/__tests__/base-wrapper.test.ts","./src/instrumentation/__tests__/chroma-trace-comparison.test.ts","./src/instrumentation/__tests__/cohere-wrapper.test.ts","./src/instrumentation/__tests__/google-ai-trace-comparison.test.ts","./src/instrumentation/__tests__/groq-trace-comparison.test.ts","./src/instrumentation/__tests__/huggingface-trace-comparison.test.ts","./src/instrumentation/__tests__/milvus-trace-comparison.test.ts","./src/instrumentation/__tests__/mistral-trace-comparison.test.ts","./src/instrumentation/__tests__/openai-wrapper.test.ts","./src/instrumentation/__tests__/qdrant-trace-comparison.test.ts","./src/instrumentation/__tests__/replicate-trace-comparison.test.ts","./src/instrumentation/__tests__/together-trace-comparison.test.ts","./src/instrumentation/__tests__/trace-comparison-utils.ts","./src/instrumentation/anthropic/index.ts","./src/instrumentation/anthropic/wrapper.ts","./src/instrumentation/bedrock/index.ts","./src/instrumentation/bedrock/wrapper.ts","./src/instrumentation/chroma/index.ts","./src/instrumentation/chroma/wrapper.ts","./src/instrumentation/cohere/index.ts","./src/instrumentation/cohere/wrapper.ts","./src/instrumentation/google-ai/index.ts","./src/instrumentation/google-ai/wrapper.ts","./src/instrumentation/groq/index.ts","./src/instrumentation/groq/wrapper.ts","./src/instrumentation/huggingface/index.ts","./src/instrumentation/huggingface/wrapper.ts","./src/instrumentation/langchain/index.ts","./src/instrumentation/langchain/wrapper.ts","./src/instrumentation/llamaindex/index.ts","./src/instrumentation/llamaindex/wrapper.ts","./src/instrumentation/milvus/index.ts","./src/instrumentation/milvus/wrapper.ts","./src/instrumentation/mistral/index.ts","./src/instrumentation/mistral/wrapper.ts","./src/instrumentation/ollama/index.ts","./src/instrumentation/ollama/wrapper.ts","./src/instrumentation/openai/index.ts","./src/instrumentation/openai/wrapper.ts","./src/instrumentation/pinecone/index.ts","./src/instrumentation/pinecone/wrapper.ts","./src/instrumentation/qdrant/index.ts","./src/instrumentation/qdrant/wrapper.ts","./src/instrumentation/replicate/index.ts","./src/instrumentation/replicate/wrapper.ts","./src/instrumentation/together/index.ts","./src/instrumentation/together/wrapper.ts","./src/instrumentation/vercel-ai/index.ts","./src/instrumentation/vercel-ai/wrapper.ts","./src/llm/anthropic.ts","./src/llm/index.ts","./src/llm/openai.ts","./src/llm/providers.ts","./src/otel/metrics.ts","./src/otel/tracing.ts","./src/otel/__tests__/metrics.test.ts"],"version":"5.8.3"}
\ No newline at end of file
+{"root":["./src/config.ts","./src/constant.ts","./src/helpers.ts","./src/index.ts","./src/prompt-hub.ts","./src/semantic-convention.ts","./src/types.ts","./src/evals/all.ts","./src/evals/base.ts","./src/evals/bias.ts","./src/evals/hallucination.ts","./src/evals/index.ts","./src/evals/metrics.ts","./src/evals/toxicity.ts","./src/evals/types.ts","./src/evals/utils.ts","./src/evals/__tests__/anthropic.test.ts","./src/evals/__tests__/base.test.ts","./src/evals/__tests__/core.test.ts","./src/evals/__tests__/metrics.test.ts","./src/evals/__tests__/openai.test.ts","./src/evals/__tests__/providers.test.ts","./src/evals/__tests__/utils.test.ts","./src/evals/llm/anthropic.ts","./src/evals/llm/openai.ts","./src/evals/llm/providers.ts","./src/features/base.ts","./src/features/prompt-hub.ts","./src/features/rule-engine.ts","./src/features/vault.ts","./src/features/__tests__/rule-engine.test.ts","./src/guard/all.ts","./src/guard/base.ts","./src/guard/index.ts","./src/guard/prompt-injection.ts","./src/guard/sensitive-topic.ts","./src/guard/topic-restriction.ts","./src/guard/types.ts","./src/guard/utils.ts","./src/guard/__tests__/gaurd.test.ts","./src/guard/__tests__/utils.test.ts","./src/instrumentation/base-wrapper.ts","./src/instrumentation/index.ts","./src/instrumentation/__tests__/anthropic-wrapper.test.ts","./src/instrumentation/__tests__/base-wrapper.test.ts","./src/instrumentation/__tests__/bedrock-trace-comparison.test.ts","./src/instrumentation/__tests__/chroma-trace-comparison.test.ts","./src/instrumentation/__tests__/cohere-wrapper.test.ts","./src/instrumentation/__tests__/google-ai-trace-comparison.test.ts","./src/instrumentation/__tests__/groq-trace-comparison.test.ts","./src/instrumentation/__tests__/huggingface-trace-comparison.test.ts","./src/instrumentation/__tests__/langchain-wrapper.test.ts","./src/instrumentation/__tests__/milvus-trace-comparison.test.ts","./src/instrumentation/__tests__/mistral-trace-comparison.test.ts","./src/instrumentation/__tests__/openai-wrapper.test.ts","./src/instrumentation/__tests__/qdrant-trace-comparison.test.ts","./src/instrumentation/__tests__/replicate-trace-comparison.test.ts","./src/instrumentation/__tests__/together-trace-comparison.test.ts","./src/instrumentation/__tests__/trace-comparison-utils.ts","./src/instrumentation/__tests__/vercel-ai-trace-comparison.test.ts","./src/instrumentation/anthropic/index.ts","./src/instrumentation/anthropic/wrapper.ts","./src/instrumentation/azure-ai-inference/index.ts","./src/instrumentation/azure-ai-inference/wrapper.ts","./src/instrumentation/bedrock/index.ts","./src/instrumentation/bedrock/wrapper.ts","./src/instrumentation/chroma/index.ts","./src/instrumentation/chroma/wrapper.ts","./src/instrumentation/claude-agent-sdk/index.ts","./src/instrumentation/claude-agent-sdk/wrapper.ts","./src/instrumentation/cohere/index.ts","./src/instrumentation/cohere/wrapper.ts","./src/instrumentation/google-adk/index.ts","./src/instrumentation/google-adk/utils.ts","./src/instrumentation/google-adk/wrapper.ts","./src/instrumentation/google-ai/index.ts","./src/instrumentation/google-ai/wrapper.ts","./src/instrumentation/groq/index.ts","./src/instrumentation/groq/wrapper.ts","./src/instrumentation/huggingface/index.ts","./src/instrumentation/huggingface/wrapper.ts","./src/instrumentation/langchain/index.ts","./src/instrumentation/langchain/wrapper.ts","./src/instrumentation/langgraph/index.ts","./src/instrumentation/langgraph/wrapper.ts","./src/instrumentation/llamaindex/index.ts","./src/instrumentation/llamaindex/wrapper.ts","./src/instrumentation/milvus/index.ts","./src/instrumentation/milvus/wrapper.ts","./src/instrumentation/mistral/index.ts","./src/instrumentation/mistral/wrapper.ts","./src/instrumentation/ollama/index.ts","./src/instrumentation/ollama/wrapper.ts","./src/instrumentation/openai/index.ts","./src/instrumentation/openai/wrapper.ts","./src/instrumentation/openai-agents/index.ts","./src/instrumentation/openai-agents/processor.ts","./src/instrumentation/openai-agents/utils.ts","./src/instrumentation/pinecone/index.ts","./src/instrumentation/pinecone/wrapper.ts","./src/instrumentation/qdrant/index.ts","./src/instrumentation/qdrant/wrapper.ts","./src/instrumentation/replicate/index.ts","./src/instrumentation/replicate/wrapper.ts","./src/instrumentation/strands/index.ts","./src/instrumentation/strands/processor.ts","./src/instrumentation/strands/utils.ts","./src/instrumentation/together/index.ts","./src/instrumentation/together/wrapper.ts","./src/instrumentation/vercel-ai/index.ts","./src/instrumentation/vercel-ai/wrapper.ts","./src/llm/anthropic.ts","./src/llm/index.ts","./src/llm/openai.ts","./src/llm/providers.ts","./src/otel/events.ts","./src/otel/metrics.ts","./src/otel/tracing.ts","./src/otel/utils.ts","./src/otel/__tests__/metrics.test.ts"],"version":"5.8.3"}
\ No newline at end of file