diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 8c7466a45..15213a6c9 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -504,6 +504,7 @@ async def ping( """ __path = "/" __query: t.Dict[str, t.Any] = {} + __path_parts: t.Dict[str, str] = {} if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: @@ -515,7 +516,12 @@ async def ping( __headers = {"accept": "application/json"} try: await self.perform_request( - "HEAD", __path, params=__query, headers=__headers + "HEAD", + __path, + params=__query, + headers=__headers, + endpoint_id="ping", + path_parts=__path_parts, ) return True except (ApiError, TransportError): diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 498f411c1..bd41b710b 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -504,6 +504,7 @@ def ping( """ __path = "/" __query: t.Dict[str, t.Any] = {} + __path_parts: t.Dict[str, str] = {} if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: @@ -514,7 +515,14 @@ def ping( __query["pretty"] = pretty __headers = {"accept": "application/json"} try: - self.perform_request("HEAD", __path, params=__query, headers=__headers) + self.perform_request( + "HEAD", + __path, + params=__query, + headers=__headers, + endpoint_id="ping", + path_parts=__path_parts, + ) return True except (ApiError, TransportError): return False diff --git a/noxfile.py b/noxfile.py index ca7f028d2..4bf3d04df 100644 --- a/noxfile.py +++ b/noxfile.py @@ -60,7 +60,7 @@ def test_otel(session): silent=False, ) - argv = pytest_argv() + ["-m", "otel"] + argv = pytest_argv() + ["-m", "otel"] + session.posargs session.run(*argv, env={"TEST_WITH_OTEL": "1"}) diff --git a/test_elasticsearch/test_server/test_otel.py b/test_elasticsearch/test_server/test_otel.py index e0b0cc776..6673e5537 100644 --- a/test_elasticsearch/test_server/test_otel.py +++ b/test_elasticsearch/test_server/test_otel.py @@ -53,6 +53,17 @@ def test_otel_end_to_end(sync_client): assert expected_attributes.items() <= spans[0].attributes.items() +# Since ping is manually implemented, we have a dedicated test for it +def test_otel_ping(sync_client): + tracer, memory_exporter = setup_tracing() + sync_client._otel.tracer = tracer + + sync_client.ping() + spans = memory_exporter.get_finished_spans() + assert len(spans) == 1 + assert spans[0].name == "ping" + + @pytest.mark.parametrize( "bulk_helper_name", ["bulk", "streaming_bulk", "parallel_bulk"] ) diff --git a/test_elasticsearch/utils.py b/test_elasticsearch/utils.py index cfcb5259c..4455462d2 100644 --- a/test_elasticsearch/utils.py +++ b/test_elasticsearch/utils.py @@ -191,3 +191,4 @@ def wait_for_cluster_state_updates_to_finish(client, timeout=30): while time.time() < end_time: if not client.cluster.pending_tasks().get("tasks", ()): break + time.sleep(0.1)