1010from opentelemetry .semconv ._incubating .attributes import (
1111 gen_ai_attributes as GenAI ,
1212)
13+ from opentelemetry .trace import SpanKind
1314from opentelemetry .util .genai .handler import TelemetryHandler
15+ from opentelemetry .util .genai .span_utils import (
16+ _GEN_AI_AGENT_DESCRIPTION ,
17+ _GEN_AI_AGENT_ID ,
18+ _GEN_AI_AGENT_NAME ,
19+ _GEN_AI_AGENT_VERSION ,
20+ )
1421from opentelemetry .util .genai .types import (
1522 AgentCreation ,
1623 Error ,
@@ -48,9 +55,7 @@ def test_start_stop_create_agent(self) -> None:
4855 self .assertEqual (
4956 span .attributes [GenAI .GEN_AI_OPERATION_NAME ], "create_agent"
5057 )
51- self .assertEqual (
52- span .attributes [GenAI .GEN_AI_AGENT_NAME ], "New Agent"
53- )
58+ self .assertEqual (span .attributes [_GEN_AI_AGENT_NAME ], "New Agent" )
5459
5560 def test_create_agent_span_kind_is_client (self ) -> None :
5661 handler = self ._make_handler ()
@@ -59,8 +64,6 @@ def test_create_agent_span_kind_is_client(self) -> None:
5964 handler .stop_create_agent (creation )
6065
6166 spans = self .span_exporter .get_finished_spans ()
62- from opentelemetry .trace import SpanKind
63-
6467 self .assertEqual (spans [0 ].kind , SpanKind .CLIENT )
6568
6669 def test_create_agent_with_all_base_attributes (self ) -> None :
@@ -82,12 +85,10 @@ def test_create_agent_with_all_base_attributes(self) -> None:
8285 self .assertEqual (len (spans ), 1 )
8386 attrs = spans [0 ].attributes
8487 self .assertEqual (attrs [GenAI .GEN_AI_OPERATION_NAME ], "create_agent" )
85- self .assertEqual (attrs [GenAI .GEN_AI_AGENT_NAME ], "Full Agent" )
86- self .assertEqual (attrs [GenAI .GEN_AI_AGENT_ID ], "agent-123" )
87- self .assertEqual (
88- attrs [GenAI .GEN_AI_AGENT_DESCRIPTION ], "A test agent"
89- )
90- self .assertEqual (attrs [GenAI .GEN_AI_AGENT_VERSION ], "1.0.0" )
88+ self .assertEqual (attrs [_GEN_AI_AGENT_NAME ], "Full Agent" )
89+ self .assertEqual (attrs [_GEN_AI_AGENT_ID ], "agent-123" )
90+ self .assertEqual (attrs [_GEN_AI_AGENT_DESCRIPTION ], "A test agent" )
91+ self .assertEqual (attrs [_GEN_AI_AGENT_VERSION ], "1.0.0" )
9192 self .assertEqual (attrs [GenAI .GEN_AI_PROVIDER_NAME ], "openai" )
9293 self .assertEqual (attrs [GenAI .GEN_AI_REQUEST_MODEL ], "gpt-4" )
9394
0 commit comments