Skip to content

Commit ebb27e0

Browse files
committed
End span only if it's still recording in stream done callbacks
1 parent fcbc7fb commit ebb27e0

File tree

1 file changed

+4
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions

1 file changed

+4
-2
lines changed

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ def stream_done_callback(response):
644644
self._converse_on_success(
645645
span, response, instrumentor_context, capture_content
646646
)
647-
span.end()
647+
if span.is_recording():
648+
span.end()
648649

649650
def stream_error_callback(exception):
650651
self._on_stream_error_callback(
@@ -684,7 +685,8 @@ def invoke_model_stream_done_callback(response):
684685
self._converse_on_success(
685686
span, response, instrumentor_context, capture_content
686687
)
687-
span.end()
688+
if span.is_recording():
689+
span.end()
688690

689691
def invoke_model_stream_error_callback(exception):
690692
self._on_stream_error_callback(

0 commit comments

Comments
 (0)