From 5f43fc91e7f064ee79b06ebcc6955c54b19dd902 Mon Sep 17 00:00:00 2001 From: Zhe Wang Date: Tue, 17 Oct 2023 11:19:25 -0700 Subject: [PATCH] pr-10985 --- fdbclient/SpecialKeySpace.actor.cpp | 1 + fdbclient/include/fdbclient/FDBTypes.h | 11 +++++++---- fdbserver/DDShardTracker.actor.cpp | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fdbclient/SpecialKeySpace.actor.cpp b/fdbclient/SpecialKeySpace.actor.cpp index 4f444dccd3..8bfd32ffc0 100644 --- a/fdbclient/SpecialKeySpace.actor.cpp +++ b/fdbclient/SpecialKeySpace.actor.cpp @@ -747,6 +747,7 @@ ACTOR Future ddMetricsGetRangeActor(ReadYourWritesTransaction* ryw, // Use json string encoded in utf-8 to encode the values, easy for adding more fields in the future json_spirit::mObject statsObj; statsObj["shard_bytes"] = ddMetricsRef.shardBytes; + statsObj["shard_bytes_per_ksecond"] = ddMetricsRef.shardBytesPerKSecond; std::string statsString = json_spirit::write_string(json_spirit::mValue(statsObj), json_spirit::Output_options::raw_utf8); ValueRef bytes(result.arena(), statsString); diff --git a/fdbclient/include/fdbclient/FDBTypes.h b/fdbclient/include/fdbclient/FDBTypes.h index 9184db3954..54a9918424 100644 --- a/fdbclient/include/fdbclient/FDBTypes.h +++ b/fdbclient/include/fdbclient/FDBTypes.h @@ -1333,16 +1333,19 @@ struct HealthMetrics { struct DDMetricsRef { int64_t shardBytes; + int64_t shardBytesPerKSecond; KeyRef beginKey; - DDMetricsRef() : shardBytes(0) {} - DDMetricsRef(int64_t bytes, KeyRef begin) : shardBytes(bytes), beginKey(begin) {} + DDMetricsRef() : shardBytes(0), shardBytesPerKSecond(0) {} + DDMetricsRef(int64_t bytes, int64_t bytesPerKSecond, KeyRef begin) + : shardBytes(bytes), shardBytesPerKSecond(bytesPerKSecond), beginKey(begin) {} DDMetricsRef(Arena& a, const DDMetricsRef& copyFrom) - : shardBytes(copyFrom.shardBytes), beginKey(a, copyFrom.beginKey) {} + : shardBytes(copyFrom.shardBytes), shardBytesPerKSecond(copyFrom.shardBytesPerKSecond), + beginKey(a, copyFrom.beginKey) {} template void serialize(Ar& ar) { - serializer(ar, shardBytes, beginKey); + serializer(ar, shardBytes, beginKey, shardBytesPerKSecond); } }; diff --git a/fdbserver/DDShardTracker.actor.cpp b/fdbserver/DDShardTracker.actor.cpp index 51f2de9481..600bfa75b2 100644 --- a/fdbserver/DDShardTracker.actor.cpp +++ b/fdbserver/DDShardTracker.actor.cpp @@ -1437,7 +1437,9 @@ ACTOR Future fetchShardMetricsList_impl(DataDistributionTracker* self, Get break; } result.push_back_deep(result.arena(), - DDMetricsRef(stats->get().get().metrics.bytes, KeyRef(t.begin().toString()))); + DDMetricsRef(stats->get().get().metrics.bytes, + stats->get().get().metrics.bytesWrittenPerKSecond, + KeyRef(t.begin().toString()))); ++shardNum; if (shardNum >= req.shardLimit) { break;