File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
packages/node/src/integrations/tracing/langgraph Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export class SentryLangGraphInstrumentation extends InstrumentationBase<LangGrap
7171 * Core patch logic applying instrumentation to the LangGraph module.
7272 */
7373 private _patch ( exports : PatchedModuleExports ) : PatchedModuleExports | void {
74+ console . log ( 'patching LangGraph module' ) ;
7475 const client = getClient ( ) ;
7576 const defaultPii = Boolean ( client ?. getOptions ( ) . sendDefaultPii ) ;
7677
@@ -96,16 +97,18 @@ export class SentryLangGraphInstrumentation extends InstrumentationBase<LangGrap
9697 }
9798
9899 // Patch createReactAgent to instrument the agent creation and invocation
99- const originalCreateReactAgent = exports . createReactAgent ;
100- Object . defineProperty ( exports , 'createReactAgent' , {
101- value : instrumentCreateReactAgent (
102- originalCreateReactAgent as ( ...args : unknown [ ] ) => CompiledGraph ,
103- options ,
104- ) ,
105- writable : true ,
106- enumerable : true ,
107- configurable : true ,
108- } ) ;
100+ if ( exports . createReactAgent && typeof exports . createReactAgent === 'function' ) {
101+ const originalCreateReactAgent = exports . createReactAgent ;
102+ Object . defineProperty ( exports , 'createReactAgent' , {
103+ value : instrumentCreateReactAgent (
104+ originalCreateReactAgent as ( ...args : unknown [ ] ) => CompiledGraph ,
105+ options ,
106+ ) ,
107+ writable : true ,
108+ enumerable : true ,
109+ configurable : true ,
110+ } ) ;
111+ }
109112
110113 return exports ;
111114 }
You can’t perform that action at this time.
0 commit comments