Skip to content

Conversation

beniwohli
Copy link
Contributor

What does this pull request do?

To make the current transaction/span available, we wrap the actual
callable with one of our own that sets the transaction/span in the
execution context of the thread.

Why is it important?

Using an executor (e.g. ThreadPoolExecutor) is a common way to use
blocking calls in an event loop.

To make the current transaction/span available, we wrap the actual callable with one of our own that sets the transaction/span in the execution context of the thread.

class RunInExecutorInstrumentation(AsyncAbstractInstrumentedModule):
name = "executor"
instrument_list = [("asyncio.base_events", "BaseEventLoop.run_in_executor")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might we worth checking if this would also work with uvloop (https://github.com/MagicStack/uvloop/blob/8beacd265651429a558d1b22e200d6d81016f1db/uvloop/loop.pyx#L2646), but I have my doubts, as wrapt can't patch objects defined in C AFAIK

@ghost
Copy link

ghost commented May 21, 2020

💔 Tests Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-11-16T16:27:30.517+0000

  • Duration: 28 min 29 sec

  • Commit: e2e7239

Test stats 🧪

Test Results
Failed 36
Passed 10258
Skipped 9537
Total 19831

Test errors 36

Expand to view the tests failures

> Show only the first 10 test failures

Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa3679c7df0> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> async def test_httpx_instrumentation(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" parsed_url = compat.urlparse.urlparse(url) elasticapm_client.begin_transaction("transaction.test") async with async_capture_span("test_request", "test"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:58: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa366f3c160> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> async def test_httpx_instrumentation_string_url(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" elasticapm_client.begin_transaction("transaction.test") async with async_capture_span("test_request", "test"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:94: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.8-0 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa366df0c10> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> async def test_url_sanitization(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" url = url.replace("http://", "http://user:pass@") transaction_object = elasticapm_client.begin_transaction("transaction") async with httpx.AsyncClient() as client: > await client.get(url) tests/instrumentation/asyncio_tests/httpx_tests.py:146: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.8-0 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa366d9bb50> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> status_code = 400 @pytest.mark.parametrize("status_code", [400, 500]) async def test_httpx_error(instrument, elasticapm_client, waiting_httpserver, status_code): waiting_httpserver.serve_content("", code=status_code) url = waiting_httpserver.url + "/hello_world" parsed_url = compat.urlparse.urlparse(url) elasticapm_client.begin_transaction("transaction") expected_sig = "GET {0}".format(parsed_url.netloc) url = "http://{0}/hello_world".format(parsed_url.netloc) async with async_capture_span("test_name", "test_type"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:165: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.8-0 / test_httpx_error[500] – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa366fd9cd0> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> status_code = 500 @pytest.mark.parametrize("status_code", [400, 500]) async def test_httpx_error(instrument, elasticapm_client, waiting_httpserver, status_code): waiting_httpserver.serve_content("", code=status_code) url = waiting_httpserver.url + "/hello_world" parsed_url = compat.urlparse.urlparse(url) elasticapm_client.begin_transaction("transaction") expected_sig = "GET {0}".format(parsed_url.netloc) url = "http://{0}/hello_world".format(parsed_url.netloc) async with async_capture_span("test_name", "test_type"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:165: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.8-0 / test_httpx_streaming – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7fa366c69bb0> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 140339794241280)> async def test_httpx_streaming(instrument, elasticapm_client, waiting_httpserver): # client.stream passes the request as a keyword argument to the instrumented method. # This helps test that we can handle it both as an arg and a kwarg # see https://github.com/elastic/apm-agent-python/issues/1336 elasticapm_client.begin_transaction("httpx-context-manager-client-streaming") client = httpx.AsyncClient() try: > async with client.stream("GET", url=waiting_httpserver.url) as response: tests/instrumentation/asyncio_tests/httpx_tests.py:187: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.8/contextlib.py:171: in __aenter__ return await self.gen.__anext__() /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1556: in stream response = await self.send( elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.8/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7fa367c091f0> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f008db2dc60> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 139640352925440)> async def test_httpx_instrumentation(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" parsed_url = compat.urlparse.urlparse(url) elasticapm_client.begin_transaction("transaction.test") async with async_capture_span("test_request", "test"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:58: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7f008dd58430> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f008dd59f00> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 139640352925440)> async def test_httpx_instrumentation_string_url(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" elasticapm_client.begin_transaction("transaction.test") async with async_capture_span("test_request", "test"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:94: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7f008dd58430> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.10-3 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f008ceb0610> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 139640352925440)> async def test_url_sanitization(instrument, elasticapm_client, waiting_httpserver): waiting_httpserver.serve_content("") url = waiting_httpserver.url + "/hello_world" url = url.replace("http://", "http://user:pass@") transaction_object = elasticapm_client.begin_transaction("transaction") async with httpx.AsyncClient() as client: > await client.get(url) tests/instrumentation/asyncio_tests/httpx_tests.py:146: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7f008dd58430> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Initializing / Test / Python-python-3.10-3 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
    Expand to view the error details

     AttributeError: 'Request' object has no attribute 'decode' 

    Expand to view the stacktrace

     instrument = None elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f008d052a40> waiting_httpserver = <ContentServer(<class 'pytest_localserver.http.ContentServer'>, started 139640352925440)> status_code = 400 @pytest.mark.parametrize("status_code", [400, 500]) async def test_httpx_error(instrument, elasticapm_client, waiting_httpserver, status_code): waiting_httpserver.serve_content("", code=status_code) url = waiting_httpserver.url + "/hello_world" parsed_url = compat.urlparse.urlparse(url) elasticapm_client.begin_transaction("transaction") expected_sig = "GET {0}".format(parsed_url.netloc) url = "http://{0}/hello_world".format(parsed_url.netloc) async with async_capture_span("test_name", "test_type"): async with httpx.AsyncClient() as client: > await client.get(url, **allow_redirects) tests/instrumentation/asyncio_tests/httpx_tests.py:165: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1736: in get return await self.request( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1513: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) elasticapm/instrumentation/packages/asyncio/httpx.py:56: in call response = await wrapped(*args, **kwargs) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1600: in send response = await self._send_handling_auth( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1628: in _send_handling_auth response = await self._send_handling_redirects( /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1665: in _send_handling_redirects response = await self._send_single_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_client.py:1702: in _send_single_request response = await transport.handle_async_request(request) /home/user/.local/lib/python3.10/site-packages/httpx/_transports/default.py:291: in handle_async_request resp = await self._pool.handle_async_request(req) /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:248: in handle_async_request raise exc /home/user/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:232: in handle_async_request response = await connection.handle_async_request(request) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <elasticapm.instrumentation.packages.asyncio.httpcore.HTTPCoreAsyncInstrumentation object at 0x7f008dd58430> module = 'httpcore._async.connection' method = 'AsyncHTTPConnection.handle_async_request' wrapped = <bound method AsyncHTTPConnection.handle_async_request of <AsyncHTTPConnection [CONNECTING]>> instance = <AsyncHTTPConnection [CONNECTING]>, args = (<Request [b'GET']>,) kwargs = {} async def call(self, module, method, wrapped, instance, args, kwargs): if "method" in kwargs: method = kwargs["method"].decode("utf-8") else: > method = args[0].decode("utf-8") E AttributeError: 'Request' object has no attribute 'decode' elasticapm/instrumentation/packages/asyncio/httpcore.py:60: AttributeError 

Steps errors 14

Expand to view the steps failures

Show only the first 10 steps failures

Shell Script
  • Took 0 min 23 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.8 httpx-newest
Shell Script
  • Took 0 min 23 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.8 httpx-newest
Shell Script
  • Took 0 min 23 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.9 httpx-newest
Shell Script
  • Took 0 min 23 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.9 httpx-newest
Shell Script
  • Took 0 min 28 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.10 httpx-newest
Shell Script
  • Took 0 min 27 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh python-3.10 httpx-newest
Shell Script
  • Took 1 min 23 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh pypy-3 httpx-newest
Shell Script
  • Took 1 min 19 sec . View more details here
  • Description: ./tests/scripts/docker/run_tests.sh pypy-3 httpx-newest
Archive the artifacts
  • Took 0 min 0 sec . View more details here
  • Description: [2021-11-16T16:55:57.081Z] Archiving artifacts Python-python-3.8-httpx-newest tests failed : hudson
Error signal
  • Took 0 min 1 sec . View more details here
  • Description: Python-python-3.6-httpx-newest tests failed : hudson.AbortException: script returned exit code 2

🐛 Flaky test report

❄️ The following tests failed but also have a history of flakiness and may not be related to this change:

Expand to view the summary

Genuine test errors 34

💔 There are test failures but not known flaky tests, most likely a genuine test failure.

  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_error[500] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_streaming – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_error[500] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_streaming – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_error[500] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_streaming – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_instrumentation – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_instrumentation_string_url – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_url_sanitization – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_error[400] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_error[500] – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_streaming – tests.instrumentation.asyncio_tests.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.8-0 / test_httpx_instrumentation_via_client – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.10-3 / test_httpx_instrumentation_via_client – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_instrumentation – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.9-0 / test_httpx_instrumentation_via_client – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_instrumentation – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.7-4 / test_httpx_instrumentation_via_client – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.6-4 / test_httpx_instrumentation – tests.instrumentation.httpx_tests
  • Name: Initializing / Test / Python-python-3.6-4 / test_httpx_instrumentation_via_client – tests.instrumentation.httpx_tests

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /test linters : Run the Python linters only.

  • /test full : Run the full matrix of tests.

  • /test benchmark : Run the APM Agent Python benchmarks tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants