Skip to content

Commit 6118211

Browse files
committed
Update core stat descriptions
Update stat descriptions and add verification code in the stats test that all reported stats from the core contains a description. Change-Id: I2fe8f17af0b59ca42de5d5a6a599593cef56f461 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/196746 Tested-by: Build Bot <[email protected]> Reviewed-by: Jim Walker <[email protected]>
1 parent 1157de0 commit 6118211

File tree

6 files changed

+451
-10
lines changed

6 files changed

+451
-10
lines changed

daemon/protocol/mcbp/stats_context.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static cb::engine_errc stat_sched_executor(const std::string& arg,
176176
}
177177

178178
if (arg == "aggregate") {
179-
static const std::string key = {"aggregate"};
179+
static const std::string key = {"Thread-aggregate"};
180180
Hdr1sfMicroSecHistogram histogram{};
181181
for (const auto& h : scheduler_info) {
182182
histogram += h;
@@ -246,7 +246,8 @@ static cb::engine_errc stat_bucket_details_executor(const std::string& arg,
246246
auto json = bucket.to_json();
247247
if (!json.empty() && json["name"] == arg) {
248248
const auto stats_str = json.dump();
249-
append_stats(arg, stats_str, cookie);
249+
append_stats(
250+
fmt::format("bucket details:{}", arg), stats_str, cookie);
250251
return cb::engine_errc::success;
251252
}
252253
}
@@ -618,7 +619,7 @@ static cb::engine_errc stat_threads_executor(const std::string& arg,
618619
e.what());
619620
}
620621

621-
append_stats("details", json.dump(), cookie);
622+
append_stats("threads:details", json.dump(), cookie);
622623
return cb::engine_errc::success;
623624
}
624625

include/mcbp/protocol/response.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ class Response {
183183
cb::byte_buffer getKey() {
184184
return reinterpret_cast<Header*>(this)->getKey();
185185
}
186+
std::string_view getKeyString() const {
187+
auto ret = getKey();
188+
return {reinterpret_cast<const char*>(ret.data()), ret.size()};
189+
}
186190

187191
cb::const_byte_buffer getValue() const {
188192
return reinterpret_cast<const Header*>(this)->getValue();

protocol/connection/client_connection.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ std::unique_ptr<MemcachedConnection> MemcachedConnection::clone(
914914
ret->tls12_ciphers = tls12_ciphers;
915915
ret->tls13_ciphers = tls13_ciphers;
916916
ret->packet_dump_callback = packet_dump_callback;
917+
ret->userValidateReceivedFrameCallback = userValidateReceivedFrameCallback;
917918
if (connect) {
918919
ret->connect();
919920
ret->applyFeatures(effective_features);
@@ -936,6 +937,10 @@ void MemcachedConnection::doValidateReceivedFrame(
936937
sizeof(packet)})));
937938
}
938939

940+
if (userValidateReceivedFrameCallback) {
941+
userValidateReceivedFrameCallback(packet);
942+
}
943+
939944
const auto magic = Magic(packet.getMagic());
940945
if (is_server_magic(magic) || is_request(magic)) {
941946
return;

protocol/connection/client_connection.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,14 +1035,25 @@ class MemcachedConnection {
10351035
packet_dump_callback = std::move(callback);
10361036
}
10371037

1038-
/// Enable / disable validation of the received frame. Validation include
1039-
/// a) The frame header is valid
1040-
/// b) The datatype received is one of the ones we've enabled support for
1041-
/// c) The value is what the datatype say it is
1038+
/**
1039+
* Enable / disable validation of the received frame. Validation include
1040+
* a) The frame header is valid
1041+
* b) The optional user-provided validate callback completes
1042+
* c) The datatype received is one of the ones we've enabled support for
1043+
* d) The value is what the datatype say it is
1044+
*
1045+
* If validation fails it'll throw an exception
1046+
*/
10421047
void setValidateReceivedFrame(bool value) {
10431048
validateReceivedFrame = value;
10441049
}
10451050

1051+
/// Add an extra validate callback for received frames
1052+
void setUserValidateReceivedFrameCallback(
1053+
std::function<void(const cb::mcbp::Header&)> callback) {
1054+
userValidateReceivedFrameCallback = std::move(callback);
1055+
}
1056+
10461057
protected:
10471058
void sendBuffer(const std::vector<iovec>& buf);
10481059
void sendBuffer(cb::const_byte_buffer buf);
@@ -1117,5 +1128,7 @@ class MemcachedConnection {
11171128

11181129
bool validateReceivedFrame;
11191130
void doValidateReceivedFrame(const cb::mcbp::Header& packet);
1131+
std::function<void(const cb::mcbp::Header&)>
1132+
userValidateReceivedFrameCallback;
11201133
std::unique_ptr<cb::json::SyntaxValidator> jsonValidator;
11211134
};

0 commit comments

Comments
 (0)