From c0a52a28bc06d7b62b40a3afd9d668836ced368e Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Mon, 3 Aug 2015 16:56:16 +0300 Subject: [PATCH] Adding the read latency support to the storage proxy This adds the latency histogram support to the storage_proxy. It uses a the latency object to mark the opetation latency, if there will be an impact on performance, it can be changed from all operations to sample of the operation. Signed-off-by: Amnon Heiman --- service/storage_proxy.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index c415fcf521..cdb8d9e3b3 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -2085,11 +2085,15 @@ storage_proxy::do_query(schema_ptr s, if (partition_ranges.empty()) { return make_empty(); } - + utils::latency_counter lc; + lc.start(); if (partition_ranges[0].is_singular() && partition_ranges[0].start()->value().has_key()) { // do not support mixed partitions (yet?) try { - return query_singular(cmd, std::move(partition_ranges), cl); + return query_singular(cmd, std::move(partition_ranges), cl).finally([lc, this] () mutable { + _stats.read.mark(lc.stop().latency_in_nano()); + }); } catch (const no_such_column_family&) { + _stats.read.mark(lc.stop().latency_in_nano()); return make_empty(); } } @@ -2097,9 +2101,12 @@ storage_proxy::do_query(schema_ptr s, if (partition_ranges.size() != 1) { // FIXME: implement throw std::runtime_error("more than one non singular range not supported yet"); + _stats.read.mark(lc.stop().latency_in_nano()); } - return query_partition_key_range(cmd, std::move(partition_ranges[0]), cl); + return query_partition_key_range(cmd, std::move(partition_ranges[0]), cl).finally([lc, this] () mutable { + _stats.read.mark(lc.stop().latency_in_nano()); + }); } #if 0