Skip to content

Commit 4044274

Browse files
committed
refactor: code style updates
1 parent 839eeae commit 4044274

File tree

1 file changed

+10
-10
lines changed
  • util/opentelemetry-util-genai/src/opentelemetry/util/genai

1 file changed

+10
-10
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,24 @@ def _apply_common_span_attributes(
4646
4747
Returns (genai_attributes) for use with metrics.
4848
"""
49-
request_model = invocation.request_model
50-
provider = invocation.provider
5149
span.update_name(
52-
f"{GenAI.GenAiOperationNameValues.CHAT.value} {request_model}".strip()
50+
f"{GenAI.GenAiOperationNameValues.CHAT.value} {invocation.request_model}".strip()
5351
)
5452
span.set_attribute(
5553
GenAI.GEN_AI_OPERATION_NAME, GenAI.GenAiOperationNameValues.CHAT.value
5654
)
57-
if request_model:
58-
span.set_attribute(GenAI.GEN_AI_REQUEST_MODEL, request_model)
59-
if provider is not None:
55+
if invocation.request_model:
56+
span.set_attribute(
57+
GenAI.GEN_AI_REQUEST_MODEL, invocation.request_model
58+
)
59+
if invocation.provider is not None:
6060
# TODO: clean provider name to match GenAiProviderNameValues?
61-
span.set_attribute(GenAI.GEN_AI_PROVIDER_NAME, provider)
61+
span.set_attribute(GenAI.GEN_AI_PROVIDER_NAME, invocation.provider)
6262

63-
finish_reasons = [gen.finish_reason for gen in invocation.output_messages]
64-
if finish_reasons:
63+
if invocation.output_messages:
6564
span.set_attribute(
66-
GenAI.GEN_AI_RESPONSE_FINISH_REASONS, finish_reasons
65+
GenAI.GEN_AI_RESPONSE_FINISH_REASONS,
66+
[gen.finish_reason for gen in invocation.output_messages],
6767
)
6868

6969
if invocation.response_model_name is not None:

0 commit comments

Comments
 (0)