# Dify Observability & Monitoring with OpenTelemetry

> Source: <https://signoz.io/docs/dify-observability>
> Published: 2026-05-20 00:00:00+00:00

Overview

This guide walks you through setting up observability and monitoring for Dify using [OpenTelemetry](https://opentelemetry.io/) and exporting traces and metrics to SigNoz. With this integration, you can observe and track various metrics for your Dify agent workflows.

Monitoring Dify agents with telemetry ensures full observability across your AI and LLM workflows. By leveraging SigNoz, you can analyze correlated traces and metrics in unified dashboards, configure alerts, and gain actionable insights to continuously improve reliability, responsiveness, and user experience.

Prerequisites

- A
[SigNoz Cloud account](https://signoz.io/teams/)with an active ingestion key or[Self Hosted SigNoz instance](https://signoz.io/docs/install/self-host/) - A Dify self-hosted instance. Follow the
[Dify quickstart guide](https://docs.dify.ai/en/self-host/quick-start/docker-compose)to get set up

Monitoring Dify

For more information on instrumenting your Dify workflows with OpenTelemetry, refer to the [Dify OpenTelemetry configuration](https://docs.dify.ai/en/self-host/configuration/environments#otlp-%2F-opentelemetry-configuration) docs.

Step 1: Configure OpenTelemetry in your Dify `.env`

file

Open the `.env`

file in your Dify `/docker`

directory and add the following environment variables:

```
# ------------------------------
# OTLP Collector Configuration
# ------------------------------
ENABLE_OTEL=true
OTLP_BASE_ENDPOINT=https://ingest.<region>.signoz.cloud:443
OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<your-ingestion-key>
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_TYPE=otlp
OTEL_SAMPLING_RATE=1.0
OTEL_BATCH_EXPORT_SCHEDULE_DELAY=5000
OTEL_MAX_QUEUE_SIZE=2048
OTEL_MAX_EXPORT_BATCH_SIZE=512
OTEL_METRIC_EXPORT_INTERVAL=60000
OTEL_BATCH_EXPORT_TIMEOUT=10000
OTEL_METRIC_EXPORT_TIMEOUT=30000
```

`<region>`

: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)`<your-ingestion-key>`

: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)

Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).

Step 2: Apply the required code change

In `docker/docker-compose.yaml`

, find the `x-shared-api-worker-env`

block and add the following line alongside the other `OTLP_*`

variables:

```
OTEL_EXPORTER_OTLP_HEADERS: ${OTEL_EXPORTER_OTLP_HEADERS:-}
```

This forwards the `OTEL_EXPORTER_OTLP_HEADERS`

value from your `.env`

file into the API and worker containers so the OpenTelemetry SDK can read it.

Step 3: Restart Dify with the applied changes

From your `/docker`

directory, run:

```
docker compose up -d
```

This restarts all Dify services with the updated environment variables, enabling OpenTelemetry export to SigNoz.

Cloud support is coming soon. Stay tuned for updates.

View Traces and Metrics in SigNoz

Your Dify usage should now automatically emit traces and metrics.

You should be able to view traces in SigNoz Cloud under the traces tab:

When you click on a trace in SigNoz, you'll see a detailed view of the trace, including all associated spans, along with their events and attributes.

You should be able to see Dify related metrics in SigNoz Cloud under the metrics tab:

When you click on any of these metrics in SigNoz, you'll see a detailed view of the metric, including attributes:

Troubleshooting

[Troubleshooting](#troubleshooting)

If you don't see your telemetry data:

**Verify network connectivity**- Ensure your application can reach SigNoz Cloud endpoints** Check ingestion key**- Verify your SigNoz ingestion key is correct** Wait for data**- OpenTelemetry batches data before sending, so wait 10-30 seconds after making API calls** Try a console exporter**— Enable a console exporter locally to confirm that your application is generating telemetry data before it’s sent to SigNoz

Next Steps

You can also check out our custom [Dify dashboard](https://signoz.io/docs/dashboards/dashboard-templates/dify-dashboard/) which provides specialized visualizations for monitoring your Dify usage. The dashboard includes pre-built charts specifically tailored for LLM usage, along with import instructions to get started quickly.

Setup OpenTelemetry Collector (Optional)

[Setup OpenTelemetry Collector (Optional)](#setup-opentelemetry-collector-optional)

What is the OpenTelemetry Collector?

Think of the OTel Collector as a middleman between your app and SigNoz. Instead of your application sending data directly to SigNoz, it sends everything to the Collector first, which then forwards it along.

Why use it?

**Cleaning up data**— Filter out noisy traces you don't care about, or remove sensitive info before it leaves your servers.** Keeping your app lightweight**— Let the Collector handle batching, retries, and compression instead of your application code.** Adding context automatically**— The Collector can tag your data with useful info like which Kubernetes pod or cloud region it came from.** Future flexibility**— Want to send data to multiple backends later? The Collector makes that easy without changing your app.

See [Switch from direct export to Collector](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/switch-to-collector/) for step-by-step instructions to convert your setup.

For more details, see [Why use the OpenTelemetry Collector?](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/why-to-use-collector/) and the [Collector configuration guide](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/configuration/).

Additional resources:

- Set up
[alerts](https://signoz.io/docs/product-features/alert-management)for high latency or error rates - Learn more about
[querying traces](https://signoz.io/docs/product-features/trace-explorer) - Explore
[log correlation](https://signoz.io/docs/product-features/logs-explorer)
