Skip to content

Dify

See each Dify application or workflow run as a trace (the full journey of one request or workflow run, made of one or more spans) in Logfire. A span is one unit of work: a single operation, with a name, a start, and a duration. Dify also sends metrics (numbers tracked over time), including HTTP response counts by method, route, and status.

Dify sends this data using the OpenTelemetry Protocol (OTLP), the standard wire format Logfire uses to receive telemetry. This direct route is available when an administrator can configure the Dify API and worker runtime. A hosted plan that does not expose runtime settings cannot use this route.

Configure Dify

Create a project write token, then set these values for the Dify API and worker services:

ENABLE_OTEL=true
OTLP_BASE_ENDPOINT=https://logfire-us.pydantic.dev
OTLP_API_KEY=<your-write-token>
OTEL_EXPORTER_TYPE=otlp
OTEL_EXPORTER_OTLP_PROTOCOL=http
OTEL_SAMPLING_RATE=1.0

For an EU project, use https://logfire-eu.pydantic.dev. Leave OTLP_TRACE_ENDPOINT and OTLP_METRIC_ENDPOINT unset when using the base URL. Dify appends /v1/traces and /v1/metrics, and sends OTLP_API_KEY as a Bearer authorization token.

OTEL_SAMPLING_RATE=1.0 records every eligible trace and is useful while verifying the connection. Lower it after considering traffic volume and cost.

Restart the API and worker services after applying the environment.

Verify

Run an application or workflow, then open the Live view. You should see Dify spans. Metrics can take a minute or two to appear in Metrics.

Troubleshooting

SymptomCause and fix
No data arrivesConfirm the settings are available to both the API and worker services and check their logs for errors sending telemetry.
Requests use a duplicated signal pathSet only OTLP_BASE_ENDPOINT; do not include /v1/traces or /v1/metrics in it.
Logfire returns 401 or 403Replace OTLP_API_KEY with a valid write token from the project in the selected region.
Too few traces arriveDify samples traces. Keep OTEL_SAMPLING_RATE=1.0 while verifying the connection.

See Dify’s current OpenTelemetry configuration and OpenTelemetry implementation for the settings and endpoint behavior.