Skip to content

Commit 0e23f4a

Browse files
rename the source metadata to channel
1 parent 6838fff commit 0e23f4a

20 files changed

Lines changed: 77 additions & 115 deletions

File tree

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from .middleware.baggage_builder import BaggageBuilder
2929
from .opentelemetry_scope import OpenTelemetryScope
3030
from .request import Request
31-
from .source_metadata import SourceMetadata
31+
from .channel import Channel
3232
from .tenant_details import TenantDetails
3333
from .tool_call_details import ToolCallDetails
3434
from .tool_type import ToolType
@@ -64,7 +64,7 @@
6464
"AgentDetails",
6565
"TenantDetails",
6666
"ToolCallDetails",
67-
"SourceMetadata",
67+
"Channel",
6868
"Request",
6969
"InferenceCallDetails",
7070
"ServiceEndpoint",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
# Channel class.
5+
6+
from dataclasses import dataclass
7+
8+
9+
@dataclass
10+
class Channel:
11+
"""Channel information for agent execution context."""
12+
13+
name: str | None = None
14+
link: str | None = None

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/execute_tool_scope.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def __init__(
131131
self.set_tag_maybe(SERVER_PORT_KEY, endpoint.port)
132132

133133
# Set request metadata if provided
134-
if request and request.source_metadata:
135-
self.set_tag_maybe(CHANNEL_NAME_KEY, request.source_metadata.name)
136-
self.set_tag_maybe(CHANNEL_LINK_KEY, request.source_metadata.description)
134+
if request and request.channel:
135+
self.set_tag_maybe(CHANNEL_NAME_KEY, request.channel.name)
136+
self.set_tag_maybe(CHANNEL_LINK_KEY, request.channel.link)
137137

138138
def record_response(self, response: str) -> None:
139139
"""Records response information for telemetry tracking.

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/inference_scope.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ def __init__(
124124
self.set_tag_maybe(SERVER_PORT_KEY, str(details.endpoint.port))
125125

126126
# Set request metadata if provided
127-
if request and request.source_metadata:
128-
self.set_tag_maybe(CHANNEL_NAME_KEY, request.source_metadata.name)
129-
self.set_tag_maybe(CHANNEL_LINK_KEY, request.source_metadata.description)
127+
if request and request.channel:
128+
self.set_tag_maybe(CHANNEL_NAME_KEY, request.channel.name)
129+
self.set_tag_maybe(CHANNEL_LINK_KEY, request.channel.link)
130130

131131
def record_input_messages(self, messages: List[str]) -> None:
132132
"""Records the input messages for telemetry tracking.

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/invoke_agent_scope.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ def __init__(
149149

150150
# Set request metadata if provided
151151
if request:
152-
if request.source_metadata:
153-
self.set_tag_maybe(CHANNEL_NAME_KEY, request.source_metadata.name)
154-
self.set_tag_maybe(CHANNEL_LINK_KEY, request.source_metadata.description)
152+
if request.channel:
153+
self.set_tag_maybe(CHANNEL_NAME_KEY, request.channel.name)
154+
self.set_tag_maybe(CHANNEL_LINK_KEY, request.channel.link)
155155

156156
self.set_tag_maybe(
157157
GEN_AI_EXECUTION_TYPE_KEY,

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/middleware/baggage_builder.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
USER_ID_KEY,
2929
USER_NAME_KEY,
3030
)
31-
from ..utils import deprecated, validate_and_normalize_ip
31+
from ..utils import validate_and_normalize_ip
3232

3333
logger = logging.getLogger(__name__)
3434

@@ -177,16 +177,6 @@ def conversation_item_link(self, value: str | None) -> "BaggageBuilder":
177177
self._set(GEN_AI_CONVERSATION_ITEM_LINK_KEY, value)
178178
return self
179179

180-
@deprecated("Use channel_name() instead")
181-
def source_metadata_name(self, value: str | None) -> "BaggageBuilder":
182-
"""Set the execution source metadata name (e.g., channel name)."""
183-
return self.channel_name(value)
184-
185-
@deprecated("Use channel_links() instead")
186-
def source_metadata_description(self, value: str | None) -> "BaggageBuilder":
187-
"""Set the execution source metadata description (e.g., channel description)."""
188-
return self.channel_links(value)
189-
190180
def session_id(self, value: str | None) -> "BaggageBuilder":
191181
"""Set the session ID baggage value."""
192182
self._set(SESSION_ID_KEY, value)
@@ -203,7 +193,7 @@ def channel_name(self, value: str | None) -> "BaggageBuilder":
203193
return self
204194

205195
def channel_links(self, value: str | None) -> "BaggageBuilder":
206-
"""Sets the channel link baggage value. (e.g., channel links or description)."""
196+
"""Sets the channel link baggage value."""
207197
self._set(CHANNEL_LINK_KEY, value)
208198
return self
209199

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dataclasses import dataclass
77

88
from .execution_type import ExecutionType
9-
from .source_metadata import SourceMetadata
9+
from .channel import Channel
1010

1111

1212
@dataclass
@@ -16,4 +16,4 @@ class Request:
1616
content: str
1717
execution_type: ExecutionType
1818
session_id: str | None = None
19-
source_metadata: SourceMetadata | None = None
19+
channel: Channel | None = None

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/source_metadata.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

libraries/microsoft-agents-a365-observability-hosting/microsoft_agents_a365/observability/hosting/middleware/output_logging_middleware.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ def _derive_conversation_id(context: TurnContext) -> str | None:
8383
return conv.id if conv else None
8484

8585

86-
def _derive_source_metadata(
86+
def _derive_channel(
8787
context: TurnContext,
8888
) -> dict[str, str | None]:
89-
"""Derive source metadata (channel name and description) from TurnContext."""
89+
"""Derive channel (name and link) from TurnContext."""
9090
channel_id = getattr(context.activity, "channel_id", None)
9191
channel_name: str | None = None
9292
sub_channel: str | None = None
@@ -96,7 +96,7 @@ def _derive_source_metadata(
9696
elif hasattr(channel_id, "channel"):
9797
channel_name = channel_id.channel
9898
sub_channel = channel_id.sub_channel
99-
return {"name": channel_name, "description": sub_channel}
99+
return {"name": channel_name, "link": sub_channel}
100100

101101

102102
def _derive_execution_type(context: TurnContext) -> str | None:
@@ -131,7 +131,7 @@ async def on_turn(
131131

132132
caller_details = _derive_caller_details(context)
133133
conversation_id = _derive_conversation_id(context)
134-
source_metadata = _derive_source_metadata(context)
134+
channel = _derive_channel(context)
135135
execution_type = _derive_execution_type(context)
136136

137137
context.on_send_activities(
@@ -141,7 +141,7 @@ async def on_turn(
141141
tenant_details,
142142
caller_details,
143143
conversation_id,
144-
source_metadata,
144+
channel,
145145
execution_type,
146146
)
147147
)
@@ -155,7 +155,7 @@ def _create_send_handler(
155155
tenant_details: TenantDetails,
156156
caller_details: CallerDetails | None,
157157
conversation_id: str | None,
158-
source_metadata: dict[str, str | None],
158+
channel: dict[str, str | None],
159159
execution_type: str | None,
160160
) -> Callable:
161161
"""Create a send handler that wraps outgoing messages in OutputScope spans.
@@ -197,8 +197,8 @@ async def handler(
197197
# Set additional attributes on the scope
198198
output_scope.set_tag_maybe(GEN_AI_CONVERSATION_ID_KEY, conversation_id)
199199
output_scope.set_tag_maybe(GEN_AI_EXECUTION_TYPE_KEY, execution_type)
200-
output_scope.set_tag_maybe(CHANNEL_NAME_KEY, source_metadata.get("name"))
201-
output_scope.set_tag_maybe(CHANNEL_LINK_KEY, source_metadata.get("description"))
200+
output_scope.set_tag_maybe(CHANNEL_NAME_KEY, channel.get("name"))
201+
output_scope.set_tag_maybe(CHANNEL_LINK_KEY, channel.get("link"))
202202

203203
if caller_details:
204204
output_scope.set_tag_maybe(USER_ID_KEY, caller_details.caller_id)

libraries/microsoft-agents-a365-observability-hosting/microsoft_agents_a365/observability/hosting/scope_helpers/populate_baggage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
from .utils import (
1313
get_caller_pairs,
14+
get_channel_pairs,
1415
get_conversation_pairs,
1516
get_execution_type_pair,
16-
get_source_metadata_pairs,
1717
get_target_agent_pairs,
1818
get_tenant_id_pair,
1919
)
@@ -27,7 +27,7 @@ def _iter_all_pairs(turn_context: TurnContext) -> Iterator[tuple[str, Any]]:
2727
yield from get_execution_type_pair(activity)
2828
yield from get_target_agent_pairs(activity)
2929
yield from get_tenant_id_pair(activity)
30-
yield from get_source_metadata_pairs(activity)
30+
yield from get_channel_pairs(activity)
3131
yield from get_conversation_pairs(activity)
3232

3333

0 commit comments

Comments
 (0)