Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Expose number of pending writes as metric.
Kishore Nallane3bf9f02d669
diff --git a/include/http_server.h b/include/http_server.hindex 97b4b508..5f73ee9c 100644--- a/include/http_server.h+++ b/include/http_server.h@@ -224,4 +224,6 @@ public:bool trigger_vote();void persist_applying_index();++ int64_t get_num_queued_writes();};diff --git a/include/raft_server.h b/include/raft_server.hindex 101f7e9d..f09b96f8 100644--- a/include/raft_server.h+++ b/include/raft_server.h@@ -210,6 +210,8 @@ public:static std::string resolve_node_hosts(const std::string& nodes_config);+ int64_t get_num_queued_writes();+private:friend class ReplicationClosure;diff --git a/src/core_api.cpp b/src/core_api.cppindex cbfd2171..ef7c9c1d 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -187,6 +187,7 @@ bool get_metrics_json(const std::shared_ptr<http_req>& req, const std::shared_ptbool get_stats_json(const std::shared_ptr<http_req>& req, const std::shared_ptr<http_res>& res) {nlohmann::json result;AppMetrics::get_instance().get("requests_per_second", "latency_ms", result);+ result["pending_write_batches"] = server->get_num_queued_writes();res->set_body(200, result.dump(2));return true;diff --git a/src/http_server.cpp b/src/http_server.cppindex 453f2bae..e78a8a96 100644--- a/src/http_server.cpp+++ b/src/http_server.cpp@@ -1021,3 +1021,6 @@ void HttpServer::persist_applying_index() {return replication_state->persist_applying_index();}+int64_t HttpServer::get_num_queued_writes() {+ return replication_state->get_num_queued_writes();+}diff --git a/src/raft_server.cpp b/src/raft_server.cppindex 9367bafc..d6391be8 100644--- a/src/raft_server.cpp+++ b/src/raft_server.cpp@@ -775,6 +775,10 @@ void ReplicationState::persist_applying_index() {meta_store->insert(key, std::to_string(write_log_index));}+int64_t ReplicationState::get_num_queued_writes() {+ return batched_indexer->get_queued_writes();+}+void OnDemandSnapshotClosure::Run() {// Auto delete this after Done()std::unique_ptr<OnDemandSnapshotClosure> self_guard(this);