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.

add gen_ai feature tag for aliyun_trace (#29084)

heysztb927ff9fcf89
diff --git a/api/core/ops/aliyun_trace/aliyun_trace.py b/api/core/ops/aliyun_trace/aliyun_trace.py
index a7d8576d8d0..d6bd4d20158 100644
--- a/api/core/ops/aliyun_trace/aliyun_trace.py
+++ b/api/core/ops/aliyun_trace/aliyun_trace.py
@@ -296,7 +296,7 @@ class AliyunDataTrace(BaseTraceInstance):
node_span = self.build_workflow_task_span(trace_info, node_execution, trace_metadata)
return node_span
except Exception as e:
- logger.debug("Error occurred in build_workflow_node_span: %s", e, exc_info=True)
+ logger.warning("Error occurred in build_workflow_node_span: %s", e, exc_info=True)
return None
def build_workflow_task_span(
diff --git a/api/core/ops/aliyun_trace/data_exporter/traceclient.py b/api/core/ops/aliyun_trace/data_exporter/traceclient.py
index 5aa9fb66895..d3324f8f82f 100644
--- a/api/core/ops/aliyun_trace/data_exporter/traceclient.py
+++ b/api/core/ops/aliyun_trace/data_exporter/traceclient.py
@@ -21,6 +21,7 @@ from opentelemetry.trace import Link, SpanContext, TraceFlags
from configs import dify_config
from core.ops.aliyun_trace.entities.aliyun_trace_entity import SpanData
+from core.ops.aliyun_trace.entities.semconv import ACS_ARMS_SERVICE_FEATURE
INVALID_SPAN_ID: Final[int] = 0x0000000000000000
INVALID_TRACE_ID: Final[int] = 0x00000000000000000000000000000000
@@ -48,6 +49,7 @@ class TraceClient:
ResourceAttributes.SERVICE_VERSION: f"dify-{dify_config.project.version}-{dify_config.COMMIT_SHA}",
ResourceAttributes.DEPLOYMENT_ENVIRONMENT: f"{dify_config.DEPLOY_ENV}-{dify_config.EDITION}",
ResourceAttributes.HOST_NAME: socket.gethostname(),
+ ACS_ARMS_SERVICE_FEATURE: "genai_app",
}
)
self.span_builder = SpanBuilder(self.resource)
@@ -75,10 +77,10 @@ class TraceClient:
if response.status_code == 405:
return True
else:
- logger.debug("AliyunTrace API check failed: Unexpected status code: %s", response.status_code)
+ logger.warning("AliyunTrace API check failed: Unexpected status code: %s", response.status_code)
return False
except httpx.RequestError as e:
- logger.debug("AliyunTrace API check failed: %s", str(e))
+ logger.warning("AliyunTrace API check failed: %s", str(e))
raise ValueError(f"AliyunTrace API check failed: {str(e)}")
def get_project_url(self) -> str:
@@ -116,7 +118,7 @@ class TraceClient:
try:
self.exporter.export(spans_to_export)
except Exception as e:
- logger.debug("Error exporting spans: %s", e)
+ logger.warning("Error exporting spans: %s", e)
def shutdown(self) -> None:
with self.condition:
diff --git a/api/core/ops/aliyun_trace/entities/semconv.py b/api/core/ops/aliyun_trace/entities/semconv.py
index c823fcab8af..aff893816c8 100644
--- a/api/core/ops/aliyun_trace/entities/semconv.py
+++ b/api/core/ops/aliyun_trace/entities/semconv.py
@@ -1,6 +1,8 @@
from enum import StrEnum
from typing import Final
+ACS_ARMS_SERVICE_FEATURE: Final[str] = "acs.arms.service.feature"
+
# Public attributes
GEN_AI_SESSION_ID: Final[str] = "gen_ai.session.id"
GEN_AI_USER_ID: Final[str] = "gen_ai.user.id"