Skip to content

Commit ce897b9

Browse files
committed
Annotate root spans with operation name
1 parent d24dd3f commit ce897b9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ def on_trace_start(self, trace: Trace) -> None:
12731273
attributes = {
12741274
GEN_AI_PROVIDER_NAME: self.system_name,
12751275
GEN_AI_SYSTEM_KEY: self.system_name,
1276+
GEN_AI_OPERATION_NAME: GenAIOperationName.INVOKE_AGENT,
12761277
}
12771278
# Legacy emission removed
12781279

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/test_z_span_processor_unit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@ def test_span_lifecycle_and_shutdown(processor_setup):
499499
statuses["linger"].status_code is StatusCode.ERROR
500500
and statuses["linger"].description == "Application shutdown"
501501
)
502+
workflow_span = next(span for span in finished if span.name == "workflow")
503+
assert (
504+
workflow_span.attributes[sp.GEN_AI_OPERATION_NAME]
505+
== sp.GenAIOperationName.INVOKE_AGENT
506+
)
502507

503508

504509
def test_chat_span_renamed_with_model(processor_setup):

0 commit comments

Comments
 (0)