Skip to content

feat(core): Instrument langgraph createReactAgent#18403

Open
nicohrubec wants to merge 37 commits intodevelopfrom
nh/langgraph-no-invoke-agent
Open

feat(core): Instrument langgraph createReactAgent#18403
nicohrubec wants to merge 37 commits intodevelopfrom
nh/langgraph-no-invoke-agent

Conversation

@nicohrubec
Copy link
Member

@nicohrubec nicohrubec commented Dec 4, 2025

This PR instruments langgraph createReactAgent. This is only relevant for pre v1 langgraph. Starting from v >1.0.0 createReactAgent is replaced with create_agent, which is exported from langchain. The model is now also extracted and send along in the span. Getting this to run required some changes to opentelemetry and IITM to allow for instrumentation of submodule exports (that's why there are a bunch of version bumps in here as well).

Closes #19372 (added automatically)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.56 kB - -
@sentry/browser - with treeshaking flags 24.08 kB - -
@sentry/browser (incl. Tracing) 42.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.03 kB - -
@sentry/browser (incl. Tracing, Replay) 81.18 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.8 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.87 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.03 kB - -
@sentry/browser (incl. Feedback) 42.29 kB - -
@sentry/browser (incl. sendFeedback) 30.23 kB - -
@sentry/browser (incl. FeedbackAsync) 35.22 kB - -
@sentry/browser (incl. Metrics) 26.74 kB - -
@sentry/browser (incl. Logs) 26.88 kB - -
@sentry/browser (incl. Metrics & Logs) 27.56 kB - -
@sentry/react 27.33 kB - -
@sentry/react (incl. Tracing) 44.72 kB - -
@sentry/vue 30.01 kB - -
@sentry/vue (incl. Tracing) 44.22 kB - -
@sentry/svelte 25.58 kB - -
CDN Bundle 28.11 kB - -
CDN Bundle (incl. Tracing) 43.2 kB - -
CDN Bundle (incl. Logs, Metrics) 28.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.02 kB - -
CDN Bundle (incl. Tracing, Replay) 80.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.4 kB - -
CDN Bundle - uncompressed 82.22 kB - -
CDN Bundle (incl. Tracing) - uncompressed 127.93 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.81 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.42 kB - -
@sentry/nextjs (client) 47.07 kB - -
@sentry/sveltekit (client) 42.81 kB - -
@sentry/node-core 52.15 kB +0.02% +10 B 🔺
⛔️ @sentry/node (max: 167 kB) 171.26 kB +2.85% +4.75 kB 🔺
⛔️ @sentry/node - without tracing (max: 95 kB) 97.19 kB +3.46% +3.25 kB 🔺
⛔️ @sentry/aws-serverless (max: 111 kB) 114.22 kB +4.37% +4.77 kB 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,949 - 9,044 -1%
GET With Sentry 1,658 19% 1,596 +4%
GET With Sentry (error only) 6,044 68% 6,140 -2%
POST Baseline 1,185 - 1,189 -0%
POST With Sentry 591 50% 592 -0%
POST With Sentry (error only) 1,057 89% 1,058 -0%
MYSQL Baseline 3,258 - 3,237 +1%
MYSQL With Sentry 484 15% 416 +16%
MYSQL With Sentry (error only) 2,653 81% 2,643 +0%

View base workflow run

@nicohrubec nicohrubec self-assigned this Dec 10, 2025
@nicohrubec nicohrubec changed the title fix(core): Instrument langgraph createReactAgent feat(core): Instrument langgraph createReactAgent Dec 17, 2025
nicohrubec added a commit that referenced this pull request Dec 23, 2025
IITM has a new patch release with a fix that we need to properly
instrument submodule imports in our Otel integrations (for instance to
make [this](#18403)
work).

Closes #18613
@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

Codecov Results 📊


Generated by Codecov Action

@isaacs isaacs force-pushed the nh/langgraph-no-invoke-agent branch from 6ff8d6d to df9c9d2 Compare February 16, 2026 21:04
@nicohrubec nicohrubec marked this pull request as ready for review February 18, 2026 09:47
@nicohrubec
Copy link
Member Author

@RulaKhaled This should finally work now, not sure about bundle size increase but this is probably a result of the opentelemetry bumps

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

handled: false,
type: 'auto.ai.langgraph.error',
},
});
Copy link

Choose a reason for hiding this comment

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

Mechanism type doesn't align with span origin

Low Severity

In the new instrumentCreateReactAgent function, the mechanism.type is set to 'auto.ai.langgraph.error', which doesn't align with the SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN value of 'auto.ai.langgraph'. Other AI integrations (Anthropic uses 'auto.ai.anthropic', Google GenAI uses 'auto.ai.google_genai') set the mechanism type to match the origin exactly. The .error suffix deviates from that convention. This also applies to the pre-existing instances at lines 77 and 177, but since this is new code, it's a good opportunity to align with the convention.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

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.

feat(core): Instrument langgraph createReactAgent

2 participants