Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion elasticsearch/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down
10 changes: 9 additions & 1 deletion elasticsearch/_sync/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})


Expand Down
11 changes: 11 additions & 0 deletions test_elasticsearch/test_server/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
)
Expand Down
1 change: 1 addition & 0 deletions test_elasticsearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)