microsoft-agents-a365-observability-core 0.1.0.dev30__py3-none-any.whl → 0.2.1.dev0__py3-none-any.whl
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/core/__init__.py +2 -1
- microsoft_agents_a365/observability/core/agent_details.py +7 -4
- microsoft_agents_a365/observability/core/config.py +71 -26
- microsoft_agents_a365/observability/core/constants.py +5 -2
- microsoft_agents_a365/observability/core/execute_tool_scope.py +15 -1
- microsoft_agents_a365/observability/core/execution_type.py +2 -1
- microsoft_agents_a365/observability/core/exporters/__init__.py +8 -0
- microsoft_agents_a365/observability/core/exporters/agent365_exporter.py +55 -7
- microsoft_agents_a365/observability/core/exporters/agent365_exporter_options.py +39 -0
- microsoft_agents_a365/observability/core/exporters/utils.py +133 -1
- microsoft_agents_a365/observability/core/inference_call_details.py +2 -1
- microsoft_agents_a365/observability/core/inference_operation_type.py +2 -1
- microsoft_agents_a365/observability/core/inference_scope.py +9 -0
- microsoft_agents_a365/observability/core/invoke_agent_details.py +2 -1
- microsoft_agents_a365/observability/core/invoke_agent_scope.py +12 -3
- microsoft_agents_a365/observability/core/middleware/__init__.py +2 -1
- microsoft_agents_a365/observability/core/middleware/baggage_builder.py +52 -28
- microsoft_agents_a365/observability/core/models/operation_source.py +21 -0
- microsoft_agents_a365/observability/core/opentelemetry_scope.py +2 -1
- microsoft_agents_a365/observability/core/request.py +2 -2
- microsoft_agents_a365/observability/core/source_metadata.py +2 -1
- microsoft_agents_a365/observability/core/tenant_details.py +2 -1
- microsoft_agents_a365/observability/core/tool_call_details.py +2 -1
- microsoft_agents_a365/observability/core/tool_type.py +2 -1
- microsoft_agents_a365/observability/core/trace_processor/__init__.py +2 -1
- microsoft_agents_a365/observability/core/trace_processor/span_processor.py +13 -3
- microsoft_agents_a365/observability/core/trace_processor/util.py +10 -5
- microsoft_agents_a365/observability/core/utils.py +53 -4
- {microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info → microsoft_agents_a365_observability_core-0.2.1.dev0.dist-info}/METADATA +3 -3
- microsoft_agents_a365_observability_core-0.2.1.dev0.dist-info/RECORD +35 -0
- {microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info → microsoft_agents_a365_observability_core-0.2.1.dev0.dist-info}/WHEEL +1 -1
- {microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info → microsoft_agents_a365_observability_core-0.2.1.dev0.dist-info}/top_level.txt +1 -0
- microsoft_agents_a365/observability/core/middleware/turn_context_baggage.py +0 -193
- microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info/RECORD +0 -33
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
from typing import Any, Iterable, Iterator, Mapping
|
|
5
|
-
|
|
6
|
-
from ..constants import (
|
|
7
|
-
GEN_AI_AGENT_AUID_KEY,
|
|
8
|
-
GEN_AI_AGENT_DESCRIPTION_KEY,
|
|
9
|
-
GEN_AI_AGENT_ID_KEY,
|
|
10
|
-
GEN_AI_AGENT_NAME_KEY,
|
|
11
|
-
GEN_AI_AGENT_UPN_KEY,
|
|
12
|
-
GEN_AI_CALLER_ID_KEY,
|
|
13
|
-
GEN_AI_CALLER_NAME_KEY,
|
|
14
|
-
GEN_AI_CALLER_TENANT_ID_KEY,
|
|
15
|
-
GEN_AI_CALLER_UPN_KEY,
|
|
16
|
-
GEN_AI_CALLER_USER_ID_KEY,
|
|
17
|
-
GEN_AI_CONVERSATION_ID_KEY,
|
|
18
|
-
GEN_AI_CONVERSATION_ITEM_LINK_KEY,
|
|
19
|
-
GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY,
|
|
20
|
-
GEN_AI_EXECUTION_SOURCE_ID_KEY,
|
|
21
|
-
GEN_AI_EXECUTION_SOURCE_NAME_KEY,
|
|
22
|
-
GEN_AI_EXECUTION_TYPE_KEY,
|
|
23
|
-
TENANT_ID_KEY,
|
|
24
|
-
)
|
|
25
|
-
from ..execution_type import ExecutionType
|
|
26
|
-
|
|
27
|
-
AGENT_ROLE = "agenticUser"
|
|
28
|
-
CHANNEL_ID_AGENTS = "agents"
|
|
29
|
-
ENTITY_TYPE_WPX_COMMENT = "wpxcomment"
|
|
30
|
-
ENTITY_TYPE_EMAIL_NOTIFICATION = "emailNotification"
|
|
31
|
-
WPX_CONVERSATION_ID_FORMAT = "{document_id}_{parent_comment_id}"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def _safe_get(obj: Any, *names: str) -> Any:
|
|
35
|
-
"""Attempt multiple attribute/dict keys; return first non-None."""
|
|
36
|
-
for n in names:
|
|
37
|
-
if obj is None:
|
|
38
|
-
continue
|
|
39
|
-
# dict-like
|
|
40
|
-
if isinstance(obj, Mapping) and n in obj:
|
|
41
|
-
return obj[n]
|
|
42
|
-
# attribute-like (support both camelCase and snake_case lookups)
|
|
43
|
-
if hasattr(obj, n):
|
|
44
|
-
return getattr(obj, n)
|
|
45
|
-
return None
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def _extract_channel_data(activity: Any) -> Mapping[str, Any] | None:
|
|
49
|
-
cd = _safe_get(activity, "channel_data")
|
|
50
|
-
if cd is None:
|
|
51
|
-
return None
|
|
52
|
-
if isinstance(cd, Mapping):
|
|
53
|
-
return cd
|
|
54
|
-
if isinstance(cd, str):
|
|
55
|
-
try:
|
|
56
|
-
return json.loads(cd)
|
|
57
|
-
except Exception:
|
|
58
|
-
return None
|
|
59
|
-
return None
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def _iter_caller_pairs(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
63
|
-
frm = _safe_get(activity, "from")
|
|
64
|
-
if not frm:
|
|
65
|
-
return
|
|
66
|
-
yield GEN_AI_CALLER_ID_KEY, _safe_get(frm, "id")
|
|
67
|
-
name = _safe_get(frm, "name")
|
|
68
|
-
yield GEN_AI_CALLER_NAME_KEY, name
|
|
69
|
-
# Reuse 'name' as UPN if no separate field
|
|
70
|
-
upn = _safe_get(frm, "upn") or name
|
|
71
|
-
yield GEN_AI_CALLER_UPN_KEY, upn
|
|
72
|
-
user_id = _safe_get(frm, "agentic_user_id", "aad_object_id")
|
|
73
|
-
yield GEN_AI_CALLER_USER_ID_KEY, user_id
|
|
74
|
-
tenant_id = _safe_get(frm, "tenant_id")
|
|
75
|
-
yield GEN_AI_CALLER_TENANT_ID_KEY, tenant_id
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def _is_agentic(entity: Any) -> bool:
|
|
79
|
-
return bool(
|
|
80
|
-
_safe_get(
|
|
81
|
-
entity,
|
|
82
|
-
"agentic_user_id",
|
|
83
|
-
)
|
|
84
|
-
or (
|
|
85
|
-
(role := _safe_get(entity, "role", "Role"))
|
|
86
|
-
and isinstance(role, str)
|
|
87
|
-
and role.lower() == AGENT_ROLE.lower()
|
|
88
|
-
)
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def _iter_execution_type_pair(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
93
|
-
frm = _safe_get(activity, "from")
|
|
94
|
-
rec = _safe_get(activity, "recipient")
|
|
95
|
-
is_agentic_caller = _is_agentic(frm)
|
|
96
|
-
is_agentic_recipient = _is_agentic(rec)
|
|
97
|
-
exec_type = (
|
|
98
|
-
ExecutionType.AGENT_TO_AGENT.value
|
|
99
|
-
if (is_agentic_caller and is_agentic_recipient)
|
|
100
|
-
else ExecutionType.HUMAN_TO_AGENT.value
|
|
101
|
-
)
|
|
102
|
-
yield GEN_AI_EXECUTION_TYPE_KEY, exec_type
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def _iter_target_agent_pairs(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
106
|
-
rec = _safe_get(activity, "recipient")
|
|
107
|
-
if not rec:
|
|
108
|
-
return
|
|
109
|
-
yield GEN_AI_AGENT_ID_KEY, _safe_get(rec, "agentic_app_id")
|
|
110
|
-
yield GEN_AI_AGENT_NAME_KEY, _safe_get(rec, "name")
|
|
111
|
-
auid = _safe_get(rec, "agentic_user_id", "aad_object_id")
|
|
112
|
-
yield GEN_AI_AGENT_AUID_KEY, auid
|
|
113
|
-
yield GEN_AI_AGENT_UPN_KEY, _safe_get(rec, "upn", "name")
|
|
114
|
-
yield (
|
|
115
|
-
GEN_AI_AGENT_DESCRIPTION_KEY,
|
|
116
|
-
_safe_get(rec, "role"),
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
def _iter_tenant_id_pair(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
121
|
-
rec = _safe_get(activity, "recipient")
|
|
122
|
-
tenant_id = _safe_get(rec, "tenant_id")
|
|
123
|
-
if not tenant_id:
|
|
124
|
-
cd_dict = _extract_channel_data(activity)
|
|
125
|
-
# channelData.tenant.id
|
|
126
|
-
try:
|
|
127
|
-
tenant_id = (
|
|
128
|
-
cd_dict
|
|
129
|
-
and isinstance(cd_dict.get("tenant"), Mapping)
|
|
130
|
-
and cd_dict["tenant"].get("id")
|
|
131
|
-
)
|
|
132
|
-
except Exception:
|
|
133
|
-
tenant_id = None
|
|
134
|
-
yield TENANT_ID_KEY, tenant_id
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def _iter_source_metadata_pairs(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
138
|
-
channel_id = _safe_get(activity, "channel_id")
|
|
139
|
-
yield GEN_AI_EXECUTION_SOURCE_ID_KEY, channel_id
|
|
140
|
-
yield GEN_AI_EXECUTION_SOURCE_NAME_KEY, channel_id
|
|
141
|
-
yield GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, _safe_get(activity, "type", "Type")
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def _iter_conversation_pairs(activity: Any) -> Iterator[tuple[str, Any]]:
|
|
145
|
-
channel_id = _safe_get(activity, "channel_id")
|
|
146
|
-
entities = _safe_get(activity, "entities") or []
|
|
147
|
-
conversation_id = None
|
|
148
|
-
|
|
149
|
-
if channel_id == CHANNEL_ID_AGENTS and isinstance(entities, Iterable):
|
|
150
|
-
# search entities for wpxcomment or emailNotification
|
|
151
|
-
for e in entities:
|
|
152
|
-
etype = _safe_get(e, "type", "Type")
|
|
153
|
-
if etype == ENTITY_TYPE_WPX_COMMENT:
|
|
154
|
-
document_id = _safe_get(e, "documentId", "document_id")
|
|
155
|
-
parent_comment_id = _safe_get(e, "parentCommentId", "parent_comment_id")
|
|
156
|
-
if document_id and parent_comment_id:
|
|
157
|
-
conversation_id = WPX_CONVERSATION_ID_FORMAT.format(
|
|
158
|
-
document_id=document_id,
|
|
159
|
-
parent_comment_id=parent_comment_id,
|
|
160
|
-
)
|
|
161
|
-
break
|
|
162
|
-
elif etype == ENTITY_TYPE_EMAIL_NOTIFICATION:
|
|
163
|
-
conversation_id = _safe_get(e, "conversationId", "conversation_id")
|
|
164
|
-
if conversation_id:
|
|
165
|
-
break
|
|
166
|
-
if not conversation_id:
|
|
167
|
-
conv = _safe_get(activity, "conversation")
|
|
168
|
-
conversation_id = _safe_get(conv, "id", "Id")
|
|
169
|
-
|
|
170
|
-
item_link = _safe_get(activity, "service_url")
|
|
171
|
-
|
|
172
|
-
yield GEN_AI_CONVERSATION_ID_KEY, conversation_id
|
|
173
|
-
yield GEN_AI_CONVERSATION_ITEM_LINK_KEY, item_link
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def _iter_all_pairs(turn_context: Any) -> Iterator[tuple[str, Any]]:
|
|
177
|
-
activity = _safe_get(
|
|
178
|
-
turn_context,
|
|
179
|
-
"activity",
|
|
180
|
-
)
|
|
181
|
-
if not activity:
|
|
182
|
-
return
|
|
183
|
-
yield from _iter_caller_pairs(activity)
|
|
184
|
-
yield from _iter_execution_type_pair(activity)
|
|
185
|
-
yield from _iter_target_agent_pairs(activity)
|
|
186
|
-
yield from _iter_tenant_id_pair(activity)
|
|
187
|
-
yield from _iter_source_metadata_pairs(activity)
|
|
188
|
-
yield from _iter_conversation_pairs(activity)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
def from_turn_context(turn_context: Any) -> dict:
|
|
192
|
-
"""Populate builder with baggage values extracted from a turn context."""
|
|
193
|
-
return dict(_iter_all_pairs(turn_context))
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
microsoft_agents_a365/observability/core/__init__.py,sha256=1-Jmokc2cQv7p_RB7W22ZEdqQ0Doq8yDENx_Yews2p8,1737
|
|
2
|
-
microsoft_agents_a365/observability/core/agent_details.py,sha256=U0xgrtrnNXrI8yjmBk7teXuMCvIIk0zWEOti_RvJP1o,1147
|
|
3
|
-
microsoft_agents_a365/observability/core/config.py,sha256=-sCfRUQNSk2XHnh-Ez1DSVrXS2vHr_2YD-lZ8byyFjk,8828
|
|
4
|
-
microsoft_agents_a365/observability/core/constants.py,sha256=K__ga_vnsqrOIVzPtW4gWeu8xLJnAxJdkmbMzYYwPXY,4614
|
|
5
|
-
microsoft_agents_a365/observability/core/execute_tool_scope.py,sha256=RcibM_Q-lEhSOpAoRioDao-HiC72W741-SCbcPDWqyI,2989
|
|
6
|
-
microsoft_agents_a365/observability/core/execution_type.py,sha256=Qsf-7_7DzZnRQZ5NHYU31ggfxAjPwneNnda1hOodmG0,303
|
|
7
|
-
microsoft_agents_a365/observability/core/inference_call_details.py,sha256=V1-KQPNq0V36J91ptX96UNRcOW6cy-AV5eIlwbzsrSg,483
|
|
8
|
-
microsoft_agents_a365/observability/core/inference_operation_type.py,sha256=ZLdDdYC0V_0Sff_aTSaiIRVB4a9wEduS7EXpYlme6_M,273
|
|
9
|
-
microsoft_agents_a365/observability/core/inference_scope.py,sha256=87r367uQ4qVp8NpR0na-uQScRR5ID1FlP6c3cmIxvMc,4973
|
|
10
|
-
microsoft_agents_a365/observability/core/invoke_agent_details.py,sha256=PEwkJq-nUz8sxLsbz44hIydGHiO2tHj-sVBkMpZXC1A,389
|
|
11
|
-
microsoft_agents_a365/observability/core/invoke_agent_scope.py,sha256=NJSeKeNmvutn_MZARIGSg80n7HxTW3BazqyXw-9LFlY,6600
|
|
12
|
-
microsoft_agents_a365/observability/core/opentelemetry_scope.py,sha256=I8WQoQkCygC7jZRrP2aHsJScGqQKDVktLlRGxApfiZo,9734
|
|
13
|
-
microsoft_agents_a365/observability/core/request.py,sha256=fcqsmxPl0BMITwbvy5lK5DkDm5YjIXKIwlJTclcdMCs,430
|
|
14
|
-
microsoft_agents_a365/observability/core/source_metadata.py,sha256=ijMIiJGvfepDnBqSuZbGsjvrTivz3f_Ub1azyZsCeMA,321
|
|
15
|
-
microsoft_agents_a365/observability/core/tenant_details.py,sha256=eC5S9Zq5sJrpGFWJLKBXVlj-OipysPSoLKSl-8I5YY0,218
|
|
16
|
-
microsoft_agents_a365/observability/core/tool_call_details.py,sha256=sPDW5yvey9_itpKxoo76pwoncOZyhONt9fy3cDdSYyY,455
|
|
17
|
-
microsoft_agents_a365/observability/core/tool_type.py,sha256=O9snmopwdhBjK5eqwyQU3aSdLZzX88c1UMi7oW7lFHg,271
|
|
18
|
-
microsoft_agents_a365/observability/core/utils.py,sha256=PkoB6J65HhRbiFU2uz_WMn5XHLiRbtvPWzkMWe5Vkos,4850
|
|
19
|
-
microsoft_agents_a365/observability/core/exporters/agent365_exporter.py,sha256=j_u0fykKK7BY0sg1PsEFE4ABoU4HPwEJMjeZ_KZ1fhk,11386
|
|
20
|
-
microsoft_agents_a365/observability/core/exporters/utils.py,sha256=6G09FlUmtpq57415QQal22AMJQi21IZqBE8_4No_Qfg,1877
|
|
21
|
-
microsoft_agents_a365/observability/core/middleware/__init__.py,sha256=v_vLyv0BQOW9pAvuUeL6Q0ZQ3Ji4MdYYcFDfP7CqvMk,177
|
|
22
|
-
microsoft_agents_a365/observability/core/middleware/baggage_builder.py,sha256=RCdaOuXO6T_5zFP1K_xukTuibee2CIIQmYuvvFjXtNw,9538
|
|
23
|
-
microsoft_agents_a365/observability/core/middleware/turn_context_baggage.py,sha256=6IuS8SLbM-W-G5FgHncBurXi9fF-hRaFHjI78Bh3qsI,6698
|
|
24
|
-
microsoft_agents_a365/observability/core/models/__init__.py,sha256=aCOr6sEsQpv9z4cJgWFA4qOs4xJqclqYYnxOVcxiK2Q,75
|
|
25
|
-
microsoft_agents_a365/observability/core/models/agent_type.py,sha256=ZazwwMAQRrYzzN3Ytz69F6thV4R6nemA6JrK-70fyt0,560
|
|
26
|
-
microsoft_agents_a365/observability/core/models/caller_details.py,sha256=8oaRKeGNteZq_RAQShhfUBs0iO-Sr9yjfk13Mv-xSjA,674
|
|
27
|
-
microsoft_agents_a365/observability/core/trace_processor/__init__.py,sha256=GML9CA7ssJPngxpGFPdVlp-0NmhgS4Ke9IGW5vm5Gys,194
|
|
28
|
-
microsoft_agents_a365/observability/core/trace_processor/span_processor.py,sha256=9Sou0m1huEncNcGdU-ThE8b9uPwHosZNSPdldOUdlkU,2513
|
|
29
|
-
microsoft_agents_a365/observability/core/trace_processor/util.py,sha256=-jM4ei60f5HKEDAVvBlZiTmhMhq8hVvvt4SwGgEnPuI,2239
|
|
30
|
-
microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info/METADATA,sha256=kQPSsroyGWfuZdwjcyLWwo1Hm2amN2UEOxVs3bQg2lA,3878
|
|
31
|
-
microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
32
|
-
microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info/top_level.txt,sha256=G3c2_4sy5_EM_BWO67SbK2tKj4G8XFn-QXRbh8g9Lgk,22
|
|
33
|
-
microsoft_agents_a365_observability_core-0.1.0.dev30.dist-info/RECORD,,
|