How Dify sends app traces to self-hosted Langfuse
A team running self-hosted Dify apps that needs their traces in self-hosted Langfuse can do it without a custom connector. Langfuse is added as a third-party LLMOps provider in each Dify app's monitoring settings, and Dify then sends trace data for that app to the Langfuse project you configure. The setting is made per app, so every app that should be observed needs its own configuration, and the Langfuse host, public key and secret key you enter must point at your own instance rather than Langfuse Cloud. Confirm the exact field names and the current settings path in your Dify version against the Langfuse Dify documentation before you write the configuration into your change process.
The native mapping decides how your Langfuse data reads later. Dify's user value maps to Langfuse userId, its message_id maps to the Langfuse trace_id, and its conversation_id maps to the Langfuse sessionId. In practice, each message becomes one trace, and all messages in the same conversation are grouped into one session. Because user is whatever identifier the calling application sends, decide with your privacy and security owners whether it should be an internal ID rather than an email address before users start chatting, since it will appear in Langfuse traces and any retention rules you apply there.
This page covers both the setup of the Dify to Langfuse connection and the use of Langfuse to evaluate Dify workflows, including how to compare workflow versions and read traces for failed runs. It does not cover deploying Dify or Langfuse themselves, configuring Dify's SSO or workspace model, building Dify workflows, or the Langfuse evaluators and datasets in depth, which have their own sections and topics.
What you need running before you connect Dify to Langfuse
Dify and Langfuse each run as their own stack, and the monitoring connection only works when both are healthy and can reach each other. Plan the two deployments first, then the network path, trust and keys that join them, so a broken trace can be traced to one layer.
Dify self-hosted stack
Dify's Docker Compose deployment starts the api, worker, web, plugin daemon and sandbox services, plus PostgreSQL, Redis, Weaviate, Nginx and an SSRF proxy. Use Docker Compose 2.24.0 or later on a host with at least 2 CPU cores and 4 GB of RAM as a floor, then size for your own workflow load. Confirm which metadata database and vector store you chose, since they change what you back up.
Dify Compose docsSelf-hosted Langfuse stack
A production Langfuse deployment runs the Web and Worker containers alongside PostgreSQL, ClickHouse, Redis or Valkey and S3-compatible blob storage. Langfuse's scaling guide sets minimum resources for each, with ClickHouse needing the most memory. Decide whether this instance is a single VM for testing or a Kubernetes deployment before Dify sends it real traces, because the host name you give Dify depends on that choice.
- ClickHouse memory, larger deployments
- 16 GiB
Network path from Dify API
The trace requests leave the Dify api container, not your browser, so the Langfuse host must be reachable from inside that container's network. Test name resolution and the port from within the container, and check any firewall, proxy or egress policy between the two hosts. Dify's SSRF proxy is designed to block internal and private address ranges, so a Langfuse address on a private network may be refused unless you allow it deliberately.
TLS trust for the Langfuse endpoint
If Langfuse is served over HTTPS with an internal certificate authority, the Dify containers must trust that CA or the connection fails during tracing. Add the CA to the container trust store through your image build or mounted bundle, then test with a request from the api container. Confirm certificate expiry and renewal dates now, since an expired certificate stops all traces without an obvious error inside Dify.
Langfuse project API keys
Create a public and secret key pair in the Langfuse project that will receive Dify traces, and keep one project per environment or team if you need separate access. Store the secret key in your secrets manager and enter it only in Dify's monitoring settings. Rotate the pair if it is exposed, because anyone holding the secret key can write traces to that project.
Dify SECRET_KEY and SSRF checks
Dify 1.16.1 added agent sandbox network isolation through a Squid proxy, token-based API authentication between services and sandboxed Jinja2 rendering. Confirm that your deployed version includes these changes, then verify that outbound requests to Langfuse route through the SSRF proxy as intended. Also confirm that SECRET_KEY is set and recorded, because changing it after deployment logs out all users.
Dify environment variablesConfiguring the Langfuse provider in a Dify app
This sequence connects one self-hosted Dify app to a self-hosted Langfuse project so that a test conversation produces a trace with the expected user and session fields.
Create the Langfuse project and API keys
An operator signs in to the self-hosted Langfuse UI, creates a dedicated project for the Dify app (one project per app keeps traces separable), and generates a public and secret API key pair from the project settings. Store the secret key in your secrets manager, not in a shared document. The step is done when the project exists, both keys are listed as active, and you have recorded the exact base URL of your Langfuse instance, which must be reachable from the Dify host. Confirm the exact menu names against the Langfuse Dify docs, since UI labels change between releases.
Confirm network reachability from Dify to Langfuse
The network or platform team checks that the Dify api and worker containers can open an HTTPS connection to the Langfuse host, and that any outbound proxy or egress rule allows it. Dify routes outbound requests through its SSRF proxy settings, so test from inside the Dify environment, not only from your workstation. The check passes when a request from the Dify container to the Langfuse base URL returns a successful response. If it fails, resolve the route or proxy exception before you touch the Dify app.
Open the Dify app's monitoring settings
A Dify workspace administrator or app editor opens the target app in the Dify console and navigates to its monitoring settings, where third-party LLMOps providers are configured for that app. Monitoring is set per app, so repeat these steps for each app you want traced. The step is done when the monitoring panel for the app is open and shows the list of available providers. Confirm the current location of this setting in the Dify UI against the Langfuse Dify docs before you proceed.
Select Langfuse and enter host and keys
In the monitoring settings, the operator chooses Langfuse as the provider and enters the Langfuse host URL, the public key and the secret key from the first step. Enter the host exactly as your instance is served, including the scheme, and do not add a path unless the docs say so. Save the configuration and note whether Dify reports the provider as enabled. The step is done when the settings save without a validation error and the provider shows as active for that app.
Send a test conversation in the Dify app
The tester opens the published or debug version of the app and sends a short conversation with at least two messages, so that the session grouping can be verified. Use a test user identifier that is clearly labeled, such as a dedicated test account, so the trace is easy to find. The step is done when the app returns a normal response and no error appears in the Dify logs for the monitoring call.
Verify the trace and session in Langfuse
In the Langfuse project, the operator opens the Traces view and finds the trace from the test conversation. Check that the trace carries the Dify user identifier as the user, that the messages share one session, and that model input, output and latency are populated. The check passes when the trace and session match the test you sent. If the trace is missing, confirm the keys, the host and the Dify provider status before sending another test. Repeat with a second app or a second user to confirm the mapping holds.
How a Dify conversation becomes a Langfuse trace
The walk starts at the end user's message in the Dify web app, which calls the Dify API and runs the app's workflow. Dify then sends its monitoring data to the Langfuse host you configured in the app's monitoring settings, where the Langfuse Web and Worker containers write to PostgreSQL, ClickHouse and blob storage. The trust boundary sits between the two stacks: the Dify side and the Langfuse side are separate self-hosted systems, so the outbound call and its network path are the points to check. Confirm that the host address, keys and network route match your environment before you test with a real conversation.
Dify monitoring data flows to a separate self-hosted Langfuse stack.
How Dify users, messages and conversations map to Langfuse fields
This table compares the three Dify identifiers that Langfuse receives and shows where each one appears in the Langfuse interface. Read it before you build dashboards or filters, because the choice of user identifier and the presence of conversation IDs decide what you can group and investigate.
| Dify field | Langfuse field | What you see in Langfuse | What to check |
|---|---|---|---|
| user | userId | Traces grouped by user in the Users views and filters, with cost and token totals per user | Use a stable pseudonymous ID from your identity system, not an email address or name, and confirm that the value is consistent across sessions |
| message_id | trace_id | One trace for each message exchange, showing the workflow or app steps, model calls and latency for that message | Confirm that each user message produces one trace, and that retries or regenerated answers are recognized as separate traces |
| conversation_id | sessionId | Traces grouped into a session that shows a full multi-turn conversation in order | Check that conversation_id is present on every trace; without it, messages appear as isolated traces and session views are empty or incomplete |
| Dify app (illustrative: one app per team) | Trace name or tags (illustrative mapping) | Traces that you can filter by application when several Dify apps report to one Langfuse project | Decide how you separate apps before go-live, and confirm the chosen naming in a test run |
Evaluating Dify workflows with traces and scores
Once Dify sends traces to Langfuse, the most useful thing a team can do is read them node by node. Each workflow run arrives as a trace, so reviewers can open the steps a workflow took, see the input and output of each LLM, retrieval or tool step, and find the step where an answer went wrong. Because Dify's conversation_id maps to the Langfuse sessionId, reviewers can also read a full multi-turn conversation in order rather than judging a single reply in isolation. Decide early which apps and environments will be reviewed this way, and confirm with your own Dify version that the node-level detail you need appears in the traces before you build review routines around it.
To compare a prompt or model change, run the same inputs through the original and the changed app, then review the two sets of traces side by side. Keep the variable that changed in one place, such as the model name or the prompt text, so differences in latency, token use and output can be traced back to it. Langfuse holds the trace data, but the comparison design is yours. Plan which inputs represent production traffic, how many runs you need before a difference is meaningful, and who signs off. Dify version changes can also affect results, so record the Dify release next to each test run. Dify's releases page lists the versions to match against.
Scores are attached to traces in Langfuse, either by a person reviewing an output, by a user feedback signal or by an automated evaluator that you configure. The integration passes trace and session identifiers through, but it does not decide what good output means for your workflow. Your team must define the criteria, write or choose the evaluators, decide who annotates, and handle disagreement between reviewers. The scoring methods, including LLM-as-a-judge, code evaluators and human annotation, are covered in the Langfuse evaluations and datasets group. Test datasets are also built outside the integration: you assemble representative inputs, expected outcomes and edge cases from your own data, store them under your control, and then run them through the Dify app. Treat that dataset as a governed asset, because a weak dataset will produce confident scores that say little about production quality.
Security settings for Dify-to-Langfuse traffic
The Dify-to-Langfuse connection passes credentials, user identifiers and prompt content between two systems you run. The cards below cover where the Langfuse keys live, who can change monitoring settings, which Dify secrets must stay stable, how outbound requests are routed, and how far the Langfuse project should reach.
Protect the Langfuse keys in Dify
Dify stores the Langfuse public and secret keys in each app's monitoring configuration, so anyone who can read that configuration can call Langfuse as your project. Use a dedicated key pair for each Dify environment, not a key shared with other applications. Check that the secret key is never copied into exported app definitions, shared screenshots or support tickets, and rotate the pair in both Dify and Langfuse when a person with access leaves.
Langfuse Dify docsLimit who edits monitoring settings
Monitoring settings decide where an app's traces go, so a user who can edit them can redirect prompts and user identifiers to another host or project. Review which Dify workspace roles can open the monitoring panel of each app, and keep that list short for production apps. Ask your Dify administrator to confirm how app-level editing rights are granted in your Dify edition before you rely on them.
Dify app managementKeep SECRET_KEY stable
Dify uses SECRET_KEY to sign session cookies and JWTs and to encrypt OAuth credentials, and changing it after deployment logs out all users. Generate the value once, store it in your secrets manager, and make sure every Dify API and worker container receives the same value. Plan any rotation as a scheduled maintenance window, because it affects sign-in for the whole platform, not only monitoring.
- Logged out on change
- All users
Route outbound calls through SSRF_PROXY
The Langfuse host is an outbound destination, and Dify's SSRF_PROXY settings route outbound requests through a proxy that blocks internal and private IP ranges. If your Langfuse runs on a private address inside your network, the proxy may block the traffic that Dify needs to reach it. Test the connection from the Dify API container after any proxy change, and allow only the Langfuse host and port that you have approved.
Scope the Langfuse project to Dify apps
Traces from every Dify app land in the Langfuse project named in its settings, so one shared project mixes development, test and production data. Create a separate Langfuse project for each environment that holds real user data, and connect only the apps that need monitoring to it. Confirm with your team which projects may hold personal data before you enable tracing on a production app.
Langfuse Dify docsUse Enterprise RBAC and masking if required
Project-level RBAC roles and server-side data masking are Langfuse Enterprise features that need a license key on a self-hosted instance. They limit what Langfuse users see and hide sensitive fields in stored traces, which matters when prompts contain customer data. The open-source edition covers the integration itself, so decide whether these controls are a requirement before you plan the rollout.
Langfuse license key docsCommon failures when Dify traces do not reach Langfuse
This table lists five symptoms teams hit when Dify monitoring is connected to self-hosted Langfuse, with the likely cause and the first things to check in each environment. Work down the rows in order, because host and egress problems can hide the others. Most failures come from the connection settings, the session and user fields Dify sends, or worker capacity in Langfuse.
| Symptom | Likely cause | Fix and what to check |
|---|---|---|
| No traces appear in Langfuse | The host in Dify points at the wrong address, or outbound requests from Dify are blocked by egress rules or the SSRF proxy | Check the host in Dify matches your Langfuse URL. Confirm Dify's api and worker containers can reach it, and that SSRF_PROXY does not block the Langfuse address. |
| Traces appear but have no sessions | conversation_id is missing, so Langfuse has no sessionId to group messages | Test with a chat app, not a one-off completion. Workflow runs may not carry conversation_id, so open a trace and confirm its session field is populated. |
| Keys are rejected | The public or secret key belongs to a different project, or it was issued by a different Langfuse instance than the host entered | Create keys in the target project on the same instance as the host. Paste both keys and the exact host again, then send one test message. |
| Traces appear without a user | The calling client sends no end-user identifier, so Dify has no user value to map to userId | Confirm each request from the calling application includes an end-user value. Check the userId field on a sample trace after one test run. |
| Ingestion lags under load | Langfuse worker CPU is saturated, or heavy ingestion is overloading langfuse-web | Watch worker CPU and ingestion delay during the test. Scale worker containers first, then split langfuse-web into ingestion and UI deployments as the scaling guide describes. |
Questions buyers ask before connecting Dify to Langfuse
Is connecting Dify to self-hosted Langfuse free to set up?
The connection itself is a settings change, but the cost sits in the platforms underneath it. Langfuse's MIT-licensed open source version includes all core features and APIs without limits, so the software license is not a line item for tracing. Dify's self-hosted Community edition is also free, but it is limited to a single workspace. The self-hosted Enterprise edition is custom priced and adds SSO, multiple workspaces, advanced security, a commercial license and professional support. Your real costs are the infrastructure to run both platforms, the people who operate them, and any support plan you choose. Ask each vendor for a written quote tied to your deployment model, and confirm which Langfuse features you need that require an Enterprise license key before you assume the open source version covers them.
How much effort does the integration take for one Dify app compared with many?
Connecting a single Dify app is a short configuration task: you add Langfuse as a third-party LLMOps provider in the app's monitoring settings and supply the host and keys. Effort grows with the number of apps, workspaces and environments. Each app needs its own monitoring configuration and a decision about which Langfuse project receives its traces. Multi-workspace setups usually need the Enterprise edition of Dify, so the scope of your workspace model drives both effort and licensing. Teams also spend time agreeing on naming, on how users and conversations are mapped, and on who reviews traces. Plan the mapping once and document it before rolling it out to a large number of apps.
What does the team need to provide before the integration starts?
You need to provide the following before anyone configures a connection:
- A running self-hosted Langfuse instance with a reachable host address and project API keys.
- A running self-hosted Dify deployment, with the Docker Compose or Kubernetes setup sized to your user load.
- Network rules that allow Dify to reach the Langfuse host over the path you choose, and that keep the traffic inside your controlled network.
- A named owner for each platform who approves key creation, rotation and access changes.
Confirm the network path with your security team early, because private hosts, proxies and firewall rules are the most common source of delay. Also confirm where API keys are stored and who can view them in the Dify console.
Can a non-engineer set up the Dify and Langfuse connection?
A non-engineer can often complete the Dify monitoring screen once someone else has supplied the Langfuse host and keys, because the configuration is a form, not code. The harder work sits outside the screen: deploying and securing both platforms, deciding how traces are retained and who may view them, and making sure keys are handled correctly. Product or operations staff can then review traces and evaluate workflows. Someone with platform or security skills should own the deployment, upgrades and access model, since Dify and Langfuse both release updates regularly and both store sensitive prompt and user data.
What breaks most often when Dify traces stop appearing in Langfuse?
Most failures come from connection and configuration rather than from the tracing feature itself. Check these in order:
- The Langfuse host in the Dify settings is reachable from the Dify containers, not only from your laptop.
- The project keys match the Langfuse project you are checking.
- The Dify outbound proxy settings do not route the Langfuse host through a path that blocks it. Dify's SSRF proxy blocks internal and private IP ranges by design, so an internal Langfuse address may need a deliberate network decision.
- The Langfuse containers are healthy and have capacity for ingestion.
Write these checks into a runbook so the on-call engineer does not have to rediscover them.
Does changing the Dify SECRET_KEY affect the Langfuse integration?
Changing Dify's SECRET_KEY after deployment logs out all users, because it signs session cookies and JWTs and encrypts OAuth credentials. It is a security setting, so treat it as a planned change with a maintenance window and a plan for re-authenticating users. Keep the value in your secrets management system, not in a configuration file that many people can read. Rotating Langfuse keys is a separate operation that you should also plan and record.
When is it worth hiring a partner for the Dify and Langfuse integration?
A partner is worth considering when the integration is part of a larger platform obligation: many Dify workspaces, strict network segmentation, SSO and access control requirements, audit evidence for an assessment, or a team without spare platform capacity. DeployOpen plans, implements, hardens, backs up and documents self-hosted open-source platforms inside your own infrastructure, and runs fixed-scope engagements with scope and timelines agreed in writing before work starts. Ask any partner for a written scope that lists the apps, environments, network paths, owners and deliverables, and ask what happens after handover, including whether ongoing support is a retainer or a separate agreement.
How DeployOpen scopes and supports a Dify and Langfuse integration
DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure. For Dify and Langfuse, we start with a written scope that covers both platforms, the Dify apps to be traced, the trace mapping and the evaluation work, then build and hand over the integration with the runbooks your teams need.
How we scope
- We inventory the self-hosted Dify apps and workspaces that will send traces to Langfuse.
- We agree how Dify users, message IDs and conversation IDs map to Langfuse users, traces and sessions.
- We confirm which Langfuse features you need, and whether any require an Enterprise license key.
How we build
- We configure Langfuse as a third-party LLMOps provider in each Dify app's monitoring settings.
- We size and deploy the Langfuse stack in your infrastructure, including PostgreSQL, ClickHouse and blob storage.
- We test sample conversations end to end, then design Dify workflow evaluations against the traces they produce.
How we hand over
- We document the trace mapping, key management, host configuration and access model for your platform team.
- We provide runbooks for Dify and Langfuse upgrades, including the version checks that apply before each change.
- We walk your engineers and reviewers through the evidence needed for internal security and compliance reviews.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Pricing follows from the written scope. Confirm the quote's assumptions about data volume and hosting before signing.

