Langfuse Tracing Integration Issue with Vercel AI SDK on Cloudflare Hono Worker #10715
Replies: 1 comment
-
|
Based on the available documentation, there is a known compatibility issue with the current Langfuse AI SDK implementation on Cloudflare Workers(1). The Core IssueThe Langfuse AI SDK integration with the Vercel AI SDK uses OpenTelemetry, which relies on Node.js APIs that are not available in Cloudflare Workers(1). This is why you're unable to capture traces in your Cloudflare Hono Worker environment, even when following the standard integration guide(2). Current StatusThe standard Vercel AI SDK integration documented at the official integration page requires the OpenTelemetry setup with import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";
const sdk = new NodeSDK({
spanProcessors: [new LangfuseSpanProcessor()],
});
sdk.start();This setup is incompatible with Cloudflare Workers because it depends on Node.js-specific APIs(1). Recommended WorkaroundsWhile there isn't currently a dedicated Edge/Web SDK for this specific use case in the documentation, the sources mention that the same code from the integration example works without issues in a Node.js environment but fails in Cloudflare Workers(1). For serverless environments in general, the documentation recommends using // within the Cloudflare Workers handler
event.waitUntil(langfuse.flushAsync());However, this alone won't resolve the underlying Node.js API compatibility issue. Alternative ApproachSince the OpenTelemetry-based approach doesn't work on Cloudflare Workers, you may need to:
Unfortunately, the current documentation does not provide a specific Edge SDK or polyfill solution for Cloudflare Workers with the Vercel AI SDK integration(2)(3)(1). Note: This is a known limitation, and there's an open issue tracking this problem(1). You may want to monitor that issue for updates on Cloudflare Workers support. 📚 Sources:
Have another question? Just tag @inkeep. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your question
Hii,
I am currently implementing an application using the Vercel AI SDK within a Cloudflare Hono Worker environment.
I am attempting to follow the official documentation for Vercel AI SDK integration (specifically, the page located at
https://langfuse.com/integrations/frameworks/vercel-ai-sdk), but I am unable to successfully capture traces in my Langfuse project.Could you please provide guidance on the recommended approach for integrating Langfuse within a Cloudflare Worker?
Your assistance in resolving this integration issue would be greatly appreciated.
Langfuse Cloud or Self-Hosted?
Self-Hosted
If Self-Hosted
3.132.0 oss
If Langfuse Cloud
No response
SDK and integration versions
Pre-Submission Checklist
Beta Was this translation helpful? Give feedback.
All reactions