fix(core): correct Langfuse import path to fix tracing issue #1805
+276
−10
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.
Summary
This PR fixes issue #1677 where Langfuse LLM call tracing was not working.
Root Causes Fixed
1. Incorrect Import Path
The code was importing
observeOpenAIfrom the wrong package:import { observeOpenAI } from 'langfuse'import { observeOpenAI } from '@langfuse/openai'According to Langfuse's official documentation, the OpenAI SDK integration should use the
@langfuse/openaipackage, not the baselangfusepackage.2. Missing OpenTelemetry Initialization
Langfuse's tracing is built on top of OpenTelemetry, which requires initialization before it can work. Previously, users had to manually add this initialization code to their application entry file, which was easy to miss.
Changes
1. Fixed Import Path (
packages/core/src/ai-model/service-caller/index.ts:188)'langfuse'to'@langfuse/openai'2. Auto-Initialize OpenTelemetry (
packages/core/src/ai-model/service-caller/index.ts:190-214)3. Documentation Updates
apps/site/docs/zh/model-config.mdxapps/site/docs/en/model-config.mdxnpm install @langfuse/openai @langfuse/otel @opentelemetry/sdk-nodeBenefits
Testing
For Users Affected by #1677
If you're experiencing Langfuse tracing issues:
Update packages:
Remove manual initialization (if you added it):
NodeSDKorLangfuseSpanProcessorinitialization code from your applicationRestart your application
You should see these logs:
Langfuse tracing should now work correctly!
Fixes #1677