File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed
dev-packages/node-integration-tests/suites/tracing/langgraph
core/src/tracing/langgraph
node/src/integrations/tracing/langgraph Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 11import { ChatAnthropic } from '@langchain/anthropic' ;
2- import { createReactAgent } from '@langchain/langgraph/prebuilt' ;
32import { HumanMessage , SystemMessage } from '@langchain/core/messages' ;
3+ import { createReactAgent } from '@langchain/langgraph/prebuilt' ;
44import * as Sentry from '@sentry/node' ;
55import express from 'express' ;
66
@@ -58,10 +58,7 @@ async function run() {
5858
5959 // Test: basic invocation
6060 await agent . invoke ( {
61- messages : [
62- new SystemMessage ( 'You are a helpful assistant.' ) ,
63- new HumanMessage ( 'What is the weather today?' ) ,
64- ] ,
61+ messages : [ new SystemMessage ( 'You are a helpful assistant.' ) , new HumanMessage ( 'What is the weather today?' ) ] ,
6562 } ) ;
6663 } ) ;
6764
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ export function instrumentCreateReactAgent(
177177 [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] : 'create_agent' ,
178178 } ,
179179 } ,
180- ( ) => {
180+ span => {
181181 try {
182182 const compiledGraph = Reflect . apply ( target , thisArg , args ) ;
183183 const compiledOptions = args . length > 0 ? ( args [ 0 ] as Record < string , unknown > ) : { } ;
@@ -193,6 +193,13 @@ export function instrumentCreateReactAgent(
193193
194194 return compiledGraph ;
195195 } catch ( error ) {
196+ span . setStatus ( { code : SPAN_STATUS_ERROR , message : 'internal_error' } ) ;
197+ captureException ( error , {
198+ mechanism : {
199+ handled : false ,
200+ type : 'auto.ai.langgraph.error' ,
201+ } ,
202+ } ) ;
196203 throw error ;
197204 }
198205 } ,
Original file line number Diff line number Diff line change @@ -110,10 +110,7 @@ export class SentryLangGraphInstrumentation extends InstrumentationBase<LangGrap
110110 if ( exports . createReactAgent && typeof exports . createReactAgent === 'function' ) {
111111 const originalCreateReactAgent = exports . createReactAgent ;
112112 Object . defineProperty ( exports , 'createReactAgent' , {
113- value : instrumentCreateReactAgent (
114- originalCreateReactAgent as ( ...args : unknown [ ] ) => CompiledGraph ,
115- options ,
116- ) ,
113+ value : instrumentCreateReactAgent ( originalCreateReactAgent as ( ...args : unknown [ ] ) => CompiledGraph , options ) ,
117114 writable : true ,
118115 enumerable : true ,
119116 configurable : true ,
You can’t perform that action at this time.
0 commit comments