Skip to content

Commit d2bd619

Browse files
committed
Use semconv provider attribute
1 parent e166384 commit d2bd619

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-agents/src/opentelemetry/instrumentation/openai_agents/span_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TracingProcessor: # type: ignore[misc]
5151
}
5252
)
5353

54-
_GEN_AI_PROVIDER_NAME = "gen_ai.provider.name"
54+
_GEN_AI_PROVIDER_NAME = GenAI.GEN_AI_PROVIDER_NAME
5555

5656

5757
def _parse_iso8601(timestamp: str | None) -> int | None:

instrumentation-genai/opentelemetry-instrumentation-openai-agents/tests/test_tracer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
)
4646
from opentelemetry.trace import SpanKind # noqa: E402
4747

48+
GEN_AI_PROVIDER_NAME = GenAI.GEN_AI_PROVIDER_NAME
49+
4850

4951
def _instrument_with_provider(**instrument_kwargs):
5052
set_trace_processors([])
@@ -79,7 +81,7 @@ def test_generation_span_creates_client_span():
7981
span for span in spans if span.kind is SpanKind.CLIENT
8082
)
8183

82-
assert client_span.attributes["gen_ai.provider.name"] == "openai"
84+
assert client_span.attributes[GEN_AI_PROVIDER_NAME] == "openai"
8385
assert client_span.attributes[GenAI.GEN_AI_OPERATION_NAME] == "chat"
8486
assert (
8587
client_span.attributes[GenAI.GEN_AI_REQUEST_MODEL] == "gpt-4o-mini"
@@ -147,7 +149,7 @@ def test_function_span_records_tool_attributes():
147149
)
148150
assert tool_span.attributes[GenAI.GEN_AI_TOOL_NAME] == "fetch_weather"
149151
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"
151153
finally:
152154
instrumentor.uninstrument()
153155
exporter.clear()
@@ -177,7 +179,7 @@ def test_agent_create_span_records_attributes():
177179

178180
assert create_span.kind is SpanKind.CLIENT
179181
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"
181183
assert create_span.attributes[GenAI.GEN_AI_AGENT_NAME] == "support_bot"
182184
assert (
183185
create_span.attributes[GenAI.GEN_AI_AGENT_DESCRIPTION]
@@ -251,7 +253,7 @@ def __init__(self) -> None:
251253

252254
assert response.kind is SpanKind.CLIENT
253255
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"
255257
assert response.attributes[GenAI.GEN_AI_RESPONSE_ID] == "resp-123"
256258
assert (
257259
response.attributes[GenAI.GEN_AI_RESPONSE_MODEL] == "gpt-4o-mini"

0 commit comments

Comments
 (0)