elastic / elastic/apm-agent-python

More transport flaky tests

オープン
#2,382 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
agent-python
主要言語
Python
スター
431
フォーク
239
平均マージ
5日 10時間
マージ済み PR(30日)
7

説明

```
____________ test_flushed_arg_with_wait[sending_elasticapm_client0] ____________

sending_elasticapm_client =

@pytest.mark.skipif(platform.system() == "Windows", reason="Flaky test on windows")
@pytest.mark.flaky(reruns=3) # Trying to test automatic flushes is inherently flaky
@pytest.mark.parametrize("sending_elasticapm_client", [{"api_request_time": "100ms"}], indirect=True)
def test_flushed_arg_with_wait(sending_elasticapm_client):
sending_elasticapm_client.begin_transaction("test_type")
sending_elasticapm_client.end_transaction("test")
time.sleep(0.3)
sending_elasticapm_client._transport.flush()

> assert sending_elasticapm_client.httpserver.requests[1].args["flushed"] == "true"
E IndexError: list index out of range

sending_elasticapm_client =

tests/transports/test_base.py:289: IndexError
----------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-08-04T02:52:17.556Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
127.0.0.1 - - [04/Aug/2025 02:52:17] "POST /intake/v2/events HTTP/1.1" 202 -
------------------------------ Captured log call -------------------------------
{"@timestamp":"2025-08-04T02:52:17.556Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
--------------------------- Captured stderr teardown ---------------------------
{"@timestamp":"2025-08-04T02:52:17.761Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events?flushed=true HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events?flushed=true HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
127.0.0.1 - - [04/Aug/2025 02:52:17] "POST /intake/v2/events?flushed=true HTTP/1.1" 202 -
----------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-08-04T02:52:18.380Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","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 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.382Z","log.level":"warning","message":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.383Z","log.level":"warning","message":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.384Z","log.level":"error","message":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'","ecs.version":"1.6.0","log":{"logger":"elasticapm.transport","origin":{"file":{"line":322,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'
{"@timestamp":"2025-08-04T02:52:18.579Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","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 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.580Z","log.level":"warning","message":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.582Z","log.level":"warning","message":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.583Z","log.level":"error","message":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'","ecs.version":"1.6.0","log":{"logger":"elasticapm.transport","origin":{"file":{"line":322,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

tests/transports/test_base.pyから始め、特にtest_flushed_arg_with_waitとそのsending_elasticapm_client fixtureを確認してください。失敗を再現し、_transport.flush()周辺のtransport requestのタイミングを調べます。完了条件は、テストが断続的なIndexErrorなしにflushed=trueリクエストを確実に検証することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。