-
Notifications
You must be signed in to change notification settings - Fork 23
Add gen_ai.caller.agent.type attribute for A2A tracing #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Nikhil Navakiran (nikhilNava)
merged 4 commits into
main
from
copilot/implement-nodejs-features-in-python
Feb 6, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5cc3a69
Initial plan
Copilot e2278bf
Add gen_ai.caller.agent.type attribute support (matching Node.js PR #…
Copilot e59be4d
Improve test assertions for agent type attribute per code review feed…
Copilot 9395d68
Merge branch 'main' into copilot/implement-nodejs-features-in-python
nikhilNava File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,14 @@ | |
| ) | ||
| from microsoft_agents_a365.observability.core.config import _telemetry_manager | ||
| from microsoft_agents_a365.observability.core.constants import ( | ||
| GEN_AI_CALLER_AGENT_TYPE_KEY, | ||
| GEN_AI_CALLER_AGENT_USER_CLIENT_IP, | ||
| GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, | ||
| GEN_AI_EXECUTION_SOURCE_NAME_KEY, | ||
| GEN_AI_EXECUTION_TYPE_KEY, | ||
| GEN_AI_INPUT_MESSAGES_KEY, | ||
| ) | ||
| from microsoft_agents_a365.observability.core.models.agent_type import AgentType | ||
| from microsoft_agents_a365.observability.core.models.caller_details import CallerDetails | ||
| from microsoft_agents_a365.observability.core.opentelemetry_scope import OpenTelemetryScope | ||
| from opentelemetry.sdk.trace.export import SimpleSpanProcessor | ||
|
|
@@ -94,6 +96,7 @@ def setUpClass(cls): | |
| agent_upn="[email protected]", | ||
| tenant_id="tenant-789", | ||
| agent_client_ip="192.168.1.100", | ||
| agent_type=AgentType.DECLARATIVE_AGENT, | ||
| ) | ||
|
|
||
| def setUp(self): | ||
|
|
@@ -232,6 +235,39 @@ def test_caller_agent_client_ip_in_scope(self): | |
| span_attributes[GEN_AI_CALLER_AGENT_USER_CLIENT_IP], "192.168.1.100" | ||
| ) | ||
|
|
||
| def test_caller_agent_type_in_scope(self): | ||
| """Test that caller agent type is properly set when creating InvokeAgentScope.""" | ||
| # Set up tracer to capture spans | ||
| span_exporter = InMemorySpanExporter() | ||
| tracer_provider = get_tracer_provider() | ||
| tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter)) | ||
|
|
||
| # Create scope with caller agent details that include agent_type | ||
| scope = InvokeAgentScope.start( | ||
| invoke_agent_details=self.invoke_details, | ||
| tenant_details=self.tenant_details, | ||
| caller_agent_details=self.caller_agent_details, | ||
| ) | ||
|
|
||
| # Verify scope was created and caller agent details contain the expected type | ||
| self.assertIsNotNone(scope) | ||
| self.assertEqual(self.caller_agent_details.agent_type, AgentType.DECLARATIVE_AGENT) | ||
| scope.dispose() | ||
|
|
||
| # Verify the agent type is set as a span attribute | ||
| finished_spans = span_exporter.get_finished_spans() | ||
| self.assertTrue(len(finished_spans) > 0, "Expected at least one span to be created") | ||
|
|
||
| span = finished_spans[-1] | ||
| span_attributes = getattr(span, "attributes", {}) or {} | ||
|
|
||
| # Verify the caller agent type is set as a span attribute | ||
| self.assertIn(GEN_AI_CALLER_AGENT_TYPE_KEY, span_attributes) | ||
| self.assertEqual( | ||
| span_attributes[GEN_AI_CALLER_AGENT_TYPE_KEY], | ||
| AgentType.DECLARATIVE_AGENT.value, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run pytest only on the current file | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.