|
45 | 45 | ) |
46 | 46 | from opentelemetry.trace import SpanKind # noqa: E402 |
47 | 47 |
|
| 48 | +GEN_AI_PROVIDER_NAME = GenAI.GEN_AI_PROVIDER_NAME |
| 49 | + |
48 | 50 |
|
49 | 51 | def _instrument_with_provider(**instrument_kwargs): |
50 | 52 | set_trace_processors([]) |
@@ -79,7 +81,7 @@ def test_generation_span_creates_client_span(): |
79 | 81 | span for span in spans if span.kind is SpanKind.CLIENT |
80 | 82 | ) |
81 | 83 |
|
82 | | - assert client_span.attributes["gen_ai.provider.name"] == "openai" |
| 84 | + assert client_span.attributes[GEN_AI_PROVIDER_NAME] == "openai" |
83 | 85 | assert client_span.attributes[GenAI.GEN_AI_OPERATION_NAME] == "chat" |
84 | 86 | assert ( |
85 | 87 | client_span.attributes[GenAI.GEN_AI_REQUEST_MODEL] == "gpt-4o-mini" |
@@ -147,7 +149,7 @@ def test_function_span_records_tool_attributes(): |
147 | 149 | ) |
148 | 150 | assert tool_span.attributes[GenAI.GEN_AI_TOOL_NAME] == "fetch_weather" |
149 | 151 | assert tool_span.attributes[GenAI.GEN_AI_TOOL_TYPE] == "function" |
150 | | - assert tool_span.attributes["gen_ai.provider.name"] == "openai" |
| 152 | + assert tool_span.attributes[GEN_AI_PROVIDER_NAME] == "openai" |
151 | 153 | finally: |
152 | 154 | instrumentor.uninstrument() |
153 | 155 | exporter.clear() |
@@ -177,7 +179,7 @@ def test_agent_create_span_records_attributes(): |
177 | 179 |
|
178 | 180 | assert create_span.kind is SpanKind.CLIENT |
179 | 181 | assert create_span.name == "create_agent support_bot" |
180 | | - assert create_span.attributes["gen_ai.provider.name"] == "openai" |
| 182 | + assert create_span.attributes[GEN_AI_PROVIDER_NAME] == "openai" |
181 | 183 | assert create_span.attributes[GenAI.GEN_AI_AGENT_NAME] == "support_bot" |
182 | 184 | assert ( |
183 | 185 | create_span.attributes[GenAI.GEN_AI_AGENT_DESCRIPTION] |
@@ -251,7 +253,7 @@ def __init__(self) -> None: |
251 | 253 |
|
252 | 254 | assert response.kind is SpanKind.CLIENT |
253 | 255 | assert response.name == "chat gpt-4o-mini" |
254 | | - assert response.attributes["gen_ai.provider.name"] == "openai" |
| 256 | + assert response.attributes[GEN_AI_PROVIDER_NAME] == "openai" |
255 | 257 | assert response.attributes[GenAI.GEN_AI_RESPONSE_ID] == "resp-123" |
256 | 258 | assert ( |
257 | 259 | response.attributes[GenAI.GEN_AI_RESPONSE_MODEL] == "gpt-4o-mini" |
|
0 commit comments