microsoft-agents-a365-observability-extensions-agent-framework 0.2.1.dev9__tar.gz → 0.2.1.dev13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/PKG-INFO +12 -12
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13/microsoft_agents_a365/observability/extensions/agentframework/__init__.py +10 -0
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13/microsoft_agents_a365/observability/extensions/agentframework/span_enricher.py +51 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365/observability/extensions/agentframework/span_processor.py +2 -5
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py +27 -6
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13/microsoft_agents_a365/observability/extensions/agentframework/utils.py +48 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/PKG-INFO +12 -12
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/SOURCES.txt +2 -0
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/requires.txt +15 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/pyproject.toml +11 -11
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/setup.py +5 -6
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9/microsoft_agents_a365/observability/extensions/agentframework/__init__.py +0 -2
- microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/requires.txt +0 -15
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/README.md +0 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/dependency_links.txt +0 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/microsoft_agents_a365_observability_extensions_agent_framework.egg-info/top_level.txt +0 -0
- {microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev9 → microsoft_agents_a365_observability_extensions_agent_framework-0.2.1.dev13}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-a365-observability-extensions-agent-framework
|
|
3
|
-
Version: 0.2.1.
|
|
3
|
+
Version: 0.2.1.dev13
|
|
4
4
|
Summary: Agent Framework observability and tracing extensions for Microsoft Agent 365
|
|
5
5
|
Author-email: Microsoft <support@microsoft.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,19 +20,19 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
20
20
|
Classifier: Topic :: System :: Monitoring
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
-
Requires-Dist: microsoft-agents-a365-observability-core
|
|
24
|
-
Requires-Dist: opentelemetry-api
|
|
25
|
-
Requires-Dist: opentelemetry-sdk
|
|
26
|
-
Requires-Dist: opentelemetry-instrumentation
|
|
23
|
+
Requires-Dist: microsoft-agents-a365-observability-core
|
|
24
|
+
Requires-Dist: opentelemetry-api
|
|
25
|
+
Requires-Dist: opentelemetry-sdk
|
|
26
|
+
Requires-Dist: opentelemetry-instrumentation
|
|
27
27
|
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: pytest
|
|
29
|
-
Requires-Dist: pytest-asyncio
|
|
30
|
-
Requires-Dist: ruff
|
|
31
|
-
Requires-Dist: black
|
|
32
|
-
Requires-Dist: mypy
|
|
28
|
+
Requires-Dist: pytest; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff; extra == "dev"
|
|
31
|
+
Requires-Dist: black; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy; extra == "dev"
|
|
33
33
|
Provides-Extra: test
|
|
34
|
-
Requires-Dist: pytest
|
|
35
|
-
Requires-Dist: pytest-asyncio
|
|
34
|
+
Requires-Dist: pytest; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-asyncio; extra == "test"
|
|
36
36
|
|
|
37
37
|
# microsoft-agents-a365-observability-extensions-agentframework
|
|
38
38
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
from microsoft_agents_a365.observability.core.constants import (
|
|
5
|
+
EXECUTE_TOOL_OPERATION_NAME,
|
|
6
|
+
GEN_AI_INPUT_MESSAGES_KEY,
|
|
7
|
+
GEN_AI_OUTPUT_MESSAGES_KEY,
|
|
8
|
+
GEN_AI_TOOL_ARGS_KEY,
|
|
9
|
+
GEN_AI_TOOL_CALL_RESULT_KEY,
|
|
10
|
+
INVOKE_AGENT_OPERATION_NAME,
|
|
11
|
+
)
|
|
12
|
+
from microsoft_agents_a365.observability.core.exporters.enriched_span import EnrichedReadableSpan
|
|
13
|
+
from opentelemetry.sdk.trace import ReadableSpan
|
|
14
|
+
|
|
15
|
+
from .utils import extract_input_content, extract_output_content
|
|
16
|
+
|
|
17
|
+
# Agent Framework specific attribute keys
|
|
18
|
+
AF_TOOL_CALL_ARGUMENTS_KEY = "gen_ai.tool.call.arguments"
|
|
19
|
+
AF_TOOL_CALL_RESULT_KEY = "gen_ai.tool.call.result"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def enrich_agent_framework_span(span: ReadableSpan) -> ReadableSpan:
|
|
23
|
+
"""
|
|
24
|
+
Enricher function for Agent Framework spans.
|
|
25
|
+
"""
|
|
26
|
+
extra_attributes = {}
|
|
27
|
+
attributes = span.attributes or {}
|
|
28
|
+
|
|
29
|
+
# Only extract content for invoke_agent spans
|
|
30
|
+
if span.name.startswith(INVOKE_AGENT_OPERATION_NAME):
|
|
31
|
+
# Extract all text content from input messages
|
|
32
|
+
input_messages = attributes.get(GEN_AI_INPUT_MESSAGES_KEY)
|
|
33
|
+
if input_messages:
|
|
34
|
+
extra_attributes[GEN_AI_INPUT_MESSAGES_KEY] = extract_input_content(input_messages)
|
|
35
|
+
|
|
36
|
+
output_messages = attributes.get(GEN_AI_OUTPUT_MESSAGES_KEY)
|
|
37
|
+
if output_messages:
|
|
38
|
+
extra_attributes[GEN_AI_OUTPUT_MESSAGES_KEY] = extract_output_content(output_messages)
|
|
39
|
+
|
|
40
|
+
# Map tool attributes for execute_tool spans
|
|
41
|
+
elif span.name.startswith(EXECUTE_TOOL_OPERATION_NAME):
|
|
42
|
+
if AF_TOOL_CALL_ARGUMENTS_KEY in attributes:
|
|
43
|
+
extra_attributes[GEN_AI_TOOL_ARGS_KEY] = attributes[AF_TOOL_CALL_ARGUMENTS_KEY]
|
|
44
|
+
|
|
45
|
+
if AF_TOOL_CALL_RESULT_KEY in attributes:
|
|
46
|
+
extra_attributes[GEN_AI_TOOL_CALL_RESULT_KEY] = attributes[AF_TOOL_CALL_RESULT_KEY]
|
|
47
|
+
|
|
48
|
+
if extra_attributes:
|
|
49
|
+
return EnrichedReadableSpan(span, extra_attributes)
|
|
50
|
+
|
|
51
|
+
return span
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
# Copyright (c) Microsoft Corporation.
|
|
2
2
|
# Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
# Custom Span Processor
|
|
5
|
-
|
|
6
|
-
from opentelemetry.sdk.trace.export import SpanProcessor
|
|
7
|
-
|
|
8
4
|
from microsoft_agents_a365.observability.core.constants import (
|
|
9
|
-
GEN_AI_OPERATION_NAME_KEY,
|
|
10
5
|
EXECUTE_TOOL_OPERATION_NAME,
|
|
11
6
|
GEN_AI_EVENT_CONTENT,
|
|
7
|
+
GEN_AI_OPERATION_NAME_KEY,
|
|
12
8
|
)
|
|
9
|
+
from opentelemetry.sdk.trace.export import SpanProcessor
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
class AgentFrameworkSpanProcessor(SpanProcessor):
|
|
@@ -7,8 +7,15 @@ from collections.abc import Collection
|
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
9
|
from microsoft_agents_a365.observability.core.config import get_tracer_provider, is_configured
|
|
10
|
+
from microsoft_agents_a365.observability.core.exporters.enriching_span_processor import (
|
|
11
|
+
register_span_enricher,
|
|
12
|
+
unregister_span_enricher,
|
|
13
|
+
)
|
|
10
14
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
11
15
|
|
|
16
|
+
from microsoft_agents_a365.observability.extensions.agentframework.span_enricher import (
|
|
17
|
+
enrich_agent_framework_span,
|
|
18
|
+
)
|
|
12
19
|
from microsoft_agents_a365.observability.extensions.agentframework.span_processor import (
|
|
13
20
|
AgentFrameworkSpanProcessor,
|
|
14
21
|
)
|
|
@@ -16,13 +23,12 @@ from microsoft_agents_a365.observability.extensions.agentframework.span_processo
|
|
|
16
23
|
# -----------------------------
|
|
17
24
|
# 3) The Instrumentor class
|
|
18
25
|
# -----------------------------
|
|
19
|
-
_instruments = ("agent-framework-azure-ai >= 1.0.
|
|
26
|
+
_instruments = ("agent-framework-azure-ai >= 1.0.0",)
|
|
20
27
|
|
|
21
28
|
|
|
22
29
|
class AgentFrameworkInstrumentor(BaseInstrumentor):
|
|
23
30
|
"""
|
|
24
|
-
Instruments Agent Framework
|
|
25
|
-
• Installs your custom OTel SpanProcessor
|
|
31
|
+
Instruments Agent Framework with Agent365 observability.
|
|
26
32
|
"""
|
|
27
33
|
|
|
28
34
|
def __init__(self):
|
|
@@ -37,13 +43,28 @@ class AgentFrameworkInstrumentor(BaseInstrumentor):
|
|
|
37
43
|
|
|
38
44
|
def _instrument(self, **kwargs: Any) -> None:
|
|
39
45
|
"""
|
|
40
|
-
|
|
41
|
-
"""
|
|
46
|
+
Instrument Agent Framework.
|
|
42
47
|
|
|
48
|
+
Args:
|
|
49
|
+
**kwargs: Optional configuration parameters.
|
|
50
|
+
"""
|
|
43
51
|
# Ensure we have an SDK TracerProvider
|
|
44
52
|
provider = get_tracer_provider()
|
|
53
|
+
|
|
54
|
+
# Add processor for on_start modifications (rename spans, add attributes)
|
|
45
55
|
self._processor = AgentFrameworkSpanProcessor()
|
|
46
56
|
provider.add_span_processor(self._processor)
|
|
47
57
|
|
|
58
|
+
# Register enricher for on_end modifications
|
|
59
|
+
register_span_enricher(enrich_agent_framework_span)
|
|
60
|
+
|
|
48
61
|
def _uninstrument(self, **kwargs: Any) -> None:
|
|
49
|
-
|
|
62
|
+
"""
|
|
63
|
+
Remove Agent Framework instrumentation.
|
|
64
|
+
"""
|
|
65
|
+
# Unregister the enricher
|
|
66
|
+
unregister_span_enricher()
|
|
67
|
+
|
|
68
|
+
# Shutdown the processor
|
|
69
|
+
if hasattr(self, "_processor"):
|
|
70
|
+
self._processor.shutdown()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""Utility functions for Agent Framework observability extensions."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def extract_content_as_string_list(messages_json: str, role_filter: str | None = None) -> str:
|
|
12
|
+
"""Extract content values from messages JSON and return as JSON string list."""
|
|
13
|
+
try:
|
|
14
|
+
messages = json.loads(messages_json)
|
|
15
|
+
if isinstance(messages, list):
|
|
16
|
+
contents = []
|
|
17
|
+
for msg in messages:
|
|
18
|
+
if isinstance(msg, dict):
|
|
19
|
+
role = msg.get("role", "")
|
|
20
|
+
|
|
21
|
+
# Filter by role if specified
|
|
22
|
+
if role_filter and role != role_filter:
|
|
23
|
+
continue
|
|
24
|
+
|
|
25
|
+
# Handle Agent Framework format with "parts"
|
|
26
|
+
parts = msg.get("parts")
|
|
27
|
+
if parts and isinstance(parts, list):
|
|
28
|
+
for part in parts:
|
|
29
|
+
if isinstance(part, dict):
|
|
30
|
+
part_type = part.get("type", "")
|
|
31
|
+
# Only extract text content, not tool_call or tool_call_response
|
|
32
|
+
if part_type == "text" and "content" in part:
|
|
33
|
+
contents.append(part["content"])
|
|
34
|
+
return json.dumps(contents)
|
|
35
|
+
return messages_json
|
|
36
|
+
except (json.JSONDecodeError, TypeError):
|
|
37
|
+
# If parsing fails, return as-is
|
|
38
|
+
return messages_json
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def extract_input_content(messages_json: str) -> str:
|
|
42
|
+
"""Extract text content from user messages only."""
|
|
43
|
+
return extract_content_as_string_list(messages_json, role_filter="user")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def extract_output_content(messages_json: str) -> str:
|
|
47
|
+
"""Extract only assistant text content from output messages."""
|
|
48
|
+
return extract_content_as_string_list(messages_json, role_filter="assistant")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-a365-observability-extensions-agent-framework
|
|
3
|
-
Version: 0.2.1.
|
|
3
|
+
Version: 0.2.1.dev13
|
|
4
4
|
Summary: Agent Framework observability and tracing extensions for Microsoft Agent 365
|
|
5
5
|
Author-email: Microsoft <support@microsoft.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,19 +20,19 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
20
20
|
Classifier: Topic :: System :: Monitoring
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
-
Requires-Dist: microsoft-agents-a365-observability-core
|
|
24
|
-
Requires-Dist: opentelemetry-api
|
|
25
|
-
Requires-Dist: opentelemetry-sdk
|
|
26
|
-
Requires-Dist: opentelemetry-instrumentation
|
|
23
|
+
Requires-Dist: microsoft-agents-a365-observability-core
|
|
24
|
+
Requires-Dist: opentelemetry-api
|
|
25
|
+
Requires-Dist: opentelemetry-sdk
|
|
26
|
+
Requires-Dist: opentelemetry-instrumentation
|
|
27
27
|
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: pytest
|
|
29
|
-
Requires-Dist: pytest-asyncio
|
|
30
|
-
Requires-Dist: ruff
|
|
31
|
-
Requires-Dist: black
|
|
32
|
-
Requires-Dist: mypy
|
|
28
|
+
Requires-Dist: pytest; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff; extra == "dev"
|
|
31
|
+
Requires-Dist: black; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy; extra == "dev"
|
|
33
33
|
Provides-Extra: test
|
|
34
|
-
Requires-Dist: pytest
|
|
35
|
-
Requires-Dist: pytest-asyncio
|
|
34
|
+
Requires-Dist: pytest; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-asyncio; extra == "test"
|
|
36
36
|
|
|
37
37
|
# microsoft-agents-a365-observability-extensions-agentframework
|
|
38
38
|
|
|
@@ -2,8 +2,10 @@ README.md
|
|
|
2
2
|
pyproject.toml
|
|
3
3
|
setup.py
|
|
4
4
|
microsoft_agents_a365/observability/extensions/agentframework/__init__.py
|
|
5
|
+
microsoft_agents_a365/observability/extensions/agentframework/span_enricher.py
|
|
5
6
|
microsoft_agents_a365/observability/extensions/agentframework/span_processor.py
|
|
6
7
|
microsoft_agents_a365/observability/extensions/agentframework/trace_instrumentor.py
|
|
8
|
+
microsoft_agents_a365/observability/extensions/agentframework/utils.py
|
|
7
9
|
microsoft_agents_a365_observability_extensions_agent_framework.egg-info/PKG-INFO
|
|
8
10
|
microsoft_agents_a365_observability_extensions_agent_framework.egg-info/SOURCES.txt
|
|
9
11
|
microsoft_agents_a365_observability_extensions_agent_framework.egg-info/dependency_links.txt
|
|
@@ -25,10 +25,10 @@ classifiers = [
|
|
|
25
25
|
license = "MIT"
|
|
26
26
|
keywords = ["observability", "telemetry", "tracing", "opentelemetry", "agent-framework", "agents", "ai"]
|
|
27
27
|
dependencies = [
|
|
28
|
-
"microsoft-agents-a365-observability-core
|
|
29
|
-
"opentelemetry-api
|
|
30
|
-
"opentelemetry-sdk
|
|
31
|
-
"opentelemetry-instrumentation
|
|
28
|
+
"microsoft-agents-a365-observability-core",
|
|
29
|
+
"opentelemetry-api",
|
|
30
|
+
"opentelemetry-sdk",
|
|
31
|
+
"opentelemetry-instrumentation",
|
|
32
32
|
]
|
|
33
33
|
|
|
34
34
|
[project.urls]
|
|
@@ -39,15 +39,15 @@ Documentation = "https://github.com/microsoft/Agent365-python/tree/main/librarie
|
|
|
39
39
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
dev = [
|
|
42
|
-
"pytest
|
|
43
|
-
"pytest-asyncio
|
|
44
|
-
"ruff
|
|
45
|
-
"black
|
|
46
|
-
"mypy
|
|
42
|
+
"pytest",
|
|
43
|
+
"pytest-asyncio",
|
|
44
|
+
"ruff",
|
|
45
|
+
"black",
|
|
46
|
+
"mypy",
|
|
47
47
|
]
|
|
48
48
|
test = [
|
|
49
|
-
"pytest
|
|
50
|
-
"pytest-asyncio
|
|
49
|
+
"pytest",
|
|
50
|
+
"pytest-asyncio",
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
[tool.setuptools.packages.find]
|
|
@@ -15,14 +15,13 @@ sys.path.insert(0, str(helper_path))
|
|
|
15
15
|
|
|
16
16
|
from setup_utils import get_dynamic_dependencies # noqa: E402
|
|
17
17
|
|
|
18
|
-
# Use
|
|
19
|
-
# - Internal packages get:
|
|
20
|
-
# -
|
|
21
|
-
# -
|
|
18
|
+
# Use exact version matching for internal dependencies:
|
|
19
|
+
# - Internal packages get: == current_version (e.g., == 1.2.3)
|
|
20
|
+
# - Ensures all SDK packages must be at the same version
|
|
21
|
+
# - Prevents incompatibility issues from version mismatches
|
|
22
22
|
setup(
|
|
23
23
|
version=package_version,
|
|
24
24
|
install_requires=get_dynamic_dependencies(
|
|
25
|
-
|
|
26
|
-
use_exact_match=False, # Not exact match
|
|
25
|
+
use_exact_match=True,
|
|
27
26
|
),
|
|
28
27
|
)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
microsoft-agents-a365-observability-core>=0.0.0
|
|
2
|
-
opentelemetry-api>=1.36.0
|
|
3
|
-
opentelemetry-sdk>=1.36.0
|
|
4
|
-
opentelemetry-instrumentation>=0.47b0
|
|
5
|
-
|
|
6
|
-
[dev]
|
|
7
|
-
pytest>=7.0.0
|
|
8
|
-
pytest-asyncio>=0.21.0
|
|
9
|
-
ruff>=0.1.0
|
|
10
|
-
black>=23.0.0
|
|
11
|
-
mypy>=1.0.0
|
|
12
|
-
|
|
13
|
-
[test]
|
|
14
|
-
pytest>=7.0.0
|
|
15
|
-
pytest-asyncio>=0.21.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|