Skip to content

Conversation

@RulaKhaled
Copy link
Member

This PR adds official support for instrumenting LangGraph StateGraph operations in Node with Sentry tracing, following OpenTelemetry semantic conventions for Generative AI.

Currently supported:

Node.js - Both agent creation and invocation are instrumented in this PR
ESM and CJS - Both module systems are supported

The langgraphIntegration() accepts the following options:

// The integration respects your sendDefaultPii client option
interface LangGraphOptions {
  recordInputs?: boolean;   // Whether to record input messages
  recordOutputs?: boolean;  // Whether to record response text and tool calls
}

e.g

Sentry.init({
  dsn: '__DSN__',
  sendDefaultPii: false, // Even with PII disabled globally
  integrations: [
    Sentry.langgraphIntegration({
      recordInputs: true,    // Force recording input messages
      recordOutputs: true,   // Force recording response text
    }),
  ],
});

Operations traced:

  • gen_ai.create_agent - Spans created when StateGraph.compile() is called
  • gen_ai.invoke_agent - Spans created when CompiledGraph.invoke() is called

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.59 kB - -
@sentry/browser - with treeshaking flags 23.08 kB - -
@sentry/browser (incl. Tracing) 41.22 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.5 kB - -
@sentry/browser (incl. Tracing, Replay) 79.7 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.37 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.39 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.57 kB - -
@sentry/browser (incl. Feedback) 41.27 kB - -
@sentry/browser (incl. sendFeedback) 29.26 kB - -
@sentry/browser (incl. FeedbackAsync) 34.19 kB - -
@sentry/react 26.29 kB - -
@sentry/react (incl. Tracing) 43.21 kB - -
@sentry/vue 29.07 kB - -
@sentry/vue (incl. Tracing) 42.99 kB - -
@sentry/svelte 24.61 kB - -
CDN Bundle 26.89 kB - -
CDN Bundle (incl. Tracing) 41.77 kB - -
CDN Bundle (incl. Tracing, Replay) 78.3 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.77 kB - -
CDN Bundle - uncompressed 78.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.97 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 240 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 252.76 kB - -
@sentry/nextjs (client) 45.31 kB - -
@sentry/sveltekit (client) 41.61 kB - -
@sentry/node-core 50.76 kB - -
@sentry/node 158.7 kB +0.56% +879 B 🔺
@sentry/node - without tracing 92.64 kB - -
@sentry/aws-serverless 106.36 kB -0.01% -1 B 🔽

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 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,982 - 11,390 -21%
GET With Sentry 1,327 15% 1,586 -16%
GET With Sentry (error only) 6,003 67% 7,742 -22%
POST Baseline 1,221 - 1,114 +10%
POST With Sentry 508 42% 543 -6%
POST With Sentry (error only) 1,063 87% 1,022 +4%
MYSQL Baseline 3,264 - 3,990 -18%
MYSQL With Sentry 415 13% 524 -21%
MYSQL With Sentry (error only) 2,693 83% 3,218 -16%

View base workflow run

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