Skip to content

Commit

Permalink
[#21859] ASH: Make ASH uuid data human readable when viewed through /…
Browse files Browse the repository at this point in the history
…rpcz

Summary:
ASH uuid data should be human readable when viewed through /rpcz
Jira: DB-10757

Test Plan: view 127.0.0.1:9000/rpcz after change to confirm that the fields are human-readable

Reviewers: asaha

Reviewed By: asaha

Subscribers: ybase, esheng

Differential Revision: https://phorge.dev.yugabyte.com/D35884
  • Loading branch information
amitanandaiyer committed Jul 1, 2024
1 parent e77b95b commit 7e289b5
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/yb/server/rpcz-path-handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,63 @@ bool GetBool(const Map& map, const typename Map::key_type& key, bool default_val
return ParseLeadingBoolValue(it->second, default_value);
}

void MakeAshUuidsHumanReadable(rpc::RpcCallInProgressPB* pb) {
if (!pb->has_wait_state() || !pb->wait_state().has_metadata()) {
return;
}
AshMetadataPB* metadata_pb = pb->mutable_wait_state()->mutable_metadata();
// Convert root_request_id and yql_endpoint_tserver_uuid from binary to
// human-readable formats
if (metadata_pb->has_root_request_id()) {
Result<Uuid> result = Uuid::FromSlice(metadata_pb->root_request_id());
if (result.ok()) {
metadata_pb->set_root_request_id(result.ToString());
}
}
if (metadata_pb->has_yql_endpoint_tserver_uuid()) {
Result<Uuid> result = Uuid::FromSlice(metadata_pb->yql_endpoint_tserver_uuid());
if (result.ok()) {
metadata_pb->set_yql_endpoint_tserver_uuid(result.ToString());
}
}
}

void MakeAshUuidsHumanReadable(rpc::RpcConnectionPB* pb) {
for (int i = 0; i < pb->calls_in_flight_size(); i++) {
MakeAshUuidsHumanReadable(pb->mutable_calls_in_flight(i));
}
}

void MakeAshUuidsHumanReadable(DumpRunningRpcsResponsePB* dump_resp) {
for (int i = 0; i < dump_resp->inbound_connections_size(); i++) {
MakeAshUuidsHumanReadable(dump_resp->mutable_inbound_connections(i));
}
for (int i = 0; i < dump_resp->outbound_connections_size(); i++) {
MakeAshUuidsHumanReadable(dump_resp->mutable_outbound_connections(i));
}
if (dump_resp->has_local_calls()) {
MakeAshUuidsHumanReadable(dump_resp->mutable_local_calls());
}
}

void RpczPathHandler(
Messenger* messenger, bool show_local_calls, const Webserver::WebRequest& req,
Webserver::WebResponse* resp) {
std::stringstream *output = &resp->output;
DumpRunningRpcsRequestPB dump_req;
DumpRunningRpcsResponsePB dump_resp;

dump_req.set_get_wait_state(GetBool(req.parsed_args, "get_wait_state", false));
const bool get_wait_state = GetBool(req.parsed_args, "get_wait_state", false);
dump_req.set_get_wait_state(get_wait_state);
dump_req.set_export_wait_state_code_as_string(true);
dump_req.set_include_traces(GetBool(req.parsed_args, "include_traces", false));
dump_req.set_dump_timed_out(GetBool(req.parsed_args, "timed_out", false));
dump_req.set_get_local_calls(show_local_calls);

WARN_NOT_OK(messenger->DumpRunningRpcs(dump_req, &dump_resp), "DumpRunningRpcs failed");
if (get_wait_state) {
MakeAshUuidsHumanReadable(&dump_resp);
}

JsonWriter writer(output, JsonWriter::PRETTY);
writer.Protobuf(dump_resp);
Expand Down

0 comments on commit 7e289b5

Please sign in to comment.