Skip to content

Commit 4e3ad44

Browse files
authored
fix(telemetry): remove force_flush in tracer (#2142)
1 parent 8e96ea8 commit 4e3ad44

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

src/strands/telemetry/tracer.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ def _end_span(
218218
logger.warning("error=<%s> | error while ending span", e, exc_info=True)
219219
finally:
220220
span.end()
221-
# Force flush to ensure spans are exported
222-
if self.tracer_provider and hasattr(self.tracer_provider, "force_flush"):
223-
try:
224-
self.tracer_provider.force_flush()
225-
except Exception as e:
226-
logger.warning("error=<%s> | failed to force flush tracer provider", e)
227221

228222
def end_span_with_error(self, span: Span, error_message: str, exception: Exception | None = None) -> None:
229223
"""End a span with error status.

tests/strands/telemetry/test_tracer.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,21 +1221,6 @@ def test_end_span_with_exception_handling(mock_span):
12211221
pytest.fail("_end_span should not raise exceptions")
12221222

12231223

1224-
def test_force_flush_with_error(mock_span, mock_get_tracer_provider):
1225-
"""Test force flush with error handling."""
1226-
# Setup the tracer with a provider that raises an exception on force_flush
1227-
tracer = Tracer()
1228-
1229-
mock_tracer_provider = mock_get_tracer_provider.return_value
1230-
mock_tracer_provider.force_flush.side_effect = Exception("Force flush error")
1231-
1232-
# Should not raise an exception
1233-
tracer._end_span(mock_span)
1234-
1235-
# Verify force_flush was called
1236-
mock_tracer_provider.force_flush.assert_called_once()
1237-
1238-
12391224
def test_end_tool_call_span_with_none(mock_span):
12401225
"""Test ending a tool call span with None result."""
12411226
tracer = Tracer()

0 commit comments

Comments
 (0)