Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: add otel endpoint config (#22492)
heysztf082452c9bfc
diff --git a/api/.env.example b/api/.env.exampleindex eab017a624d..c09c6c230e2 100644--- a/api/.env.example+++ b/api/.env.example@@ -505,6 +505,8 @@ LOGIN_LOCKOUT_DURATION=86400# Enable OpenTelemetryENABLE_OTEL=false+OTLP_TRACE_ENDPOINT=+OTLP_METRIC_ENDPOINT=OTLP_BASE_ENDPOINT=http://localhost:4318OTLP_API_KEY=OTEL_EXPORTER_OTLP_PROTOCOL=diff --git a/api/configs/observability/otel/otel_config.py b/api/configs/observability/otel/otel_config.pyindex 1b88ddcfe66..7572a696ce5 100644--- a/api/configs/observability/otel/otel_config.py+++ b/api/configs/observability/otel/otel_config.py@@ -12,6 +12,16 @@ class OTelConfig(BaseSettings):default=False,)+ OTLP_TRACE_ENDPOINT: str = Field(+ description="OTLP trace endpoint",+ default="",+ )++ OTLP_METRIC_ENDPOINT: str = Field(+ description="OTLP metric endpoint",+ default="",+ )+OTLP_BASE_ENDPOINT: str = Field(description="OTLP base endpoint",default="http://localhost:4318",diff --git a/api/extensions/ext_otel.py b/api/extensions/ext_otel.pyindex b62b0b60d61..0771104fb15 100644--- a/api/extensions/ext_otel.py+++ b/api/extensions/ext_otel.py@@ -193,13 +193,22 @@ def init_app(app: DifyApp):insecure=True,)else:+ headers = {"Authorization": f"Bearer {dify_config.OTLP_API_KEY}"} if dify_config.OTLP_API_KEY else None++ trace_endpoint = dify_config.OTLP_TRACE_ENDPOINT+ if not trace_endpoint:+ trace_endpoint = dify_config.OTLP_BASE_ENDPOINT + "/v1/traces"exporter = HTTPSpanExporter(- endpoint=dify_config.OTLP_BASE_ENDPOINT + "/v1/traces",- headers={"Authorization": f"Bearer {dify_config.OTLP_API_KEY}"},+ endpoint=trace_endpoint,+ headers=headers,)++ metric_endpoint = dify_config.OTLP_METRIC_ENDPOINT+ if not metric_endpoint:+ metric_endpoint = dify_config.OTLP_BASE_ENDPOINT + "/v1/traces"metric_exporter = HTTPMetricExporter(- endpoint=dify_config.OTLP_BASE_ENDPOINT + "/v1/metrics",- headers={"Authorization": f"Bearer {dify_config.OTLP_API_KEY}"},+ endpoint=metric_endpoint,+ headers=headers,)else:exporter = ConsoleSpanExporter()diff --git a/docker/.env.example b/docker/.env.exampleindex e08a81e49e9..94f3766b2ea 100644--- a/docker/.env.example+++ b/docker/.env.example@@ -1139,6 +1139,8 @@ PLUGIN_VOLCENGINE_TOS_REGION=# OTLP Collector Configuration# ------------------------------ENABLE_OTEL=false+OTLP_TRACE_ENDPOINT=+OTLP_METRIC_ENDPOINT=OTLP_BASE_ENDPOINT=http://localhost:4318OTLP_API_KEY=OTEL_EXPORTER_OTLP_PROTOCOL=diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yamlindex 73e061e7700..5f0d2b1f874 100644--- a/docker/docker-compose.yaml+++ b/docker/docker-compose.yaml@@ -506,6 +506,8 @@ x-shared-env: &shared-api-worker-envPLUGIN_VOLCENGINE_TOS_SECRET_KEY: ${PLUGIN_VOLCENGINE_TOS_SECRET_KEY:-}PLUGIN_VOLCENGINE_TOS_REGION: ${PLUGIN_VOLCENGINE_TOS_REGION:-}ENABLE_OTEL: ${ENABLE_OTEL:-false}+ OTLP_TRACE_ENDPOINT: ${OTLP_TRACE_ENDPOINT:-}+ OTLP_METRIC_ENDPOINT: ${OTLP_METRIC_ENDPOINT:-}OTLP_BASE_ENDPOINT: ${OTLP_BASE_ENDPOINT:-http://localhost:4318}OTLP_API_KEY: ${OTLP_API_KEY:-}OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-}