Skip to content

feat(cloudflare/vercel-edge): Add manual instrumentation for LangGraph - #18112

Merged
RulaKhaled merged 2 commits into
developfrom
support-cloudflare-and-vercel-edge
Nov 19, 2025
Merged

RulaKhaled merged 2 commits into
developfrom
support-cloudflare-and-vercel-edge

Conversation

@RulaKhaled

@RulaKhaled RulaKhaled commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

This PR adds manual instrumentation support for LangGraph StateGraph operations in Cloudflare Workers and Vercel Edge environments.

import * as Sentry from '@sentry/cloudflare'; // or '@sentry/vercel-edge'
import { StateGraph, START, END, MessagesAnnotation } from '@langchain/langgraph';

// Create and instrument the graph
const graph = new StateGraph(MessagesAnnotation)
  .addNode('agent', agentFn)
  .addEdge(START, 'agent')
  .addEdge('agent', END);

Sentry.instrumentLangGraph(graph, {
  recordInputs: true,
  recordOutputs: true,
});

const compiled = graph.compile({ name: 'weather_assistant' });

await compiled.invoke({
  messages: [{ role: 'user', content: 'What is the weather in SF?' }],
});

@RulaKhaled
RulaKhaled force-pushed the support-cloudflare-and-vercel-edge branch from 8637cdc to 936427e Compare November 6, 2025 18:38
@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.62 kB - -
@sentry/browser - with treeshaking flags 23.13 kB - -
@sentry/browser (incl. Tracing) 41.28 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.61 kB - -
@sentry/browser (incl. Tracing, Replay) 79.73 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.44 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.43 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.64 kB - -
@sentry/browser (incl. Feedback) 41.29 kB - -
@sentry/browser (incl. sendFeedback) 29.29 kB - -
@sentry/browser (incl. FeedbackAsync) 34.21 kB - -
@sentry/react 26.32 kB - -
@sentry/react (incl. Tracing) 43.22 kB - -
@sentry/vue 29.11 kB - -
@sentry/vue (incl. Tracing) 43.08 kB - -
@sentry/svelte 24.64 kB - -
CDN Bundle 26.94 kB - -
CDN Bundle (incl. Tracing) 41.83 kB - -
CDN Bundle (incl. Tracing, Replay) 78.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.85 kB - -
CDN Bundle - uncompressed 78.92 kB - -
CDN Bundle (incl. Tracing) - uncompressed 124.07 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.1 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 252.87 kB - -
@sentry/nextjs (client) 45.37 kB - -
@sentry/sveltekit (client) 41.67 kB - -
@sentry/node-core 50.91 kB - -
@sentry/node 159.09 kB - -
@sentry/node - without tracing 92.78 kB +0.01% +1 B 🔺
@sentry/aws-serverless 106.53 kB -0.01% -2 B 🔽

View base workflow run

@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

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,808 - 9,158 -4%
GET With Sentry 1,377 16% 1,276 +8%
GET With Sentry (error only) 6,170 70% 5,987 +3%
POST Baseline 1,179 - 1,166 +1%
POST With Sentry 465 39% 502 -7%
POST With Sentry (error only) 1,059 90% 1,041 +2%
MYSQL Baseline 3,317 - 3,304 +0%
MYSQL With Sentry 429 13% 425 +1%
MYSQL With Sentry (error only) 2,737 83% 2,662 +3%

View base workflow run

@RulaKhaled
RulaKhaled force-pushed the support-cloudflare-and-vercel-edge branch from 337b60c to 17b303d Compare November 17, 2025 10:31
@RulaKhaled
RulaKhaled force-pushed the support-cloudflare-and-vercel-edge branch from 17b303d to b88aa39 Compare November 17, 2025 11:47
@RulaKhaled
RulaKhaled marked this pull request as ready for review November 18, 2025 09:36
Comment thread packages/core/src/tracing/langgraph/index.ts

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@RulaKhaled
RulaKhaled merged commit 584d4bc into develop Nov 19, 2025
380 of 383 checks passed
@RulaKhaled
RulaKhaled deleted the support-cloudflare-and-vercel-edge branch November 19, 2025 09:00
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