Skip to content

Commit 9c9ffae

Browse files
committed
fix: re-enable otel tracing for agents
1 parent 5104fb8 commit 9c9ffae

File tree

5 files changed

+165
-8
lines changed

5 files changed

+165
-8
lines changed

package-lock.json

Lines changed: 157 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/agent-api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"author": "Microsoft",
1717
"license": "MIT",
1818
"dependencies": {
19+
"@arizeai/openinference-instrumentation-langchain": "^4.0.0",
1920
"@azure/cosmos": "^4.6.0",
2021
"@azure/functions": "^4.0.0",
2122
"@azure/identity": "^4.2.0",

packages/agent-api/src/functions/chats-post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createAgent, AIMessage, HumanMessage } from 'langchain';
55
import { ChatOpenAI } from '@langchain/openai';
66
import { AzureCosmsosDBNoSQLChatMessageHistory } from '@langchain/azure-cosmosdb';
77
import { loadMcpTools } from '@langchain/mcp-adapters';
8-
import { StreamEvent } from '@langchain/core/dist/tracers/log_stream.js';
8+
import { StreamEvent } from '@langchain/core/tracers/log_stream';
99
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
1010
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
1111
import { getAzureOpenAiTokenProvider, getCredentials, getInternalUserId } from '../auth.js';

packages/agent-api/src/tracing.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { useAzureMonitor } from '@azure/monitor-opentelemetry';
66
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
77
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
88
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
9-
// import { LangChainInstrumentation } from '@arizeai/openinference-instrumentation-langchain';
10-
// import * as CallbackManagerModule from 'langchain';
9+
import { LangChainInstrumentation } from '@arizeai/openinference-instrumentation-langchain';
10+
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";
1111

1212
let isTracingInitialized = false;
1313
if (!isTracingInitialized) {
@@ -35,9 +35,8 @@ if (!isTracingInitialized) {
3535
}
3636

3737
// Manually instrument LangChain's CallbackManager to capture traces
38-
// TODO: temporarily disabled due to compatibility issues with LangChain v1 (PR in progress)
39-
// const langchainInstrumentation = new LangChainInstrumentation();
40-
// langchainInstrumentation.manuallyInstrument(CallbackManagerModule);
38+
const langchainInstrumentation = new LangChainInstrumentation();
39+
langchainInstrumentation.manuallyInstrument(CallbackManagerModule);
4140

4241
isTracingInitialized = true;
4342
}

packages/agent-api/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "CommonJS",
3+
"module": "nodenext",
44
"target": "ESNext",
55
"incremental": true,
66
"composite": true,
@@ -14,7 +14,7 @@
1414
"noUnusedParameters": true,
1515
"noImplicitReturns": true,
1616
"noImplicitOverride": true,
17-
"moduleResolution": "node",
17+
"moduleResolution": "nodenext",
1818
"esModuleInterop": true,
1919
"lib": ["ESNext"]
2020
},

0 commit comments

Comments
 (0)