Skip to content

Commit fc9af7f

Browse files
committed
update attributes
1 parent 3c30699 commit fc9af7f

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33

44
def common_gen_ai_system(**kwargs) -> str:
5-
return "veadk"
5+
"""This field will be parsed as `model_provider` in Volcengine CozeLoop platform."""
6+
model_provider = kwargs.get("model_provider")
7+
return model_provider or "<unknown_model_provider>"
68

79

810
def common_gen_ai_system_version(**kwargs) -> str:
@@ -33,7 +35,10 @@ def common_gen_ai_session_id(**kwargs) -> str:
3335
"gen_ai.system": common_gen_ai_system,
3436
"gen_ai.system.version": common_gen_ai_system_version,
3537
"gen_ai.agent.name": common_gen_ai_agent_name,
36-
"gen_ai.app.name": common_gen_ai_app_name,
37-
"gen_ai.user.id": common_gen_ai_user_id,
38-
"gen_ai.session.id": common_gen_ai_session_id,
38+
"gen_ai.app.name": common_gen_ai_app_name, # APMPlus required
39+
"gen_ai.user.id": common_gen_ai_user_id, # APMPlus required
40+
"gen_ai.session.id": common_gen_ai_session_id, # APMPlus required
41+
"app.name": common_gen_ai_app_name, # CozeLoop required
42+
"user.id": common_gen_ai_user_id, # CozeLoop required
43+
"session.id": common_gen_ai_session_id, # CozeLoop required
3944
}

veadk/tracing/telemetry/telemetry.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def set_common_attributes(current_span: _Span, **kwargs) -> None:
3737

3838
common_attributes = ATTRIBUTES.get("common", {})
3939
for span in spans_in_current_trace:
40+
if span.name.startswith("invocation"):
41+
span.set_attribute("gen_ai.operation.name", "chain")
42+
elif span.name.startswith("agent_run"):
43+
span.set_attribute("gen_ai.operation.name", "agent")
4044
for attr_name, attr_extractor in common_attributes.items():
4145
value = attr_extractor(**kwargs)
4246
span.set_attribute(attr_name, value)
@@ -65,12 +69,20 @@ def trace_call_llm(
6569
) -> None:
6670
span = trace.get_current_span()
6771

72+
from veadk.agent import Agent
73+
6874
set_common_attributes(
6975
current_span=span, # type: ignore
7076
agent_name=invocation_context.agent.name,
71-
app_name=invocation_context.app_name,
7277
user_id=invocation_context.user_id,
78+
app_name=invocation_context.app_name,
7379
session_id=invocation_context.session.id,
80+
model_provider=invocation_context.agent.model_provider
81+
if isinstance(invocation_context.agent, Agent)
82+
else "",
83+
model_name=invocation_context.agent.model_name
84+
if isinstance(invocation_context.agent, Agent)
85+
else "",
7486
)
7587

7688
llm_attributes_mapping = ATTRIBUTES.get("llm", {})

0 commit comments

Comments
 (0)