Repository navigation
fix(trace): send Langfuse traces over OpenTelemetry - #45606
Merged
Merged
Conversation
Langfuse v4 rejects trace, span, and generation events on the legacy ingestion API, and Langfuse Cloud retires it on 2026-11-16. Send each trace unit as OTLP protobuf to /api/public/otel/v1/traces instead, using the shared OTLP encoder and egress. Fixes #41542
Contributor
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #45606 +/- ##
========================================
Coverage 89.88% 89.89%
========================================
Files 6245 6246 +1
Lines 391156 391273 +117
Branches 78436 78451 +15
========================================
+ Hits 351599 351728 +129
+ Misses 33453 33444 -9
+ Partials 6104 6101 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wylswz
approved these changes
Nov 5, 2026
hjlarry
pushed a commit
that referenced
this pull request
Nov 9, 2026
(cherry picked from commit 0be453d)
fatelei
pushed a commit
to fatelei/dify
that referenced
this pull request
Nov 9, 2026
1 task done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important
Fixes #<issue number>.Summary
Fixes #41542
Langfuse v4 rejects trace, span, and generation events on
POST /api/public/ingestion(HTTP 207 with a 400 for every event), and Langfuse Cloud retires that endpoint on 2026-11-16. After #44673 the Langfuse provider still posts there, so every Dify trace to Langfuse Cloud or to self-hosted v4 is dropped.This switches
LangfuseProvider.sendto OTLP protobuf through the shareddify_trace_sdk.otlpencoder and egress, the same path the Phoenix provider uses. Only the Langfuse provider changes. The pipeline, the SDK runtime, the provider config, and the other providers are untouched.Mapping:
langfuse.observation.type=generation/chain/tool/retriever/agentlangfuse.observation.input/.outputlangfuse.observation.metadata.<key>.model.name,.usage_details,.cost_details,.completion_start_timelangfuse.user.id,langfuse.session.id,langfuse.trace.nameon every span (Langfuse v4 filters per observation)dify_trace_id+external_trace_idlangfuse.trace.metadata.<key>on the root span onlyERRORand the status message from it)Retries follow the shared OTLP classification. A transient failure before anything was sent is retried. An unknown outcome, or a failure after part of a split unit was accepted, is not retried, because Langfuse v4 does not deduplicate re-sent spans.
Supersedes #41543 and #43705, which were written against the provider before #44673.
Screenshots
N/A (backend). Evidence:
ExportRejectedError: Langfuse rejected 2 ingestion events200, including a ~4.5 MB trace split into two requestsGET /api/public/v2/observations: 207 of 209 field checks match what was sent (IDs, parents, types, times, level, input/output, metadata, user/session, model, usage, cost, TTFT, no duplicates). The 2 misses are Langfuse moving 2.25 MB inputs to its media storage.total_tokens) match.Behavior changes for users
No Dify config, database, or queue changes. Visible in Langfuse:
langfuse.*attributes: self-hosted v3.63.0 or later (the same floor as Langfuse's Python SDK). Older servers answer 404 and the trace is dropped with a warning.X-Trace-Idis hashed (kept as trace metadataexternal_trace_id). Observation IDs are the 16-hex span IDs. Existing traces and stored links are unchanged.SPAN.POST /api/public/otel/v1/traceswithapplication/x-protobuf.Merge Danger
Door: two-way. Reverting restores the legacy request (which Langfuse Cloud stops accepting on 2026-11-16).
Blast Radius: Langfuse tracing only.
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods