microsoft-agents-a365-observability-hosting 0.2.1.dev45__tar.gz → 0.2.1.dev47__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_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/PKG-INFO +1 -1
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/middleware/output_logging_middleware.py +24 -53
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/scope_helpers/populate_baggage.py +0 -2
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/scope_helpers/populate_invoke_agent_scope.py +0 -2
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/scope_helpers/utils.py +0 -15
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365_observability_hosting.egg-info/PKG-INFO +1 -1
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/README.md +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/__init__.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/middleware/__init__.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/middleware/baggage_middleware.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/middleware/observability_hosting_manager.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/scope_helpers/__init__.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/token_cache_helpers/__init__.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365/observability/hosting/token_cache_helpers/agent_token_cache.py +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365_observability_hosting.egg-info/SOURCES.txt +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365_observability_hosting.egg-info/dependency_links.txt +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365_observability_hosting.egg-info/requires.txt +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/microsoft_agents_a365_observability_hosting.egg-info/top_level.txt +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/pyproject.toml +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/setup.cfg +0 -0
- {microsoft_agents_a365_observability_hosting-0.2.1.dev45 → microsoft_agents_a365_observability_hosting-0.2.1.dev47}/setup.py +0 -0
|
@@ -14,22 +14,14 @@ from microsoft_agents_a365.observability.core.agent_details import AgentDetails
|
|
|
14
14
|
from microsoft_agents_a365.observability.core.constants import (
|
|
15
15
|
CHANNEL_LINK_KEY,
|
|
16
16
|
CHANNEL_NAME_KEY,
|
|
17
|
-
GEN_AI_CONVERSATION_ID_KEY,
|
|
18
|
-
GEN_AI_EXECUTION_TYPE_KEY,
|
|
19
|
-
USER_EMAIL_KEY,
|
|
20
|
-
USER_ID_KEY,
|
|
21
|
-
USER_NAME_KEY,
|
|
22
17
|
)
|
|
23
|
-
from microsoft_agents_a365.observability.core.models.caller_details import CallerDetails
|
|
24
18
|
from microsoft_agents_a365.observability.core.models.response import Response
|
|
19
|
+
from microsoft_agents_a365.observability.core.models.user_details import UserDetails
|
|
20
|
+
from microsoft_agents_a365.observability.core.request import Request
|
|
21
|
+
from microsoft_agents_a365.observability.core.span_details import SpanDetails
|
|
25
22
|
from microsoft_agents_a365.observability.core.spans_scopes.output_scope import OutputScope
|
|
26
|
-
from microsoft_agents_a365.observability.core.tenant_details import TenantDetails
|
|
27
23
|
from microsoft_agents_a365.observability.core.utils import extract_context_from_headers
|
|
28
24
|
|
|
29
|
-
from ..scope_helpers.utils import (
|
|
30
|
-
get_execution_type_pair,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
25
|
logger = logging.getLogger(__name__)
|
|
34
26
|
|
|
35
27
|
# TurnState key for the parent trace context (W3C traceparent string).
|
|
@@ -52,28 +44,21 @@ def _derive_agent_details(context: TurnContext) -> AgentDetails | None:
|
|
|
52
44
|
return AgentDetails(
|
|
53
45
|
agent_id=activity.get_agentic_instance_id() or "",
|
|
54
46
|
agent_name=getattr(recipient, "name", None),
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
agentic_user_id=getattr(recipient, "aad_object_id", None),
|
|
48
|
+
agentic_user_email=activity.get_agentic_user(),
|
|
57
49
|
agent_description=getattr(recipient, "role", None),
|
|
58
50
|
tenant_id=getattr(recipient, "tenant_id", None),
|
|
59
51
|
)
|
|
60
52
|
|
|
61
53
|
|
|
62
|
-
def
|
|
63
|
-
"""Derive
|
|
64
|
-
tenant_id = getattr(getattr(context.activity, "recipient", None), "tenant_id", None)
|
|
65
|
-
return TenantDetails(tenant_id=tenant_id) if tenant_id else None
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def _derive_caller_details(context: TurnContext) -> CallerDetails | None:
|
|
69
|
-
"""Derive caller identity details from the activity from property."""
|
|
54
|
+
def _derive_user_details(context: TurnContext) -> UserDetails | None:
|
|
55
|
+
"""Derive user identity details from the activity from property."""
|
|
70
56
|
frm = getattr(context.activity, "from_property", None)
|
|
71
57
|
if not frm:
|
|
72
58
|
return None
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
caller_name=getattr(frm, "name", None),
|
|
59
|
+
return UserDetails(
|
|
60
|
+
user_id=getattr(frm, "aad_object_id", None),
|
|
61
|
+
user_name=getattr(frm, "name", None),
|
|
77
62
|
)
|
|
78
63
|
|
|
79
64
|
|
|
@@ -99,14 +84,6 @@ def _derive_channel(
|
|
|
99
84
|
return {"name": channel_name, "link": sub_channel}
|
|
100
85
|
|
|
101
86
|
|
|
102
|
-
def _derive_execution_type(context: TurnContext) -> str | None:
|
|
103
|
-
"""Derive execution type from the activity."""
|
|
104
|
-
pairs = list(get_execution_type_pair(context.activity))
|
|
105
|
-
if pairs:
|
|
106
|
-
return pairs[0][1]
|
|
107
|
-
return None
|
|
108
|
-
|
|
109
|
-
|
|
110
87
|
class OutputLoggingMiddleware:
|
|
111
88
|
"""Middleware that creates :class:`OutputScope` spans for outgoing messages.
|
|
112
89
|
|
|
@@ -123,26 +100,22 @@ class OutputLoggingMiddleware:
|
|
|
123
100
|
logic: Callable[[TurnContext], Awaitable],
|
|
124
101
|
) -> None:
|
|
125
102
|
agent_details = _derive_agent_details(context)
|
|
126
|
-
tenant_details = _derive_tenant_details(context)
|
|
127
103
|
|
|
128
|
-
if not agent_details
|
|
104
|
+
if not agent_details:
|
|
129
105
|
await logic()
|
|
130
106
|
return
|
|
131
107
|
|
|
132
|
-
|
|
108
|
+
user_details = _derive_user_details(context)
|
|
133
109
|
conversation_id = _derive_conversation_id(context)
|
|
134
110
|
channel = _derive_channel(context)
|
|
135
|
-
execution_type = _derive_execution_type(context)
|
|
136
111
|
|
|
137
112
|
context.on_send_activities(
|
|
138
113
|
self._create_send_handler(
|
|
139
114
|
context,
|
|
140
115
|
agent_details,
|
|
141
|
-
|
|
142
|
-
caller_details,
|
|
116
|
+
user_details,
|
|
143
117
|
conversation_id,
|
|
144
118
|
channel,
|
|
145
|
-
execution_type,
|
|
146
119
|
)
|
|
147
120
|
)
|
|
148
121
|
|
|
@@ -152,11 +125,9 @@ class OutputLoggingMiddleware:
|
|
|
152
125
|
self,
|
|
153
126
|
turn_context: TurnContext,
|
|
154
127
|
agent_details: AgentDetails,
|
|
155
|
-
|
|
156
|
-
caller_details: CallerDetails | None,
|
|
128
|
+
user_details: UserDetails | None,
|
|
157
129
|
conversation_id: str | None,
|
|
158
130
|
channel: dict[str, str | None],
|
|
159
|
-
execution_type: str | None,
|
|
160
131
|
) -> Callable:
|
|
161
132
|
"""Create a send handler that wraps outgoing messages in OutputScope spans.
|
|
162
133
|
|
|
@@ -187,24 +158,24 @@ class OutputLoggingMiddleware:
|
|
|
187
158
|
A365_PARENT_TRACEPARENT_KEY,
|
|
188
159
|
)
|
|
189
160
|
|
|
161
|
+
request = Request(
|
|
162
|
+
conversation_id=conversation_id,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
span_details = SpanDetails(parent_context=parent_context) if parent_context else None
|
|
166
|
+
|
|
190
167
|
output_scope = OutputScope.start(
|
|
191
|
-
|
|
192
|
-
tenant_details=tenant_details,
|
|
168
|
+
request=request,
|
|
193
169
|
response=Response(messages=messages),
|
|
194
|
-
|
|
170
|
+
agent_details=agent_details,
|
|
171
|
+
user_details=user_details,
|
|
172
|
+
span_details=span_details,
|
|
195
173
|
)
|
|
196
174
|
|
|
197
175
|
# Set additional attributes on the scope
|
|
198
|
-
output_scope.set_tag_maybe(GEN_AI_CONVERSATION_ID_KEY, conversation_id)
|
|
199
|
-
output_scope.set_tag_maybe(GEN_AI_EXECUTION_TYPE_KEY, execution_type)
|
|
200
176
|
output_scope.set_tag_maybe(CHANNEL_NAME_KEY, channel.get("name"))
|
|
201
177
|
output_scope.set_tag_maybe(CHANNEL_LINK_KEY, channel.get("link"))
|
|
202
178
|
|
|
203
|
-
if caller_details:
|
|
204
|
-
output_scope.set_tag_maybe(USER_ID_KEY, caller_details.caller_id)
|
|
205
|
-
output_scope.set_tag_maybe(USER_EMAIL_KEY, caller_details.caller_upn)
|
|
206
|
-
output_scope.set_tag_maybe(USER_NAME_KEY, caller_details.caller_name)
|
|
207
|
-
|
|
208
179
|
try:
|
|
209
180
|
await send_next()
|
|
210
181
|
except Exception as error:
|
|
@@ -13,7 +13,6 @@ from .utils import (
|
|
|
13
13
|
get_caller_pairs,
|
|
14
14
|
get_channel_pairs,
|
|
15
15
|
get_conversation_pairs,
|
|
16
|
-
get_execution_type_pair,
|
|
17
16
|
get_target_agent_pairs,
|
|
18
17
|
get_tenant_id_pair,
|
|
19
18
|
)
|
|
@@ -24,7 +23,6 @@ def _iter_all_pairs(turn_context: TurnContext) -> Iterator[tuple[str, Any]]:
|
|
|
24
23
|
if not activity:
|
|
25
24
|
return
|
|
26
25
|
yield from get_caller_pairs(activity)
|
|
27
|
-
yield from get_execution_type_pair(activity)
|
|
28
26
|
yield from get_target_agent_pairs(activity)
|
|
29
27
|
yield from get_tenant_id_pair(activity)
|
|
30
28
|
yield from get_channel_pairs(activity)
|
|
@@ -11,7 +11,6 @@ from .utils import (
|
|
|
11
11
|
get_caller_pairs,
|
|
12
12
|
get_channel_pairs,
|
|
13
13
|
get_conversation_pairs,
|
|
14
|
-
get_execution_type_pair,
|
|
15
14
|
get_target_agent_pairs,
|
|
16
15
|
get_tenant_id_pair,
|
|
17
16
|
)
|
|
@@ -36,7 +35,6 @@ def populate(scope: InvokeAgentScope, turn_context: TurnContext) -> InvokeAgentS
|
|
|
36
35
|
activity = turn_context.activity
|
|
37
36
|
|
|
38
37
|
scope.record_attributes(get_caller_pairs(activity))
|
|
39
|
-
scope.record_attributes(get_execution_type_pair(activity))
|
|
40
38
|
scope.record_attributes(get_target_agent_pairs(activity))
|
|
41
39
|
scope.record_attributes(get_tenant_id_pair(activity))
|
|
42
40
|
scope.record_attributes(get_channel_pairs(activity))
|
|
@@ -14,13 +14,11 @@ from microsoft_agents_a365.observability.core.constants import (
|
|
|
14
14
|
GEN_AI_AGENT_NAME_KEY,
|
|
15
15
|
GEN_AI_CONVERSATION_ID_KEY,
|
|
16
16
|
GEN_AI_CONVERSATION_ITEM_LINK_KEY,
|
|
17
|
-
GEN_AI_EXECUTION_TYPE_KEY,
|
|
18
17
|
TENANT_ID_KEY,
|
|
19
18
|
USER_EMAIL_KEY,
|
|
20
19
|
USER_ID_KEY,
|
|
21
20
|
USER_NAME_KEY,
|
|
22
21
|
)
|
|
23
|
-
from microsoft_agents_a365.observability.core.execution_type import ExecutionType
|
|
24
22
|
|
|
25
23
|
AGENT_ROLE = "agenticUser"
|
|
26
24
|
|
|
@@ -43,19 +41,6 @@ def get_caller_pairs(activity: Activity) -> Iterator[tuple[str, Any]]:
|
|
|
43
41
|
yield USER_EMAIL_KEY, frm.agentic_user_id
|
|
44
42
|
|
|
45
43
|
|
|
46
|
-
def get_execution_type_pair(activity: Activity) -> Iterator[tuple[str, Any]]:
|
|
47
|
-
frm = activity.from_property
|
|
48
|
-
rec = activity.recipient
|
|
49
|
-
is_agentic_caller = _is_agentic(frm)
|
|
50
|
-
is_agentic_recipient = _is_agentic(rec)
|
|
51
|
-
exec_type = (
|
|
52
|
-
ExecutionType.AGENT_TO_AGENT.value
|
|
53
|
-
if (is_agentic_caller and is_agentic_recipient)
|
|
54
|
-
else ExecutionType.HUMAN_TO_AGENT.value
|
|
55
|
-
)
|
|
56
|
-
yield GEN_AI_EXECUTION_TYPE_KEY, exec_type
|
|
57
|
-
|
|
58
|
-
|
|
59
44
|
def get_target_agent_pairs(activity: Activity) -> Iterator[tuple[str, Any]]:
|
|
60
45
|
rec = activity.recipient
|
|
61
46
|
if not rec:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|