From 8e667dee8d867775db9297943923a4bac3a617a2 Mon Sep 17 00:00:00 2001 From: Ali Waleed Date: Tue, 22 Oct 2024 07:08:08 +0300 Subject: [PATCH] cleanup --- .../src/opentelemetry/instrumentation/openai_v2/patch.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py b/instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py index be3534e233..e139a799cb 100644 --- a/instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py +++ b/instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py @@ -54,6 +54,7 @@ def traced_method(wrapped, instance, args, kwargs): name=span_name, kind=SpanKind.CLIENT, attributes=span_attributes ) if span.is_recording(): + _set_input_attributes(span, span_attributes) set_event_prompt(span, json.dumps(llm_prompts)) try: @@ -83,6 +84,12 @@ def traced_method(wrapped, instance, args, kwargs): return traced_method +@silently_fail +def _set_input_attributes(span, attributes): + for field, value in attributes.items(): + set_span_attribute(span, field, value) + + @silently_fail def _set_response_attributes(span, result): set_span_attribute(