Skip to content
Draft
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
1 change: 1 addition & 0 deletions aerospike_helpers/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class Cluster:

Attributes:
cluster_name (Optional[str]): Expected cluster name for all nodes. May be :py:obj:`None`.
app_id (Optional[str]): Application identifier. May be :py:obj:`None`.
invalid_node_count (int): Count of add node failures in the most recent cluster tend iteration.
command_count (int): Command count. The value is cumulative and not reset per metrics interval.
retry_count (int): Command retry count. There can be multiple retries for a single command.
Expand Down
10 changes: 10 additions & 0 deletions src/main/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,16 @@ PyObject *create_py_cluster_from_as_cluster(as_error *error_p,
PyObject_SetAttrString(py_cluster, "cluster_name", Py_None);
}

// App Id is optional (declared in client config)
if (cluster->app_id) {
PyObject *py_app_id = PyUnicode_FromString(cluster->app_id);
PyObject_SetAttrString(py_cluster, "app_id", py_app_id);
Py_DECREF(py_app_id);
}
else {
PyObject_SetAttrString(py_cluster, "app_id", Py_None);
}

PyObject *py_invalid_node_count =
PyLong_FromUnsignedLong(cluster->invalid_node_count);
PyObject_SetAttrString(py_cluster, "invalid_node_count",
Expand Down
1 change: 1 addition & 0 deletions test/new_tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def test_setting_metrics_policy_custom_settings(self):
assert type(cluster.command_count) == int
assert type(cluster.retry_count) == int
assert type(cluster.nodes) == list
assert cluster.app_id is None or type(cluster.app_id) == str
# Also check the Node and ConnectionStats objects in the Cluster object were populated
for node in cluster.nodes:
assert type(node) == Node
Expand Down
5 changes: 4 additions & 1 deletion test/standalone/test_ext_metrics_cluster_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"hosts": [
("127.0.0.1", 3000)
],
"cluster_name": "docker"
"cluster_name": "docker",
"app_id": "PythonClientTest"
}
print("Connecting to server...")
as_client = aerospike.client(config)
Expand All @@ -35,12 +36,14 @@ def snapshot(cluster: Cluster):
global snapshot_triggered
snapshot_triggered = True
assert cluster.cluster_name == "docker"
assert cluster.app_id == "PythonClientTest"

def disable(cluster: Cluster):
print(f"Disable listener run. Cluster name: {cluster.cluster_name}")
global disable_triggered
disable_triggered = True
assert cluster.cluster_name == "docker"
assert cluster.app_id == "PythonClientTest"

def node_close(_: Node):
pass
Expand Down
Loading