Skip to content

Commit 168d40e

Browse files
committed
Rename span_attr to request_attr
1 parent 1c12412 commit 168d40e

File tree

1 file changed

+10
-11
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2

1 file changed

+10
-11
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,22 +291,21 @@ def _record_metrics(
291291
instruments: Instruments,
292292
duration: float,
293293
result,
294-
span_attributes: dict,
294+
request_attributes: dict,
295295
error_type: Optional[str],
296296
operation_name: str,
297297
):
298-
"""Generalized function to record metrics for both chat and embeddings operations."""
299298
common_attributes = {
300299
GenAIAttributes.GEN_AI_OPERATION_NAME: operation_name,
301300
GenAIAttributes.GEN_AI_SYSTEM: GenAIAttributes.GenAiSystemValues.OPENAI.value,
302-
GenAIAttributes.GEN_AI_REQUEST_MODEL: span_attributes[
301+
GenAIAttributes.GEN_AI_REQUEST_MODEL: request_attributes[
303302
GenAIAttributes.GEN_AI_REQUEST_MODEL
304303
],
305304
}
306305

307-
if "gen_ai.embeddings.dimension.count" in span_attributes:
306+
if "gen_ai.embeddings.dimension.count" in request_attributes:
308307
common_attributes["gen_ai.embeddings.dimension.count"] = (
309-
span_attributes["gen_ai.embeddings.dimension.count"]
308+
request_attributes["gen_ai.embeddings.dimension.count"]
310309
)
311310

312311
if error_type:
@@ -325,13 +324,13 @@ def _record_metrics(
325324
result.system_fingerprint
326325
)
327326

328-
if ServerAttributes.SERVER_ADDRESS in span_attributes:
329-
common_attributes[ServerAttributes.SERVER_ADDRESS] = span_attributes[
330-
ServerAttributes.SERVER_ADDRESS
331-
]
327+
if ServerAttributes.SERVER_ADDRESS in request_attributes:
328+
common_attributes[ServerAttributes.SERVER_ADDRESS] = (
329+
request_attributes[ServerAttributes.SERVER_ADDRESS]
330+
)
332331

333-
if ServerAttributes.SERVER_PORT in span_attributes:
334-
common_attributes[ServerAttributes.SERVER_PORT] = span_attributes[
332+
if ServerAttributes.SERVER_PORT in request_attributes:
333+
common_attributes[ServerAttributes.SERVER_PORT] = request_attributes[
335334
ServerAttributes.SERVER_PORT
336335
]
337336

0 commit comments

Comments
 (0)