diff --git a/curvefs/src/client/kvclient/kvclient_manager.cpp b/curvefs/src/client/kvclient/kvclient_manager.cpp index c87630758b..9e677cc212 100644 --- a/curvefs/src/client/kvclient/kvclient_manager.cpp +++ b/curvefs/src/client/kvclient/kvclient_manager.cpp @@ -62,10 +62,12 @@ void KVClientManager::Uninit() { } void KVClientManager::Set(std::shared_ptr task) { + kvClientManagerMetric_->setQueueSize << 1; threadPool_.Enqueue([task, this]() { std::string error_log; task->res = client_->Set(task->key, task->value, task->length, &error_log); + kvClientManagerMetric_->setQueueSize << -1; if (task->res) { kvClientManagerMetric_->count << 1; } @@ -96,12 +98,14 @@ void UpdateHitMissMetric(memcached_return_t retCode, } void KVClientManager::Get(std::shared_ptr task) { + kvClientManagerMetric_->getQueueSize << 1; threadPool_.Enqueue([task, this]() { std::string error_log; memcached_return_t retCode; task->res = client_->Get(task->key, task->value, task->offset, task->valueLength, &error_log, &task->length, &retCode); + kvClientManagerMetric_->getQueueSize << -1; UpdateHitMissMetric(retCode, kvClientManagerMetric_.get()); OnReturn(&kvClientManagerMetric_->get, task); }); diff --git a/curvefs/src/client/metric/client_metric.h b/curvefs/src/client/metric/client_metric.h index bfbf0f3373..25c45acbd9 100644 --- a/curvefs/src/client/metric/client_metric.h +++ b/curvefs/src/client/metric/client_metric.h @@ -317,6 +317,10 @@ struct KVClientManagerMetric { bvar::Adder hit; // kvcache miss bvar::Adder miss; + // kvcache getQueueSize + bvar::Adder getQueueSize; + // kvcache setQueueSize + bvar::Adder setQueueSize; explicit KVClientManagerMetric(const std::string& name = "") : fsName(!name.empty() ? name @@ -325,7 +329,9 @@ struct KVClientManagerMetric { set(prefix, fsName + "_set"), count(prefix, fsName + "_count"), hit(prefix, fsName + "_hit"), - miss(prefix, fsName + "_miss") {} + miss(prefix, fsName + "_miss"), + getQueueSize(prefix, fsName + "_get_queue_size"), + setQueueSize(prefix, fsName + "_set_queue_size") {} }; struct MemcacheClientMetric {