|
|
@@ -736,6 +736,44 @@ public:
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+ std::optional<Client::StatsInfo> getStats() {
|
|
|
+ smartbotic::databasepb::GetStatsRequest request;
|
|
|
+
|
|
|
+ smartbotic::databasepb::GetStatsResponse response;
|
|
|
+ grpc::ClientContext context;
|
|
|
+ setDeadline(context);
|
|
|
+
|
|
|
+ auto status = stub_->GetStats(&context, request, &response);
|
|
|
+ if (!status.ok()) {
|
|
|
+ return std::nullopt;
|
|
|
+ }
|
|
|
+
|
|
|
+ Client::StatsInfo info;
|
|
|
+ info.totalDocuments = response.total_documents();
|
|
|
+ info.totalCollections = response.total_collections();
|
|
|
+ info.memoryUsedBytes = response.memory_used_bytes();
|
|
|
+ info.walSequence = response.wal_sequence();
|
|
|
+ info.walSizeBytes = response.wal_size_bytes();
|
|
|
+ info.snapshotCount = response.snapshot_count();
|
|
|
+ info.lastSnapshotSequence = response.last_snapshot_sequence();
|
|
|
+ info.insertCount = response.insert_count();
|
|
|
+ info.updateCount = response.update_count();
|
|
|
+ info.deleteCount = response.delete_count();
|
|
|
+ info.queryCount = response.query_count();
|
|
|
+
|
|
|
+ // Memory eviction stats
|
|
|
+ info.evictedDocuments = response.evicted_documents();
|
|
|
+ info.totalEvictions = response.total_evictions();
|
|
|
+ info.recoveryCount = response.recovery_count();
|
|
|
+
|
|
|
+ // Memory configuration
|
|
|
+ info.maxMemoryBytes = response.max_memory_bytes();
|
|
|
+ info.evictionThresholdPercent = response.eviction_threshold_percent();
|
|
|
+ info.evictionTargetPercent = response.eviction_target_percent();
|
|
|
+
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
void setDeadline(grpc::ClientContext& context) {
|
|
|
context.set_deadline(
|
|
|
@@ -885,4 +923,8 @@ std::optional<Client::HealthInfo> Client::getHealthInfo() {
|
|
|
return impl_->getHealthInfo();
|
|
|
}
|
|
|
|
|
|
+std::optional<Client::StatsInfo> Client::getStats() {
|
|
|
+ return impl_->getStats();
|
|
|
+}
|
|
|
+
|
|
|
} // namespace smartbotic::database
|