From f2e58515505e5a1ed9d30342e23be5e75cae93c1 Mon Sep 17 00:00:00 2001 From: Yu Kun Date: Fri, 23 Aug 2019 17:38:31 +0800 Subject: [PATCH] modify CollectorMetrics in InsertVectors Former-commit-id: e00d68ca1be8407061f3ac6b9fc41fa36fe24b13 --- cpp/src/db/DBImpl.cpp | 6 +++--- cpp/src/metrics/Metrics.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp/src/db/DBImpl.cpp b/cpp/src/db/DBImpl.cpp index a09457d3..4299801c 100644 --- a/cpp/src/db/DBImpl.cpp +++ b/cpp/src/db/DBImpl.cpp @@ -141,9 +141,9 @@ Status DBImpl::InsertVectors(const std::string& table_id_, uint64_t n, const float* vectors, IDNumbers& vector_ids_) { ENGINE_LOG_DEBUG << "Insert " << n << " vectors to cache"; - auto start_time = METRICS_NOW_TIME; - Status status = mem_mgr_->InsertVectors(table_id_, n, vectors, vector_ids_); - zilliz::milvus::server::CollectInsertMetrics metrics(start_time, n, status.ok()); + Status status; + zilliz::milvus::server::CollectInsertMetrics metrics(n, status); + status = mem_mgr_->InsertVectors(table_id_, n, vectors, vector_ids_); // std::chrono::microseconds time_span = std::chrono::duration_cast(end_time - start_time); // double average_time = double(time_span.count()) / n; diff --git a/cpp/src/metrics/Metrics.h b/cpp/src/metrics/Metrics.h index bc47971b..98e7c306 100644 --- a/cpp/src/metrics/Metrics.h +++ b/cpp/src/metrics/Metrics.h @@ -32,8 +32,8 @@ class Metrics { class CollectInsertMetrics { public: - CollectInsertMetrics(std::chrono::system_clock::time_point start_time, - size_t n, bool succeed) : start_time_(start_time), n_(n), succeed_(succeed) { + CollectInsertMetrics(size_t n, engine::Status& status) : n_(n), status_(status) { + start_time_ = METRICS_NOW_TIME; } ~CollectInsertMetrics() { @@ -45,7 +45,7 @@ public: } // server::Metrics::GetInstance().add_vector_duration_seconds_quantiles().Observe((average_time)); - if (succeed_) { + if (status_.ok()) { server::Metrics::GetInstance().AddVectorsSuccessTotalIncrement(n_); server::Metrics::GetInstance().AddVectorsSuccessGaugeSet(n_); } @@ -59,7 +59,7 @@ private: using TIME_POINT = std::chrono::system_clock::time_point; TIME_POINT start_time_; size_t n_; - bool succeed_; + engine::Status& status_; }; class CollectQueryMetrics { -- GitLab