Skip to content

Commit 5b5743b

Browse files
committed
Use end_on_exit
1 parent ebb728a commit 5b5743b

File tree

1 file changed

+2
-4
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def traced_method(wrapped, instance, args, kwargs):
184184
name=span_name,
185185
kind=SpanKind.CLIENT,
186186
attributes=span_attributes,
187-
end_on_exit=False,
187+
end_on_exit=True,
188188
) as span:
189189
# Store the input for later use in the response attributes
190190
input_text = kwargs.get("input", "")
@@ -200,7 +200,6 @@ def traced_method(wrapped, instance, args, kwargs):
200200
span, result, event_logger, capture_content, input_text
201201
)
202202

203-
span.end()
204203
return result
205204

206205
except Exception as error:
@@ -249,7 +248,7 @@ async def traced_method(wrapped, instance, args, kwargs):
249248
name=span_name,
250249
kind=SpanKind.CLIENT,
251250
attributes=span_attributes,
252-
end_on_exit=False,
251+
end_on_exit=True,
253252
) as span:
254253
# Store the input for later use in the response attributes
255254
input_text = kwargs.get("input", "")
@@ -265,7 +264,6 @@ async def traced_method(wrapped, instance, args, kwargs):
265264
span, result, event_logger, capture_content, input_text
266265
)
267266

268-
span.end()
269267
return result
270268

271269
except Exception as error:

0 commit comments

Comments
 (0)