mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
per table metrics: change estimated_histogram to time_estimated_histogram
This patch changes the per table latencies histograms: read, write, cas_prepare, cas_accept, and cas_learn. Beside changing the definition type and the insertion method, the API was changed to support the new metrics. Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
@@ -256,4 +256,6 @@ public:
|
||||
operator T() const { return value; }
|
||||
};
|
||||
|
||||
utils_json::estimated_histogram time_to_json_histogram(const utils::time_estimated_histogram& val);
|
||||
|
||||
}
|
||||
|
||||
@@ -249,6 +249,12 @@ static future<json::json_return_type> sum_sstable(http_context& ctx, bool total)
|
||||
});
|
||||
}
|
||||
|
||||
future<json::json_return_type> map_reduce_cf_time_histogram(http_context& ctx, const sstring& name, std::function<utils::time_estimated_histogram(const column_family&)> f) {
|
||||
return map_reduce_cf_raw(ctx, name, utils::time_estimated_histogram(), f, utils::time_estimated_histogram_merge).then([](const utils::time_estimated_histogram& res) {
|
||||
return make_ready_future<json::json_return_type>(time_to_json_histogram(res));
|
||||
});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class sum_ratio {
|
||||
uint64_t _n = 0;
|
||||
@@ -796,24 +802,21 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_cas_prepare.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf_time_histogram(ctx, req->param["name"], [](const column_family& cf) {
|
||||
return cf.get_stats().estimated_cas_prepare;
|
||||
},
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
});
|
||||
|
||||
cf::get_cas_propose.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf_time_histogram(ctx, req->param["name"], [](const column_family& cf) {
|
||||
return cf.get_stats().estimated_cas_accept;
|
||||
},
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
});
|
||||
|
||||
cf::get_cas_commit.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf_time_histogram(ctx, req->param["name"], [](const column_family& cf) {
|
||||
return cf.get_stats().estimated_cas_learn;
|
||||
},
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
});
|
||||
|
||||
cf::get_sstables_per_read_histogram.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
@@ -909,17 +912,15 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_read_latency_estimated_histogram.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf_time_histogram(ctx, req->param["name"], [](const column_family& cf) {
|
||||
return cf.get_stats().estimated_read;
|
||||
},
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
});
|
||||
|
||||
cf::get_write_latency_estimated_histogram.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf_time_histogram(ctx, req->param["name"], [](const column_family& cf) {
|
||||
return cf.get_stats().estimated_write;
|
||||
},
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
});
|
||||
|
||||
cf::set_compaction_strategy_class.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
|
||||
@@ -68,6 +68,8 @@ future<json::json_return_type> map_reduce_cf(http_context& ctx, const sstring& n
|
||||
});
|
||||
}
|
||||
|
||||
future<json::json_return_type> map_reduce_cf_time_histogram(http_context& ctx, const sstring& name, std::function<utils::time_estimated_histogram(const column_family&)> f);
|
||||
|
||||
struct map_reduce_column_families_locally {
|
||||
std::any init;
|
||||
std::function<std::unique_ptr<std::any>(column_family&)> mapper;
|
||||
|
||||
10
database.hh
10
database.hh
@@ -352,11 +352,11 @@ struct table_stats {
|
||||
utils::timed_rate_moving_average_and_histogram cas_prepare{256};
|
||||
utils::timed_rate_moving_average_and_histogram cas_accept{256};
|
||||
utils::timed_rate_moving_average_and_histogram cas_learn{256};
|
||||
utils::estimated_histogram estimated_read;
|
||||
utils::estimated_histogram estimated_write;
|
||||
utils::estimated_histogram estimated_cas_prepare;
|
||||
utils::estimated_histogram estimated_cas_accept;
|
||||
utils::estimated_histogram estimated_cas_learn;
|
||||
utils::time_estimated_histogram estimated_read;
|
||||
utils::time_estimated_histogram estimated_write;
|
||||
utils::time_estimated_histogram estimated_cas_prepare;
|
||||
utils::time_estimated_histogram estimated_cas_accept;
|
||||
utils::time_estimated_histogram estimated_cas_learn;
|
||||
utils::estimated_histogram estimated_sstable_per_read{35};
|
||||
utils::timed_rate_moving_average_and_histogram tombstone_scanned;
|
||||
utils::timed_rate_moving_average_and_histogram live_scanned;
|
||||
|
||||
@@ -120,9 +120,7 @@ future<prepare_response> paxos_state::prepare(tracing::trace_state_ptr tr_state,
|
||||
}).finally([schema, lc] () mutable {
|
||||
auto& stats = get_local_storage_proxy().get_db().local().find_column_family(schema).get_stats();
|
||||
stats.cas_prepare.mark(lc.stop().latency());
|
||||
if (lc.is_start()) {
|
||||
stats.estimated_cas_prepare.add(lc.latency(), stats.cas_prepare.hist.count);
|
||||
}
|
||||
stats.estimated_cas_prepare.add(lc.latency());
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -162,9 +160,7 @@ future<bool> paxos_state::accept(tracing::trace_state_ptr tr_state, schema_ptr s
|
||||
}).finally([schema, lc] () mutable {
|
||||
auto& stats = get_local_storage_proxy().get_db().local().find_column_family(schema).get_stats();
|
||||
stats.cas_accept.mark(lc.stop().latency());
|
||||
if (lc.is_start()) {
|
||||
stats.estimated_cas_accept.add(lc.latency(), stats.cas_accept.hist.count);
|
||||
}
|
||||
stats.estimated_cas_accept.add(lc.latency());
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -214,9 +210,7 @@ future<> paxos_state::learn(schema_ptr schema, proposal decision, clock_type::ti
|
||||
}).finally([schema, lc] () mutable {
|
||||
auto& stats = get_local_storage_proxy().get_db().local().find_column_family(schema).get_stats();
|
||||
stats.cas_learn.mark(lc.stop().latency());
|
||||
if (lc.is_start()) {
|
||||
stats.estimated_cas_learn.add(lc.latency(), stats.cas_learn.hist.count);
|
||||
}
|
||||
stats.estimated_cas_learn.add(lc.latency());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
14
table.cc
14
table.cc
@@ -968,11 +968,11 @@ void table::set_metrics() {
|
||||
|
||||
if (_schema->ks_name() != db::system_keyspace::NAME && _schema->ks_name() != db::schema_tables::v3::NAME && _schema->ks_name() != "system_traces") {
|
||||
_metrics.add_group("column_family", {
|
||||
ms::make_histogram("read_latency", ms::description("Read latency histogram"), [this] {return _stats.estimated_read.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
|
||||
ms::make_histogram("write_latency", ms::description("Write latency histogram"), [this] {return _stats.estimated_write.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
|
||||
ms::make_histogram("cas_prepare_latency", ms::description("CAS prepare round latency histogram"), [this] {return _stats.estimated_cas_prepare.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
|
||||
ms::make_histogram("cas_propose_latency", ms::description("CAS accept round latency histogram"), [this] {return _stats.estimated_cas_accept.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
|
||||
ms::make_histogram("cas_commit_latency", ms::description("CAS learn round latency histogram"), [this] {return _stats.estimated_cas_learn.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
|
||||
ms::make_histogram("read_latency", ms::description("Read latency histogram"), [this] {return to_metrics_histogram(_stats.estimated_read);})(cf)(ks),
|
||||
ms::make_histogram("write_latency", ms::description("Write latency histogram"), [this] {return to_metrics_histogram(_stats.estimated_write);})(cf)(ks),
|
||||
ms::make_histogram("cas_prepare_latency", ms::description("CAS prepare round latency histogram"), [this] {return to_metrics_histogram(_stats.estimated_cas_prepare);})(cf)(ks),
|
||||
ms::make_histogram("cas_propose_latency", ms::description("CAS accept round latency histogram"), [this] {return to_metrics_histogram(_stats.estimated_cas_accept);})(cf)(ks),
|
||||
ms::make_histogram("cas_commit_latency", ms::description("CAS learn round latency histogram"), [this] {return to_metrics_histogram(_stats.estimated_cas_learn);})(cf)(ks),
|
||||
ms::make_gauge("cache_hit_rate", ms::description("Cache hit rate"), [this] {return float(_global_cache_hit_rate);})(cf)(ks)
|
||||
});
|
||||
}
|
||||
@@ -1938,7 +1938,7 @@ void table::do_apply(db::rp_handle&& h, Args&&... args) {
|
||||
}
|
||||
_stats.writes.mark(lc);
|
||||
if (lc.is_start()) {
|
||||
_stats.estimated_write.add(lc.latency(), _stats.writes.hist.count);
|
||||
_stats.estimated_write.add(lc.latency());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2033,7 +2033,7 @@ table::query(schema_ptr s,
|
||||
}).finally([lc, this]() mutable {
|
||||
_stats.reads.mark(lc);
|
||||
if (lc.is_start()) {
|
||||
_stats.estimated_read.add(lc.latency(), _stats.reads.hist.count);
|
||||
_stats.estimated_read.add(lc.latency());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user