Skip to content

Commit e6721c7

Browse files
address copilot review
1 parent f59708b commit e6721c7

File tree

2 files changed

+6
-17
lines changed
  • libraries/microsoft-agents-a365-observability-extensions-semantickernel/microsoft_agents_a365/observability/extensions/semantickernel

2 files changed

+6
-17
lines changed

libraries/microsoft-agents-a365-observability-extensions-semantickernel/microsoft_agents_a365/observability/extensions/semantickernel/span_enricher.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,11 @@ def enrich_semantic_kernel_span(span: ReadableSpan) -> ReadableSpan:
6363

6464
# Map tool attributes for execute_tool spans
6565
elif span.name.startswith(EXECUTE_TOOL_OPERATION_NAME):
66-
# Map SK's gen_ai.tool.arguments to standard gen_ai.tool.call.arguments
67-
tool_arguments = attributes.get(GEN_AI_TOOL_ARGS_KEY) or attributes.get(
68-
SK_TOOL_CALL_ARGUMENTS_KEY
69-
)
70-
if tool_arguments:
71-
extra_attributes[GEN_AI_TOOL_ARGS_KEY] = tool_arguments
66+
if SK_TOOL_CALL_ARGUMENTS_KEY in attributes:
67+
extra_attributes[GEN_AI_TOOL_ARGS_KEY] = attributes[SK_TOOL_CALL_ARGUMENTS_KEY]
7268

73-
# Map SK's tool result to standard gen_ai.tool.call.result
74-
tool_result = attributes.get(GEN_AI_TOOL_CALL_RESULT_KEY) or attributes.get(
75-
SK_TOOL_CALL_RESULT_KEY
76-
)
77-
if tool_result:
78-
extra_attributes[GEN_AI_TOOL_CALL_RESULT_KEY] = tool_result
69+
if SK_TOOL_CALL_RESULT_KEY in attributes:
70+
extra_attributes[GEN_AI_TOOL_CALL_RESULT_KEY] = attributes[SK_TOOL_CALL_RESULT_KEY]
7971

8072
if extra_attributes:
8173
return EnrichedReadableSpan(span, extra_attributes)

libraries/microsoft-agents-a365-observability-extensions-semantickernel/microsoft_agents_a365/observability/extensions/semantickernel/span_processor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from microsoft_agents_a365.observability.core.execution_type import ExecutionType
1010
from microsoft_agents_a365.observability.core.inference_operation_type import InferenceOperationType
1111
from microsoft_agents_a365.observability.core.utils import extract_model_name
12+
from opentelemetry import context as context_api
1213
from opentelemetry.sdk.trace import ReadableSpan, Span
1314
from opentelemetry.sdk.trace.export import SpanProcessor
1415

@@ -27,7 +28,7 @@ def __init__(self, service_name: str | None = None):
2728
"""
2829
self.service_name = service_name
2930

30-
def on_start(self, span: Span, parent_context) -> None:
31+
def on_start(self, span: Span, parent_context: context_api.Context | None) -> None:
3132
"""
3233
Modify span while it's still writable.
3334
@@ -48,10 +49,6 @@ def on_start(self, span: Span, parent_context) -> None:
4849
def on_end(self, span: ReadableSpan) -> None:
4950
"""
5051
Called when a span ends.
51-
52-
Note: For on_end modifications, use the span enricher pattern
53-
(enrich_semantic_kernel_span) which is registered with the core SDK.
54-
This ensures enriched attributes propagate to the exporter.
5552
"""
5653
pass
5754

0 commit comments

Comments
 (0)