Skip to content

feat(@langchain/langgraph): initial integration support#7412

Open
crysmags wants to merge 6 commits intomasterfrom
crysmags/agentic-llm-langgraph-test
Open

feat(@langchain/langgraph): initial integration support#7412
crysmags wants to merge 6 commits intomasterfrom
crysmags/agentic-llm-langgraph-test

Conversation

@crysmags
Copy link
Collaborator

@crysmags crysmags commented Feb 2, 2026

This will add support for LangGraph and was made using the APM Instrumentation Toolkit.

@crysmags crysmags force-pushed the crysmags/agentic-llm-langgraph-test branch from 5e87531 to 4de611f Compare February 2, 2026 17:56
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Overall package size

Self size: 4.57 MB
Deduped: 5.4 MB
No deduping: 5.4 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.3 | 76.87 kB | 808.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 30.95238% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.26%. Comparing base (2e337bd) to head (fec5e8c).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
packages/datadog-plugin-langgraph/src/internal.js 13.88% 31 Missing ⚠️
...ges/dd-trace/src/llmobs/plugins/langgraph/index.js 26.47% 25 Missing ⚠️
...ages/datadog-instrumentations/src/helpers/hooks.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/plugins/index.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7412      +/-   ##
==========================================
- Coverage   80.39%   80.26%   -0.13%     
==========================================
  Files         732      736       +4     
  Lines       31027    31134     +107     
==========================================
+ Hits        24945    24991      +46     
- Misses       6082     6143      +61     
Flag Coverage Δ
aiguard-macos 39.06% <33.33%> (-0.10%) ⬇️
aiguard-ubuntu 39.10% <33.33%> (-0.10%) ⬇️
aiguard-windows 38.95% <33.33%> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.78% <30.95%> (-0.13%) ⬇️
apm-capabilities-tracing-ubuntu 48.83% <30.95%> (-0.08%) ⬇️
apm-capabilities-tracing-windows 48.51% <30.95%> (-0.13%) ⬇️
apm-integrations-child-process 38.56% <33.33%> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.46% <33.33%> (-0.10%) ⬇️
apm-integrations-couchbase-eol 37.80% <33.33%> (-0.07%) ⬇️
apm-integrations-oracledb 37.99% <33.33%> (-0.08%) ⬇️
appsec-express 55.35% <33.33%> (-0.10%) ⬇️
appsec-fastify 51.98% <33.33%> (-0.08%) ⬇️
appsec-graphql 52.31% <33.33%> (-0.09%) ⬇️
appsec-kafka 44.63% <33.33%> (-0.08%) ⬇️
appsec-ldapjs 44.30% <33.33%> (-0.08%) ⬇️
appsec-lodash 43.98% <33.33%> (-0.08%) ⬇️
appsec-macos 58.47% <33.33%> (-0.04%) ⬇️
appsec-mongodb-core 49.18% <33.33%> (-0.09%) ⬇️
appsec-mongoose 49.87% <33.33%> (-0.09%) ⬇️
appsec-mysql 51.26% <33.33%> (-0.08%) ⬇️
appsec-node-serialize 43.49% <33.33%> (-0.08%) ⬇️
appsec-passport 48.09% <33.33%> (-0.08%) ⬇️
appsec-postgres 51.05% <33.33%> (-0.06%) ⬇️
appsec-sourcing 42.83% <33.33%> (-0.08%) ⬇️
appsec-template 43.66% <33.33%> (-0.08%) ⬇️
appsec-ubuntu 58.50% <33.33%> (-0.04%) ⬇️
appsec-windows 58.34% <33.33%> (-0.04%) ⬇️
instrumentations-instrumentation-bluebird 32.24% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-body-parser 40.72% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 37.87% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.50% <33.33%> (-0.09%) ⬇️
instrumentations-instrumentation-express 34.84% <33.33%> (-0.09%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.63% <33.33%> (-0.09%) ⬇️
instrumentations-instrumentation-express-session 40.40% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-fs 31.83% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-generic-pool 29.80% <50.00%> (+<0.01%) ⬆️
instrumentations-instrumentation-http 39.61% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-knex 32.24% <33.33%> (+0.12%) ⬆️
instrumentations-instrumentation-mongoose 33.61% <33.33%> (-0.07%) ⬇️
instrumentations-instrumentation-multer 40.46% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 38.26% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-passport 40.76% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.73% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 40.73% <33.33%> (-0.08%) ⬇️
instrumentations-instrumentation-pg 37.77% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.16% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-promise-js 32.17% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-q 32.21% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-url 32.13% <33.33%> (-0.13%) ⬇️
instrumentations-instrumentation-when 32.18% <33.33%> (-0.13%) ⬇️
llmobs-ai 41.54% <33.33%> (+0.06%) ⬆️
llmobs-anthropic 40.62% <33.33%> (-0.08%) ⬇️
llmobs-bedrock 39.50% <33.33%> (-0.07%) ⬇️
llmobs-google-genai 40.24% <33.33%> (+0.06%) ⬆️
llmobs-langchain 39.65% <33.33%> (-0.06%) ⬇️
llmobs-openai 44.45% <33.33%> (-0.08%) ⬇️
llmobs-vertex-ai 40.34% <33.33%> (-0.13%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.69% <100.00%> (+0.07%) ⬆️
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.77% <100.00%> (+0.12%) ⬆️
plugins-azure-service-bus 22.20% <100.00%> (+0.12%) ⬆️
plugins-bullmq 43.70% <33.33%> (+0.07%) ⬆️
plugins-cassandra 38.17% <33.33%> (+0.07%) ⬆️
plugins-cookie 23.82% <100.00%> (+0.12%) ⬆️
plugins-cookie-parser 23.62% <100.00%> (+0.12%) ⬆️
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.38% <33.33%> (-0.10%) ⬇️
plugins-express-mongo-sanitize 23.80% <100.00%> (+0.12%) ⬆️
plugins-express-session 23.58% <100.00%> (+0.12%) ⬆️
plugins-fastify 42.52% <33.33%> (-0.08%) ⬇️
plugins-fetch 38.59% <33.33%> (-0.08%) ⬇️
plugins-fs 38.66% <33.33%> (-0.08%) ⬇️
plugins-generic-pool 22.80% <100.00%> (+0.12%) ⬆️
plugins-google-cloud-pubsub 45.72% <33.33%> (-0.07%) ⬇️
plugins-grpc 41.28% <33.33%> (-0.09%) ⬇️
plugins-handlebars 23.84% <100.00%> (+0.12%) ⬆️
plugins-hapi 40.42% <33.33%> (-0.08%) ⬇️
plugins-hono 40.76% <33.33%> (+0.06%) ⬆️
plugins-ioredis 38.46% <33.33%> (-0.08%) ⬇️
plugins-knex 23.63% <100.00%> (+0.11%) ⬆️
plugins-ldapjs 21.40% <100.00%> (+0.12%) ⬆️
plugins-limitd-client 32.53% <33.33%> (-0.13%) ⬇️
plugins-lodash 22.87% <100.00%> (+0.12%) ⬆️
plugins-mariadb 39.57% <33.33%> (-0.03%) ⬇️
plugins-memcached 38.19% <33.33%> (-0.08%) ⬇️
plugins-microgateway-core 39.43% <33.33%> (-0.08%) ⬇️
plugins-moleculer 40.83% <33.33%> (-0.08%) ⬇️
plugins-mongodb 39.54% <33.33%> (-0.08%) ⬇️
plugins-mongodb-core 39.11% <33.33%> (-0.08%) ⬇️
plugins-mongoose 39.17% <33.33%> (-0.08%) ⬇️
plugins-multer 23.58% <100.00%> (+0.12%) ⬆️
plugins-mysql 39.25% <33.33%> (-0.05%) ⬇️
plugins-mysql2 39.29% <33.33%> (-0.08%) ⬇️
plugins-node-serialize 23.86% <100.00%> (+0.12%) ⬆️
plugins-opensearch 37.87% <33.33%> (-0.08%) ⬇️
plugins-postgres 35.70% <33.33%> (-0.07%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.82% <100.00%> (+0.12%) ⬆️
plugins-redis 38.78% <33.33%> (-0.08%) ⬇️
plugins-router 43.23% <33.33%> (-0.08%) ⬇️
plugins-sequelize 22.40% <100.00%> (+0.12%) ⬆️
plugins-test-and-upstream-amqp10 38.53% <33.33%> (-0.07%) ⬇️
plugins-test-and-upstream-amqplib 43.89% <33.33%> (-0.08%) ⬇️
plugins-test-and-upstream-apollo 39.31% <33.33%> (-0.07%) ⬇️
plugins-test-and-upstream-avsc 38.80% <33.33%> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 33.85% <33.33%> (-0.10%) ⬇️
plugins-test-and-upstream-connect 41.03% <33.33%> (-0.08%) ⬇️
plugins-test-and-upstream-graphql 40.21% <33.33%> (-0.09%) ⬇️
plugins-test-and-upstream-koa 40.68% <33.33%> (-0.07%) ⬇️
plugins-test-and-upstream-protobufjs 39.03% <33.33%> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 44.14% <33.33%> (-0.08%) ⬇️
plugins-undici 39.39% <33.33%> (-0.07%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.11% <33.33%> (-0.08%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.25% <33.33%> (-0.09%) ⬇️
plugins-ws 40.74% <33.33%> (-0.09%) ⬇️
profiling-macos 40.05% <33.33%> (-0.07%) ⬇️
profiling-ubuntu 40.10% <33.33%> (-0.07%) ⬇️
profiling-windows 41.46% <33.33%> (-0.07%) ⬇️
serverless-azure-functions-client 23.01% <100.00%> (+0.12%) ⬆️
serverless-azure-functions-eventhubs 23.01% <100.00%> (+0.12%) ⬆️
serverless-azure-functions-servicebus 23.01% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link

pr-commenter bot commented Feb 2, 2026

Benchmarks

Benchmark execution time: 2026-02-03 18:52:50

Comparing candidate commit fec5e8c in PR branch crysmags/agentic-llm-langgraph-test with baseline commit 2e337bd in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 225 metrics, 25 unstable metrics.

These changes were made by the llm obs workflow to improve test
robustness but are not needed for the LangGraph integration itself.

The changes have been saved to /tmp/util-js-llmobs-improvements.patch
for future reference and can be applied later if needed.

Changes reverted:
- Mock value handling for timing fields (span_id, duration, start_ns)
- Better error handling in test assertions
- Input validation improvements
- Edge case handling for outputValue === 0
- Add trailing commas to all arrays and objects per @stylistic/comma-dangle
- Break long line in llmobs plugin to comply with max-len rule
- Remove unused 'llmobs' variable in test spec

All langgraph-related linting errors have been fixed.
@crysmags crysmags force-pushed the crysmags/agentic-llm-langgraph-test branch from 522cd8e to 6d3c48d Compare February 2, 2026 18:54
@datadog-official
Copy link

datadog-official bot commented Feb 3, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 2 New flaky tests detected

cypress@14.5.4 commonJS intelligent test runner reports itr_correlation_id in tests from integration-tests/cypress/cypress.spec.js (Datadog) (Fix with Cursor)
Timeout of 80000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/dd-trace-js/dd-trace-js/integration-tests/cypress/cypress.spec.js)
cypress@14.5.4 esm test management quarantine does not enable quarantine tests if DD_TEST_MANAGEMENT_ENABLED is set to false from integration-tests/cypress/cypress.spec.js (Datadog) (Fix with Cursor)
Cannot read properties of undefined (reading 'content')

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fec5e8c | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@crysmags crysmags marked this pull request as ready for review February 3, 2026 18:31
@crysmags crysmags requested review from a team as code owners February 3, 2026 18:31
@crysmags crysmags requested review from ida613 and removed request for a team February 3, 2026 18:31
Comment on lines +51 to +55
const asyncIterable = ctx.result

const originalAsyncIterator = asyncIterable[Symbol.asyncIterator].bind(asyncIterable)

asyncIterable[Symbol.asyncIterator] = function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we should try and do this in the langgraph.js instrumentation file maybe, and add a custom subscriber there and use shimmer.wrap for robustness. then we can emit a new event with the context that this PregelStreamPlugin can listen for

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are trying to avoid this so that we can continue to use Orchestrion, right now since we only have tracePromise we need to handle this on the subscriber.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, what i mean is we can do this out directly in the langgraph.js instead

const orchestrionStreamCh = channel('tracing:orchestrion:@langchain/langgraph:Pregel_stream')

orchestrionStreamCh.subscribe({
  asyncStart (ctx) {
    // shimmer.wrap ctx.result
  }
})

just so any/all custom wrapping logic happens in instrumentation and not in the plugins directly. lmk if this doesn't make any sense tho as idk if we do something like this currently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is a common pattern to mix publisher and subscriber logic in the instrumentation. I would think it would be cleaner to keep it on the subscriber/plugin side, but I can defer to @rochdev on this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok i don't have too strong a preference, just that we had done something like that previously for langchain before we had some more orchestrion capabilities (ref).

i think in either case we should use shimmer to patch instead of modifying properties directly (even if shimmer just does this directly under the hood)


getLLMObsSpanRegisterOptions (ctx) {
const span = ctx.currentStore?.span
const name = span?.context()._tags?.['resource.name'] || 'langgraph.workflow'
Copy link
Collaborator

@sabrenner sabrenner Feb 3, 2026

Choose a reason for hiding this comment

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

i gotta check it out but ideally if we can use ctx.self.name if it exists (like this.name, this referring to the graph instance), that would be better i think


formatIO (data) {
// Handle null/undefined explicitly
if (data === null || data === undefined) return ''
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (data === null || data === undefined) return ''
if (data == null) return ''

@tlhunter tlhunter added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Feb 4, 2026
@tlhunter tlhunter changed the title Crysmags/agentic llm langgraph test feat(@langchain/langgraph): initial integration support Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants