Skip to content

Comments

Add Cluster Statistics (client.cluster.statistics())#1959

Merged
dirkkul merged 3 commits intomainfrom
MohamedShahin-Add-Cluster-Statistics
Feb 23, 2026
Merged

Add Cluster Statistics (client.cluster.statistics())#1959
dirkkul merged 3 commits intomainfrom
MohamedShahin-Add-Cluster-Statistics

Conversation

@Shah91n
Copy link
Member

@Shah91n Shah91n commented Feb 22, 2026

Summary

  • Add client.cluster.statistics().
  • Introduce RAFT statistics models in weaviate.cluster.models (ClusterStatistics, NodeStatistics, RaftStats, RaftConfigurationMember) to strongly type the full JSON response.
  • Export public types from weaviate.outputs.cluster so users can type‑hint ClusterStatistics and related models.
  • Wire up sync & async clients via _ClusterExecutor and update .pyi stubs for proper editor/type-checker support.

Server Details

Weaviate Client Version: 4.19.5.dev2+g420b1d0b7.d20260220
Weaviate Server Version: 1.35.9

Local Example

stat = client.cluster.statistics()
print("synchronized:", stat.synchronized)
for node in stat.statistics:
    print(node.name, node.status, node.raft.state)
image image image

Implementation Details

  • weaviate.cluster.base._ClusterExecutor.statistics() performs an authenticated HTTP GET /v1/cluster/statistics through the existing Connection.
  • Response JSON is decoded with _decode_json_response_dict and converted into the new dataclasses, including nested RAFT configuration members.

Testing

  • Mock tests: mock_tests/test_collection.py::test_cluster_statistics verifies the request path and response parsing from a mocked /v1/cluster/statistics endpoint.
  • Integration tests: integration/test_client.py::test_client_cluster_statistics exercises client.cluster.statistics() against a running Weaviate instance and asserts the basic shape/fields of the result.

Copilot AI review requested due to automatic review settings February 22, 2026 22:28
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new cluster API to retrieve RAFT cluster statistics from the Weaviate server and exposes strongly-typed response models so users can easily consume and type-hint the returned data.

Changes:

  • Add client.cluster.statistics() implemented via _ClusterExecutor.statistics() calling GET /v1/cluster/statistics.
  • Introduce dataclass models for the cluster statistics response (ClusterStatistics, NodeStatistics, RaftStats, RaftConfigurationMember).
  • Export new types + update sync/async .pyi stubs and add mock + integration tests for the new endpoint.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
weaviate/outputs/cluster.py Exposes cluster-related output types (now includes statistics models).
weaviate/cluster/sync.pyi Adds the typed sync stub for cluster.statistics().
weaviate/cluster/async_.pyi Adds the typed async stub for cluster.statistics().
weaviate/cluster/models.py Adds RAFT statistics dataclasses and decoding helpers.
weaviate/cluster/base.py Implements _ClusterExecutor.statistics() using the connection executor.
mock_tests/test_collection.py Adds a mock test validating request path and parsing into models.
integration/test_client.py Adds an integration test validating basic response shape/fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 98.85057% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.55%. Comparing base (fd58638) to head (c4c4ec2).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
weaviate/cluster/base.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1959      +/-   ##
==========================================
+ Coverage   86.45%   86.55%   +0.10%     
==========================================
  Files         274      276       +2     
  Lines       19966    20251     +285     
==========================================
+ Hits        17261    17528     +267     
- Misses       2705     2723      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Shah91n Shah91n self-assigned this Feb 23, 2026
@weaviate weaviate deleted a comment from Copilot AI Feb 23, 2026
@dirkkul dirkkul merged commit cb55792 into main Feb 23, 2026
119 of 121 checks passed
@dirkkul dirkkul deleted the MohamedShahin-Add-Cluster-Statistics branch February 23, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants