Skip to content

Commit 9837d18

Browse files
committed
instrumentation-google-genai: simplify event attributes assertions in tests
1 parent 3335e96 commit 9837d18

File tree

1 file changed

+4
-9
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content

1 file changed

+4
-9
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/nonstreaming_base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from google.genai.types import GenerateContentConfig
2121
from pydantic import BaseModel, Field
2222

23-
from opentelemetry._events import Event
2423
from opentelemetry.instrumentation._semconv import (
2524
_OpenTelemetrySemanticConventionStability,
2625
_OpenTelemetryStabilitySignalType,
@@ -324,7 +323,7 @@ def test_new_semconv_record_completion_as_log(self):
324323
event.attributes,
325324
)
326325
else:
327-
attrs = {
326+
expected_event_attributes = {
328327
gen_ai_attributes.GEN_AI_INPUT_MESSAGES: (
329328
{
330329
"role": "user",
@@ -346,31 +345,27 @@ def test_new_semconv_record_completion_as_log(self):
346345
{"content": sys_instr, "type": "text"},
347346
),
348347
}
349-
expected_event = Event(
350-
"gen_ai.client.inference.operation.details",
351-
attributes=attrs,
352-
)
353348
self.assertEqual(
354349
event.attributes[
355350
gen_ai_attributes.GEN_AI_INPUT_MESSAGES
356351
],
357-
expected_event.attributes[
352+
expected_event_attributes[
358353
gen_ai_attributes.GEN_AI_INPUT_MESSAGES
359354
],
360355
)
361356
self.assertEqual(
362357
event.attributes[
363358
gen_ai_attributes.GEN_AI_OUTPUT_MESSAGES
364359
],
365-
expected_event.attributes[
360+
expected_event_attributes[
366361
gen_ai_attributes.GEN_AI_OUTPUT_MESSAGES
367362
],
368363
)
369364
self.assertEqual(
370365
event.attributes[
371366
gen_ai_attributes.GEN_AI_SYSTEM_INSTRUCTIONS
372367
],
373-
expected_event.attributes[
368+
expected_event_attributes[
374369
gen_ai_attributes.GEN_AI_SYSTEM_INSTRUCTIONS
375370
],
376371
)

0 commit comments

Comments
 (0)