Skip to content

fix(langgraph): Call instrumentLangGraph before .compile()#16611

Open
priscilawebdev wants to merge 3 commits intomasterfrom
fix/langgraph-instrument-before-compile
Open

fix(langgraph): Call instrumentLangGraph before .compile()#16611
priscilawebdev wants to merge 3 commits intomasterfrom
fix/langgraph-instrument-before-compile

Conversation

@priscilawebdev
Copy link
Member

DESCRIBE YOUR PR

Fix the instrumentLangGraph example in the Browser-Side Usage section to call the helper before .compile(), not after.

instrumentLangGraph works by wrapping the .compile() method on a StateGraph to intercept the compilation step and inject tracing. It must be called before .compile() is invoked. The previous example passed the already-compiled graph, meaning the compile step had already happened and there was no hook point for the SDK to instrument.

Also updates the surrounding description from "wrapping a compiled LangGraph graph" to "wrapping a StateGraph before compilation" to match the correct usage.

Related fix in the sentry repo: getsentry/sentry#109551

IS YOUR CHANGE URGENT?

  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

Co-Authored-By: Claude noreply@anthropic.com

instrumentLangGraph works by wrapping the .compile() method on a
StateGraph to intercept the compilation step and inject tracing.
It must be called before .compile() is invoked.

The previous example called instrumentLangGraph on the already-compiled
graph — by that point the compile step has already happened, so there
is no hook point for the SDK to instrument.

Also update the surrounding description to reflect that the helper
wraps a StateGraph before compilation, not a compiled graph.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment Feb 27, 2026 1:11pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview Feb 27, 2026 1:11pm

Request Review

The alert box incorrectly said "wrap your compiled graph", implying
instrumentLangGraph should be called post-compilation. It must be
called on the StateGraph before .compile(), as stated elsewhere in
the doc and shown in the code examples.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants