-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Labels
Description
________ test_send_remote_failover_sync_non_transport_exception_error _________
should_try = <MagicMock name='should_try' id='1774992538976'>
caplog = <_pytest.logging.LogCaptureFixture object at 0x0000019D45CCBE80>
@mock.patch("elasticapm.transport.base.TransportState.should_try", return_value=True)
def test_send_remote_failover_sync_non_transport_exception_error(should_try, caplog):
client = Client(
server_url="http://example.com/",
service_name="app_name",
secret_token="secret",
transport_class="tests.fixtures.MockSendHTTPTransport",
metrics_interval="0ms",
metrics_sets=[],
)
# test error
client._transport.send_mock.side_effect = ValueError("oopsie")
with caplog.at_level("ERROR", "elasticapm.transport"):
client.capture_message("foo", handled=False)
try:
client._transport.flush()
except ValueError:
# give flush a bit more room because we may take a bit more than the max timeout to flush
client._transport._flushed.wait(timeout=1)
> assert client._transport.state.did_fail()
E assert False
E + where False = <bound method TransportState.did_fail of <elasticapm.transport.base.TransportState object at 0x0000019D45CCD850>>()
E + where <bound method TransportState.did_fail of <elasticapm.transport.base.TransportState object at 0x0000019D45CCD850>> = <elasticapm.transport.base.TransportState object at 0x0000019D45CCD850>.did_fail
E + where <elasticapm.transport.base.TransportState object at 0x0000019D45CCD850> = <tests.fixtures.MockSendHTTPTransport object at 0x0000019D45CCD820>.state
E + where <tests.fixtures.MockSendHTTPTransport object at 0x0000019D45CCD820> = <elasticapm.base.Client object at 0x0000019D45CCBD30>._transport
tests\client\client_tests.py:297: AssertionError
---------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-12-16T02:38:16.408Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError(\"HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)\")': /","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError(\"HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)\")': /"},"process":{"name":"MainProcess","pid":3960,"thread":{"id":6368,"name":"eapm event processor thread"}},"service":{"name":"app_name"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)")': /