[Observability]Add agent frame observation extension#12
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new Python library for Agent Framework observability and tracing extensions for Microsoft Agents A365. The library provides OpenTelemetry-based instrumentation capabilities specifically for the Agent Framework, including custom span processing for tool execution operations.
- Establishes package structure with dynamic versioning using PEP 440 compliant timestamp-based versions
- Implements Agent Framework instrumentation using OpenTelemetry BaseInstrumentor
- Adds custom span processor to enrich telemetry data for tool execution operations
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| setup.py | Implements dynamic versioning with UTC timestamp-based version numbers, supporting CI/CD override via environment variable |
| pyproject.toml | Defines package metadata, dependencies, and build configuration for the observability extensions library |
| trace_instrumentor.py | Provides AgentFrameworkInstrumentor class that registers custom span processor with OpenTelemetry tracer provider |
| span_processor.py | Implements custom span processor to enrich tool execution spans with event content attributes |
| init.py | Empty module initialization file with copyright header |
Comments suppressed due to low confidence (2)
libraries/microsoft-agents-a365-observability-extensions-agentframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py:8
- Import of 'InferenceOperationType' is not used.
from microsoft_agents_a365.observability.core.inference_operation_type import InferenceOperationType
libraries/microsoft-agents-a365-observability-extensions-agentframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py:9
- Import of 'extract_model_name' is not used.
from microsoft_agents_a365.observability.core.wrappers.utils import extract_model_name
libraries/microsoft-agents-a365-observability-extensions-agentframework/setup.py
Outdated
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/pyproject.toml
Outdated
Show resolved
Hide resolved
...ramework/microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...ons-agentframework/microsoft_agents_a365/observability/extensions/agentframework/__init__.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
nikhilNava
left a comment
There was a problem hiding this comment.
Can you add integration tests instead of sample app?
please refer to https://github.com/microsoft/Agent365-python/blob/main/tests/integration/test_openai_trace_processor.py
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/setup.py
Outdated
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/setup.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
libraries/microsoft-agents-a365-observability-extensions-agentframework/setup.py:1
- Copyright header format is inconsistent with other packages in the repository. All other similar packages use '# Copyright (c) Microsoft. All rights reserved.' format. Please update to match the established pattern for consistency.
# Copyright (c) Microsoft Corporation.
libraries/microsoft-agents-a365-observability-extensions-agentframework/setup.py:1
- Version management implementation differs from other packages in the repository. All similar packages (e.g., observability-core, observability-extensions-langchain) use a
build_version()function that generates date-based versions with UTC timestamps and checks the 'A365_SDK_VERSION' environment variable. This package uses a simpler approach with 'AGENT365_PYTHON_SDK_PACKAGE_VERSION'. Please align with the established pattern for consistency.
# Copyright (c) Microsoft Corporation.
...ramework/microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Outdated
Show resolved
Hide resolved
...ons-agentframework/microsoft_agents_a365/observability/extensions/agentframework/__init__.py
Outdated
Show resolved
Hide resolved
...ramework/microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py
Outdated
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Show resolved
Hide resolved
...s/observability/extensions/agentframework/integration/test_agentframework_trace_processor.py
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/pyproject.toml
Outdated
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/pyproject.toml
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Show resolved
Hide resolved
|
Would you update "microsoft-agents-a365-runtime >= 0.1.0" in pyproject.toml file of There is some package versioning conflict. Please get this reviewed from Rahul as well. |
mrunalhirve128
left a comment
There was a problem hiding this comment.
Check my previous comment
nikhilNava
left a comment
There was a problem hiding this comment.
Does the inference or invoke agent spans track input or output messages?
...ramework/microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py
Outdated
Show resolved
Hide resolved
libraries/microsoft-agents-a365-observability-extensions-agentframework/README.md
Show resolved
Hide resolved
...entframework/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
Show resolved
Hide resolved
...s/observability/extensions/agentframework/integration/test_agentframework_trace_processor.py
Show resolved
Hide resolved
microsoft-agents-a365-runtime >= 0.1.0 is already updated in there, from other merged branch
examples:
1.
{
"name": "chat gpt-4o-mini",
"context": {
"trace_id": "0x391f1d4e13c285bce547e03a4eb6e019",
"span_id": "0x2c2d04e20edb73b1",
"trace_state": "[]"
},
"kind": "SpanKind.INTERNAL",
"parent_id": "0x0089408c54e3007d",
"start_time": "2025-11-05T04:03:02.720236Z",
"end_time": "2025-11-05T04:03:13.922298Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"gen_ai.operation.name": "chat",
"gen_ai.request.choice.count": 1,
"gen_ai.provider.name": "azure.ai.openai",
"gen_ai.request.model": "gpt-4o-mini",
"server.address": "https://a365-hw-openai-sentinel.openai.azure.com/openai/deployments/gpt-4o-mini/",
"gen_ai.response.id": "chatcmpl-CYP1bPQBRWECwF5ush924IBTgC3gj",
"gen_ai.response.finish_reasons": "["stop"]",
"gen_ai.response.model": "gpt-4o-mini-2024-07-18",
"gen_ai.usage.input_tokens": 25,
"gen_ai.usage.output_tokens": 564,
"gen_ai.client.operation.duration": 11.20091659999889
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.38.0",
"service.namespace": "agent365-tests",
"service.name": "integration-test-service"
},
"schema_url": ""
}
}
2.
{
"name": "invoke_agent 412a6822-5aad-4863-a11e-4fa51ca5765d",
"context": {
"trace_id": "0x391f1d4e13c285bce547e03a4eb6e019",
"span_id": "0x0089408c54e3007d",
"trace_state": "[]"
},
"kind": "SpanKind.INTERNAL",
"parent_id": null,
"start_time": "2025-11-05T04:03:02.719208Z",
"end_time": "2025-11-05T04:03:13.922298Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"gen_ai.operation.name": "invoke_agent",
"gen_ai.request.choice.count": 1,
"gen_ai.provider.name": "microsoft.agent_framework",
"gen_ai.request.model": "unknown",
"gen_ai.agent.id": "412a6822-5aad-4863-a11e-4fa51ca5765d",
"gen_ai.agent.name": "412a6822-5aad-4863-a11e-4fa51ca5765d",
"gen_ai.response.id": "chatcmpl-CYP1bPQBRWECwF5ush924IBTgC3gj",
"gen_ai.response.finish_reasons": "["stop"]",
"gen_ai.usage.input_tokens": 25,
"gen_ai.usage.output_tokens": 564
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.38.0",
"service.namespace": "agent365-tests",
"service.name": "integration-test-service"
},
"schema_url": ""
}
}
3.
{
"name": "execute_tool add_numbers",
"context": {
"trace_id": "0xee7d1f03ab5d91dd20768ab6f3c88d55",
"span_id": "0xf59bddb6084efa0a",
"trace_state": "[]"
},
"kind": "SpanKind.INTERNAL",
"parent_id": "0x643e1b7e3b4c4de6",
"start_time": "2025-11-05T04:03:16.482169Z",
"end_time": "2025-11-05T04:03:16.482169Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"gen_ai.operation.name": "execute_tool",
"gen_ai.tool.name": "add_numbers",
"gen_ai.tool.call.id": "call_6PWwum9FD353331ImN4NoZKl",
"gen_ai.tool.type": "function",
"gen_ai.tool.description": "Add two numbers together.\n\n Args:\n a: First number\n b: Second number\n\n Returns:\n The sum of a and b\n ",
"agent_framework.function.invocation.duration": 3.719999949680641e-05
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.38.0",
"service.namespace": "agent365-tests",
"service.name": "integration-test-service"
},
"schema_url": ""
}
}