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 HTTPX client instrumentation for OpenTelemetry (#26651)
耐小心89821d66bb84
diff --git a/api/extensions/ext_otel.py b/api/extensions/ext_otel.pyindex b0059693e29..19c6e68c6bb 100644--- a/api/extensions/ext_otel.py+++ b/api/extensions/ext_otel.py@@ -136,6 +136,7 @@ def init_app(app: DifyApp):from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter as HTTPSpanExporterfrom opentelemetry.instrumentation.celery import CeleryInstrumentorfrom opentelemetry.instrumentation.flask import FlaskInstrumentor+ from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentorfrom opentelemetry.instrumentation.redis import RedisInstrumentorfrom opentelemetry.instrumentation.requests import RequestsInstrumentorfrom opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor@@ -238,6 +239,7 @@ def init_app(app: DifyApp):init_sqlalchemy_instrumentor(app)RedisInstrumentor().instrument()RequestsInstrumentor().instrument()+ HTTPXClientInstrumentor().instrument()atexit.register(shutdown_tracer)diff --git a/api/pyproject.toml b/api/pyproject.tomlindex 96ca20c31ca..1f51d600988 100644--- a/api/pyproject.toml+++ b/api/pyproject.toml@@ -46,6 +46,7 @@ dependencies = ["opentelemetry-instrumentation==0.48b0","opentelemetry-instrumentation-celery==0.48b0","opentelemetry-instrumentation-flask==0.48b0",+ "opentelemetry-instrumentation-httpx==0.48b0","opentelemetry-instrumentation-redis==0.48b0","opentelemetry-instrumentation-requests==0.48b0","opentelemetry-instrumentation-sqlalchemy==0.48b0",diff --git a/api/pyrightconfig.json b/api/pyrightconfig.jsonindex c733059331e..b9b496b77ec 100644--- a/api/pyrightconfig.json+++ b/api/pyrightconfig.json@@ -12,6 +12,7 @@"flask_login","opentelemetry.instrumentation.celery","opentelemetry.instrumentation.flask",+ "opentelemetry.instrumentation.httpx","opentelemetry.instrumentation.requests","opentelemetry.instrumentation.sqlalchemy","opentelemetry.instrumentation.redis"diff --git a/api/uv.lock b/api/uv.lockindex 804c7abaa50..21d1f17bad3 100644--- a/api/uv.lock+++ b/api/uv.lock@@ -1323,6 +1323,7 @@ dependencies = [{ name = "opentelemetry-instrumentation" },{ name = "opentelemetry-instrumentation-celery" },{ name = "opentelemetry-instrumentation-flask" },+ { name = "opentelemetry-instrumentation-httpx" },{ name = "opentelemetry-instrumentation-redis" },{ name = "opentelemetry-instrumentation-requests" },{ name = "opentelemetry-instrumentation-sqlalchemy" },@@ -1513,6 +1514,7 @@ requires-dist = [{ name = "opentelemetry-instrumentation", specifier = "==0.48b0" },{ name = "opentelemetry-instrumentation-celery", specifier = "==0.48b0" },{ name = "opentelemetry-instrumentation-flask", specifier = "==0.48b0" },+ { name = "opentelemetry-instrumentation-httpx", specifier = "==0.48b0" },{ name = "opentelemetry-instrumentation-redis", specifier = "==0.48b0" },{ name = "opentelemetry-instrumentation-requests", specifier = "==0.48b0" },{ name = "opentelemetry-instrumentation-sqlalchemy", specifier = "==0.48b0" },@@ -3878,6 +3880,21 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/78/3d/fcde4f8f0bf9fa1ee73a12304fa538076fb83fe0a2ae966ab0f0b7da5109/opentelemetry_instrumentation_flask-0.48b0-py3-none-any.whl", hash = "sha256:26b045420b9d76e85493b1c23fcf27517972423480dc6cf78fd6924248ba5808", size = 14588, upload-time = "2024-08-28T21:26:58.504Z" },]+[[package]]+name = "opentelemetry-instrumentation-httpx"+version = "0.48b0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "opentelemetry-api" },+ { name = "opentelemetry-instrumentation" },+ { name = "opentelemetry-semantic-conventions" },+ { name = "opentelemetry-util-http" },+]+sdist = { url = "https://files.pythonhosted.org/packages/d3/d9/c65d818607c16d1b7ea8d2de6111c6cecadf8d2fd38c1885a72733a7c6d3/opentelemetry_instrumentation_httpx-0.48b0.tar.gz", hash = "sha256:ee977479e10398931921fb995ac27ccdeea2e14e392cb27ef012fc549089b60a", size = 16931, upload-time = "2024-08-28T21:28:03.794Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/c2/fe/f2daa9d6d988c093b8c7b1d35df675761a8ece0b600b035dc04982746c9d/opentelemetry_instrumentation_httpx-0.48b0-py3-none-any.whl", hash = "sha256:d94f9d612c82d09fe22944d1904a30a464c19bea2ba76be656c99a28ad8be8e5", size = 13900, upload-time = "2024-08-28T21:27:01.566Z" },+]+[[package]]name = "opentelemetry-instrumentation-redis"version = "0.48b0"