|
| 1 | +Feature: SDK telemetry instrumentation |
| 2 | + |
| 3 | + Background: |
| 4 | + Given auto_instrument is initialized |
| 5 | + |
| 6 | + Scenario: invoke_agent_span emits a span with required GenAI attributes |
| 7 | + When I invoke an agent with provider "test" and name "bot" and conversation_id "c1" |
| 8 | + Then a span named "invoke_agent bot" is recorded |
| 9 | + And the span has attribute "gen_ai.operation.name" equal to "invoke_agent" |
| 10 | + And the span has attribute "gen_ai.provider.name" equal to "test" |
| 11 | + And the span has attribute "gen_ai.agent.name" equal to "bot" |
| 12 | + And the span has attribute "gen_ai.conversation.id" equal to "c1" |
| 13 | + |
| 14 | + Scenario: invoke_agent_span records errors |
| 15 | + When I invoke an agent that raises an exception |
| 16 | + Then the span status is ERROR |
| 17 | + And the span has an exception event |
| 18 | + |
| 19 | + Scenario: spans carry SDK resource attributes |
| 20 | + When I invoke an agent with provider "test" and name "sdk-resource-test" |
| 21 | + Then a span named "invoke_agent sdk-resource-test" is recorded |
| 22 | + And the span resource has attribute "sap.cloud_sdk.name" equal to "SAP Cloud SDK for Python" |
| 23 | + And the span resource has attribute "sap.cloud_sdk.language" equal to "python" |
| 24 | + And the span resource has attribute "sap.cloud_sdk.version" set |
| 25 | + |
| 26 | + # Real LLM call scenarios — require AI Core credentials |
| 27 | + |
| 28 | + @aicore |
| 29 | + Scenario: invoke_agent_span wrapping a real LLM call produces a complete trace |
| 30 | + Given AI Core is configured via set_aicore_config |
| 31 | + When I invoke an agent wrapping a direct LLM call |
| 32 | + Then a span named "invoke_agent llm-agent" is recorded |
| 33 | + And a span with operation "chat" is a child of "invoke_agent llm-agent" |
| 34 | + And that span has attribute "gen_ai.usage.input_tokens" set |
| 35 | + And that span has attribute "gen_ai.usage.output_tokens" set |
| 36 | + And the span "invoke_agent llm-agent" has resource attribute "sap.cloud_sdk.name" equal to "SAP Cloud SDK for Python" |
| 37 | + And the span "invoke_agent llm-agent" has resource attribute "sap.cloud_sdk.language" equal to "python" |
| 38 | + And the span "invoke_agent llm-agent" has resource attribute "sap.cloud_sdk.version" set |
| 39 | + |
| 40 | + @aicore |
| 41 | + Scenario: invoke_agent_span wrapping LLM call then tool produces a full agentic trace |
| 42 | + Given AI Core is configured via set_aicore_config |
| 43 | + When I invoke an agent that calls an LLM then executes a tool |
| 44 | + Then a span named "invoke_agent agent-with-tool" is recorded |
| 45 | + And a span with operation "chat" is a child of "invoke_agent agent-with-tool" |
| 46 | + And that span has attribute "gen_ai.usage.input_tokens" set |
| 47 | + And the span "execute_tool search" is a child of "invoke_agent agent-with-tool" |
| 48 | + And the span "execute_tool search" has attribute "gen_ai.tool.name" equal to "search" |
| 49 | + |
| 50 | + @aicore |
| 51 | + Scenario: propagate=True flows invoke_agent attributes to nested LLM span |
| 52 | + Given AI Core is configured via set_aicore_config |
| 53 | + When I invoke an agent with propagate=True wrapping a real LLM call |
| 54 | + Then a span with operation "chat" is a child of "invoke_agent propagate-llm-agent" |
| 55 | + And that span has attribute "custom.session" equal to "s42" |
| 56 | + And that span has attribute "gen_ai.usage.input_tokens" set |
| 57 | + |
| 58 | + @aicore |
| 59 | + Scenario: propagate=False does not leak invoke_agent attributes to nested LLM span |
| 60 | + Given AI Core is configured via set_aicore_config |
| 61 | + When I invoke an agent with propagate=False wrapping a real LLM call |
| 62 | + Then a span with operation "chat" is a child of "invoke_agent no-propagate-llm-agent" |
| 63 | + And that span does not have attribute "custom.session" |
| 64 | + |
| 65 | + @aicore |
| 66 | + Scenario: baggage attributes propagate to Traceloop-instrumented LLM spans |
| 67 | + Given baggage key "sap.extension.capabilityId" is set to "cap-traceloop" |
| 68 | + And AI Core is configured via set_aicore_config |
| 69 | + When I invoke an agent wrapping a direct LLM call with baggage |
| 70 | + Then a span with operation "chat" is a child of "invoke_agent baggage-llm-agent" |
| 71 | + And that span has attribute "sap.extension.capabilityId" equal to "cap-traceloop" |
| 72 | + |
| 73 | + @aicore |
| 74 | + Scenario: LangGraph agent run produces an invoke_agent span with LangChain child spans |
| 75 | + Given AI Core is configured via set_aicore_config |
| 76 | + When I run a LangGraph agent with provider "sap-aicore" and name "test-agent" |
| 77 | + Then a span named "invoke_agent test-agent" is recorded |
| 78 | + And at least one descendant span with attribute "gen_ai.operation.name" equal to "chat" is recorded |
| 79 | + And at least one descendant span has attribute "gen_ai.request.model" set |
| 80 | + And at least one descendant span has attribute "gen_ai.usage.input_tokens" set |
| 81 | + And at least one descendant span has attribute "gen_ai.usage.output_tokens" set |
| 82 | + And no descendant span has an attribute starting with "llm.usage." |
| 83 | + And no descendant span has attribute "traceloop.association.properties.ls_model_name" |
| 84 | + And no descendant span has attribute "traceloop.association.properties.ls_provider" |
0 commit comments