Skip to content

Commit 332ea81

Browse files
committed
Remove InferenceOperationType.TEXT_COMPLETION, InferenceOperationType.GENERATE_CONTENT from the list
1 parent 94bb019 commit 332ea81

3 files changed

Lines changed: 21 additions & 35 deletions

File tree

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from opentelemetry.trace import StatusCode
1919

2020
from .utils import (
21-
INFERENCE_OPERATION_TYPE_NAMES,
2221
build_export_url,
2322
get_validated_domain_override,
2423
hex_span_id,
@@ -29,7 +28,6 @@
2928
status_name,
3029
truncate_span,
3130
)
32-
from ..constants import CHAT_OPERATION_NAME, GEN_AI_OPERATION_NAME_KEY
3331

3432
# ---- Exporter ---------------------------------------------------------------
3533

@@ -279,14 +277,6 @@ def _map_span(self, sp: ReadableSpan) -> dict[str, Any]:
279277
# attributes
280278
attrs = dict(sp.attributes or {})
281279

282-
# Normalize gen_ai.operation.name from any InferenceOperationType enum
283-
# value (Chat, TextCompletion, GenerateContent) to the canonical "chat"
284-
# value the ingest service accepts. This is applied only on the export
285-
# payload; the underlying span attribute is left untouched.
286-
op_name = attrs.get(GEN_AI_OPERATION_NAME_KEY)
287-
if isinstance(op_name, str) and op_name in INFERENCE_OPERATION_TYPE_NAMES:
288-
attrs[GEN_AI_OPERATION_NAME_KEY] = CHAT_OPERATION_NAME
289-
290280
# events
291281
events = []
292282
for ev in sp.events:

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@
4040
OUTPUT_MESSAGES_OPERATION_NAME,
4141
CHAT_OPERATION_NAME,
4242
InferenceOperationType.CHAT.value,
43-
InferenceOperationType.TEXT_COMPLETION.value,
44-
InferenceOperationType.GENERATE_CONTENT.value,
45-
}
46-
)
47-
48-
# Inference operation type values that the ingest service expects to be
49-
# normalized to the canonical "chat" gen_ai.operation.name.
50-
INFERENCE_OPERATION_TYPE_NAMES: frozenset[str] = frozenset(
51-
{
52-
InferenceOperationType.CHAT.value,
53-
InferenceOperationType.TEXT_COMPLETION.value,
54-
InferenceOperationType.GENERATE_CONTENT.value,
5543
}
5644
)
5745

tests/observability/core/test_agent365_exporter.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,27 @@ def test_export_filters_out_only_non_genai_spans_returns_success(self):
703703
self.assertEqual(result, SpanExportResult.SUCCESS)
704704
mock_post.assert_not_called()
705705

706-
def test_export_includes_inference_operation_type_spans(self):
707-
"""Spans with InferenceOperationType enum values are kept and normalized."""
708-
# Arrange
706+
def test_export_includes_inference_operation_type_chat_spans(self):
707+
"""Spans with InferenceOperationType.CHAT value ('Chat') are kept without normalization."""
708+
# Arrange — server accepts 'Chat' via case-insensitive matching
709709
chat_span = self._create_mock_span(
710710
"chat_span", trace_id=1, span_id=2, operation_name="Chat"
711711
)
712+
713+
with patch.object(self.exporter, "_post_with_retries", return_value=True) as mock_post:
714+
result = self.exporter.export([chat_span])
715+
716+
self.assertEqual(result, SpanExportResult.SUCCESS)
717+
mock_post.assert_called_once()
718+
_, body, _ = mock_post.call_args[0]
719+
request_data = json.loads(body)
720+
spans_out = request_data["resourceSpans"][0]["scopeSpans"][0]["spans"]
721+
self.assertEqual(len(spans_out), 1)
722+
# Value is preserved as-is; no normalization
723+
self.assertEqual(spans_out[0]["attributes"]["gen_ai.operation.name"], "Chat")
724+
725+
def test_export_filters_out_unsupported_inference_operation_types(self):
726+
"""Spans with TextCompletion / GenerateContent are filtered out."""
712727
text_completion_span = self._create_mock_span(
713728
"text_completion_span", trace_id=3, span_id=4, operation_name="TextCompletion"
714729
)
@@ -717,18 +732,11 @@ def test_export_includes_inference_operation_type_spans(self):
717732
)
718733

719734
with patch.object(self.exporter, "_post_with_retries", return_value=True) as mock_post:
720-
# Act
721-
result = self.exporter.export([chat_span, text_completion_span, generate_content_span])
735+
result = self.exporter.export([text_completion_span, generate_content_span])
722736

723-
# Assert: all three are exported and normalized to "chat"
737+
# Both are filtered out — nothing to export
724738
self.assertEqual(result, SpanExportResult.SUCCESS)
725-
mock_post.assert_called_once()
726-
_, body, _ = mock_post.call_args[0]
727-
request_data = json.loads(body)
728-
spans_out = request_data["resourceSpans"][0]["scopeSpans"][0]["spans"]
729-
self.assertEqual(len(spans_out), 3)
730-
for span in spans_out:
731-
self.assertEqual(span["attributes"]["gen_ai.operation.name"], "chat")
739+
mock_post.assert_not_called()
732740

733741
def test_export_does_not_normalize_canonical_operation_names(self):
734742
"""invoke_agent / execute_tool / output_messages / chat are not rewritten."""

0 commit comments

Comments
 (0)