Skip to content

Commit b2cceb5

Browse files
authored
.Net: Update OTel GenAI operation names (#13334)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> OTel GenAI operation names have the following updates: 1. `chat.completion` to `chat` 2. `text.completion` to `text_completion` ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This PR updates those operation names ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 2464458 commit b2cceb5

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

dotnet/src/InternalUtilities/src/Diagnostics/ModelDiagnostics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal static class ModelDiagnostics
5353
return null;
5454
}
5555

56-
const string OperationName = "text.completions";
56+
const string OperationName = "text_completion";
5757
var activity = s_activitySource.StartActivityWithTags(
5858
$"{OperationName} {modelName}",
5959
[
@@ -105,7 +105,7 @@ internal static class ModelDiagnostics
105105
return null;
106106
}
107107

108-
const string OperationName = "chat.completions";
108+
const string OperationName = "chat";
109109
var activity = s_activitySource.StartActivityWithTags(
110110
$"{OperationName} {modelName}",
111111
[

python/semantic_kernel/utils/telemetry/model_diagnostics/decorators.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
MODEL_DIAGNOSTICS_SETTINGS = ModelDiagnosticSettings()
3535

3636
# Operation names
37-
CHAT_COMPLETION_OPERATION = "chat.completions"
38-
CHAT_STREAMING_COMPLETION_OPERATION = "chat.streaming_completions"
39-
TEXT_COMPLETION_OPERATION = "text.completions"
40-
TEXT_STREAMING_COMPLETION_OPERATION = "text.streaming_completions"
37+
CHAT_COMPLETION_OPERATION = "chat"
38+
TEXT_COMPLETION_OPERATION = "text_completions"
4139

4240

4341
# We're recording multiple events for the chat history, some of them are emitted within (hundreds of)
@@ -174,7 +172,7 @@ async def wrapper_decorator(
174172

175173
with use_span(
176174
_get_completion_span(
177-
CHAT_STREAMING_COMPLETION_OPERATION,
175+
CHAT_COMPLETION_OPERATION,
178176
completion_service.ai_model_id,
179177
model_provider,
180178
completion_service.service_url(),
@@ -288,7 +286,7 @@ async def wrapper_decorator(*args: Any, **kwargs: Any) -> AsyncGenerator[list["S
288286

289287
with use_span(
290288
_get_completion_span(
291-
TEXT_STREAMING_COMPLETION_OPERATION,
289+
TEXT_COMPLETION_OPERATION,
292290
completion_service.ai_model_id,
293291
model_provider,
294292
completion_service.service_url(),

python/tests/integration/completions/test_text_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ def services(self) -> dict[str, tuple[ServiceType | None, type[PromptExecutionSe
233233
),
234234
"hf_summ": (
235235
HuggingFaceTextCompletion(
236-
service_id="jotamunz/billsum_tiny_summarization",
237-
ai_model_id="jotamunz/billsum_tiny_summarization",
236+
service_id="Falconsai/text_summarization",
237+
ai_model_id="Falconsai/text_summarization",
238238
task="summarization",
239239
)
240240
if hugging_face_setup

python/tests/unit/connectors/ai/hugging_face/test_hf_text_completions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"translate English to Dutch: Hello, how are you?",
2424
),
2525
(
26-
"jotamunz/billsum_tiny_summarization",
26+
"Falconsai/text_summarization",
2727
"summarization",
2828
"""
2929
Summarize: Whales are fully aquatic, open-ocean animals:

python/tests/unit/utils/model_diagnostics/test_trace_streaming_chat_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from semantic_kernel.exceptions.service_exceptions import ServiceResponseException
1717
from semantic_kernel.utils.telemetry.model_diagnostics import gen_ai_attributes
1818
from semantic_kernel.utils.telemetry.model_diagnostics.decorators import (
19-
CHAT_STREAMING_COMPLETION_OPERATION,
19+
CHAT_COMPLETION_OPERATION,
2020
ChatHistoryMessageTimestampFilter,
2121
trace_streaming_chat_completion,
2222
)
@@ -119,7 +119,7 @@ async def test_trace_streaming_chat_completion(
119119

120120
# Before the call to the model
121121
mock_span.set_attributes.assert_called_with({
122-
gen_ai_attributes.OPERATION: CHAT_STREAMING_COMPLETION_OPERATION,
122+
gen_ai_attributes.OPERATION: CHAT_COMPLETION_OPERATION,
123123
gen_ai_attributes.SYSTEM: MockChatCompletion.MODEL_PROVIDER_NAME,
124124
gen_ai_attributes.MODEL: chat_completion.ai_model_id,
125125
})

python/tests/unit/utils/model_diagnostics/test_trace_streaming_text_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from semantic_kernel.exceptions.service_exceptions import ServiceResponseException
1515
from semantic_kernel.utils.telemetry.model_diagnostics import gen_ai_attributes
1616
from semantic_kernel.utils.telemetry.model_diagnostics.decorators import (
17-
TEXT_STREAMING_COMPLETION_OPERATION,
17+
TEXT_COMPLETION_OPERATION,
1818
trace_streaming_text_completion,
1919
)
2020
from tests.unit.utils.model_diagnostics.conftest import MockTextCompletion
@@ -98,7 +98,7 @@ async def test_trace_streaming_text_completion(
9898

9999
# Before the call to the model
100100
mock_span.set_attributes.assert_called_with({
101-
gen_ai_attributes.OPERATION: TEXT_STREAMING_COMPLETION_OPERATION,
101+
gen_ai_attributes.OPERATION: TEXT_COMPLETION_OPERATION,
102102
gen_ai_attributes.SYSTEM: MockTextCompletion.MODEL_PROVIDER_NAME,
103103
gen_ai_attributes.MODEL: text_completion.ai_model_id,
104104
})

0 commit comments

Comments
 (0)