You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds support for LangChain manual instrumentation in @sentry/cloudflare and @sentry/vercel-edge.
To instrument LangChain operations, create a callback handler with Sentry.createLangChainCallbackHandler and pass it to your LangChain invocations.
import * as Sentry from '@sentry/cloudflare';
import { ChatAnthropic } from '@langchain/anthropic';
// Create a LangChain callback handler
const callbackHandler = Sentry.createLangChainCallbackHandler({
recordInputs: true, // Optional: record input prompts/messages
recordOutputs: true // Optional: record output responses
});
// Use with chat models
const model = new ChatAnthropic({
model: 'claude-3-5-sonnet-20241022',
apiKey: 'your-api-key'
});
await model.invoke('Tell me a joke', {
callbacks: [callbackHandler]
});
The callback handler automatically creates spans for:
Chat model invocations (gen_ai.chat)
LLM invocations (gen_ai.pipeline)
Chain executions (gen_ai.invoke_agent)
Tool executions (gen_ai.execute_tool)
RulaKhaled
changed the title
Support vercel and cloudflare
feat(cloudflare,vercel-edge): Add support for LangChain instrumentation
Oct 21, 2025
The code passes a Record object { invocation_params: invocationParams } to the tags parameter which has type string[]. While the type assertion as unknown as string[] silences the compiler, this creates a type mismatch at runtime. The callback handler expects tags to be a string array, but receives an object instead, which could cause runtime errors or incorrect behavior in the actual LangChain callback handler implementation.
The compatibility_date is set to "2025-06-17" which is in the future relative to the current date (10/23/2025 according to the context). This appears to be a typo and should likely be "2024-06-17" or another valid past date. A future compatibility date may cause unexpected behavior or errors in Cloudflare Workers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for LangChain manual instrumentation in @sentry/cloudflare and @sentry/vercel-edge.
To instrument LangChain operations, create a callback handler with Sentry.createLangChainCallbackHandler and pass it to your LangChain invocations.
The callback handler automatically creates spans for: