diff --git a/sstables/partition.cc b/sstables/partition.cc index aa31dcaa9e..188ebd1613 100644 --- a/sstables/partition.cc +++ b/sstables/partition.cc @@ -493,6 +493,7 @@ public: }; flat_mutation_reader sstable::read_rows_flat(schema_ptr schema, const io_priority_class& pc, streamed_mutation::forwarding fwd) { + get_stats().on_sstable_partition_read(); if (_version == version_types::mc) { return make_flat_mutation_reader>( shared_from_this(), std::move(schema), pc, no_resource_tracking(), fwd, default_read_monitor()); @@ -509,6 +510,7 @@ sstables::sstable::read_row_flat(schema_ptr schema, streamed_mutation::forwarding fwd, read_monitor& mon) { + get_stats().on_single_partition_read(); if (_version == version_types::mc) { return make_flat_mutation_reader>( shared_from_this(), std::move(schema), std::move(key), slice, pc, std::move(resource_tracker), fwd, mutation_reader::forwarding::no, mon); @@ -525,6 +527,7 @@ sstable::read_range_rows_flat(schema_ptr schema, streamed_mutation::forwarding fwd, mutation_reader::forwarding fwd_mr, read_monitor& mon) { + get_stats().on_range_partition_read(); if (_version == version_types::mc) { return make_flat_mutation_reader>( shared_from_this(), std::move(schema), range, slice, pc, std::move(resource_tracker), fwd, fwd_mr, mon); diff --git a/sstables/sstables.cc b/sstables/sstables.cc index f6d2953d15..98b3a77c90 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -4292,6 +4292,12 @@ future<> init_metrics() { sm::description("Number of range tombstones written")), sm::make_derive("cell_tombstone_writes", [] { return sstables_stats::get_shard_stats().cell_tombstone_writes; }, sm::description("Number of cell tombstones written")), + sm::make_derive("single_partition_reads", [] { return sstables_stats::get_shard_stats().single_partition_reads; }, + sm::description("Number of single partition flat mutation reads")), + sm::make_derive("range_partition_reads", [] { return sstables_stats::get_shard_stats().range_partition_reads; }, + sm::description("Number of partition range flat mutation reads")), + sm::make_derive("sstable_partition_reads", [] { return sstables_stats::get_shard_stats().sstable_partition_reads; }, + sm::description("Number of whole sstable flat mutation reads")), }); }); } diff --git a/sstables/stats.hh b/sstables/stats.hh index 1f84fa621c..ace8438e9a 100644 --- a/sstables/stats.hh +++ b/sstables/stats.hh @@ -32,6 +32,9 @@ class sstables_stats { uint64_t range_tombstone_writes = 0; uint64_t cell_writes = 0; uint64_t cell_tombstone_writes = 0; + uint64_t single_partition_reads = 0; + uint64_t range_partition_reads = 0; + uint64_t sstable_partition_reads = 0; } _shard_stats; stats& _stats = _shard_stats; @@ -68,6 +71,18 @@ public: inline void on_cell_tombstone_write() { ++_stats.cell_tombstone_writes; } + + inline void on_single_partition_read() { + ++_stats.single_partition_reads; + } + + inline void on_range_partition_read() { + ++_stats.range_partition_reads; + } + + inline void on_sstable_partition_read() { + ++_stats.sstable_partition_reads; + } }; }