Skip to content

armgit / dify

Public Imported from GitHub
0

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.

hotfix(otel): replace hardcoded span attributes with shared constants (#29227)

NeatGuyCodingb365bffd0209
diff --git a/api/extensions/otel/runtime.py b/api/extensions/otel/runtime.py
index f8ed330cf6d..16f5ccf488e 100644
--- a/api/extensions/otel/runtime.py
+++ b/api/extensions/otel/runtime.py
@@ -11,6 +11,7 @@ from opentelemetry.propagators.composite import CompositePropagator
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
from configs import dify_config
+from extensions.otel.semconv import DifySpanAttributes, GenAIAttributes
from libs.helper import extract_tenant_id
from models import Account, EndUser
@@ -51,8 +52,8 @@ def on_user_loaded(_sender, user: Union["Account", "EndUser"]):
if not tenant_id:
return
if current_span:
- current_span.set_attribute("service.tenant.id", tenant_id)
- current_span.set_attribute("service.user.id", user.id)
+ current_span.set_attribute(DifySpanAttributes.TENANT_ID, tenant_id)
+ current_span.set_attribute(GenAIAttributes.USER_ID, user.id)
except Exception:
logger.exception("Error setting tenant and user attributes")
pass