|
|
|
@ -85,7 +85,7 @@ intptr_t GetParentUuidFromArgs(const grpc_channel_args& args) { |
|
|
|
|
// BaseNode
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
BaseNode::BaseNode(EntityType type, UniquePtr<char> name) |
|
|
|
|
BaseNode::BaseNode(EntityType type, std::string name) |
|
|
|
|
: type_(type), uuid_(-1), name_(std::move(name)) { |
|
|
|
|
// The registry will set uuid_ under its lock.
|
|
|
|
|
ChannelzRegistry::Register(this); |
|
|
|
@ -180,11 +180,11 @@ void CallCountingHelper::PopulateCallCounts(grpc_json* json) { |
|
|
|
|
// ChannelNode
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
ChannelNode::ChannelNode(UniquePtr<char> target, |
|
|
|
|
size_t channel_tracer_max_nodes, intptr_t parent_uuid) |
|
|
|
|
ChannelNode::ChannelNode(std::string target, size_t channel_tracer_max_nodes, |
|
|
|
|
intptr_t parent_uuid) |
|
|
|
|
: BaseNode(parent_uuid == 0 ? EntityType::kTopLevelChannel |
|
|
|
|
: EntityType::kInternalChannel, |
|
|
|
|
UniquePtr<char>(gpr_strdup(target.get()))), |
|
|
|
|
target), |
|
|
|
|
target_(std::move(target)), |
|
|
|
|
trace_(channel_tracer_max_nodes), |
|
|
|
|
parent_uuid_(parent_uuid) {} |
|
|
|
@ -239,8 +239,8 @@ grpc_json* ChannelNode::RenderJson() { |
|
|
|
|
json = data; |
|
|
|
|
} |
|
|
|
|
// populate the target.
|
|
|
|
|
GPR_ASSERT(target_.get() != nullptr); |
|
|
|
|
grpc_json_create_child(nullptr, json, "target", target_.get(), |
|
|
|
|
GPR_ASSERT(!target_.empty()); |
|
|
|
|
grpc_json_create_child(nullptr, json, "target", target_.c_str(), |
|
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
|
// fill in the channel trace if applicable
|
|
|
|
|
grpc_json* trace_json = trace_.RenderJson(); |
|
|
|
@ -316,8 +316,7 @@ void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) { |
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
ServerNode::ServerNode(grpc_server* /*server*/, size_t channel_tracer_max_nodes) |
|
|
|
|
: BaseNode(EntityType::kServer, /* name */ nullptr), |
|
|
|
|
trace_(channel_tracer_max_nodes) {} |
|
|
|
|
: BaseNode(EntityType::kServer, ""), trace_(channel_tracer_max_nodes) {} |
|
|
|
|
|
|
|
|
|
ServerNode::~ServerNode() {} |
|
|
|
|
|
|
|
|
@ -363,7 +362,8 @@ char* ServerNode::RenderServerSockets(intptr_t start_socket_id, |
|
|
|
|
json_iterator = grpc_json_add_number_string_child( |
|
|
|
|
socket_ref_json, nullptr, "socketId", it->first); |
|
|
|
|
grpc_json_create_child(json_iterator, socket_ref_json, "name", |
|
|
|
|
it->second->name(), GRPC_JSON_STRING, false); |
|
|
|
|
it->second->name().c_str(), GRPC_JSON_STRING, |
|
|
|
|
false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (sockets_rendered == child_sockets_.size()) { |
|
|
|
@ -416,7 +416,8 @@ grpc_json* ServerNode::RenderJson() { |
|
|
|
|
grpc_json* sibling_iterator = grpc_json_add_number_string_child( |
|
|
|
|
json_iterator, nullptr, "socketId", it.first); |
|
|
|
|
grpc_json_create_child(sibling_iterator, json_iterator, "name", |
|
|
|
|
it.second->name(), GRPC_JSON_STRING, false); |
|
|
|
|
it.second->name().c_str(), GRPC_JSON_STRING, |
|
|
|
|
false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return top_level_json; |
|
|
|
@ -479,8 +480,7 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, |
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
SocketNode::SocketNode(UniquePtr<char> local, UniquePtr<char> remote, |
|
|
|
|
UniquePtr<char> name) |
|
|
|
|
SocketNode::SocketNode(std::string local, std::string remote, std::string name) |
|
|
|
|
: BaseNode(EntityType::kSocket, std::move(name)), |
|
|
|
|
local_(std::move(local)), |
|
|
|
|
remote_(std::move(remote)) {} |
|
|
|
@ -520,11 +520,11 @@ grpc_json* SocketNode::RenderJson() { |
|
|
|
|
json_iterator = nullptr; |
|
|
|
|
json_iterator = grpc_json_add_number_string_child(json, json_iterator, |
|
|
|
|
"socketId", uuid()); |
|
|
|
|
json_iterator = grpc_json_create_child(json_iterator, json, "name", name(), |
|
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
|
json_iterator = grpc_json_create_child( |
|
|
|
|
json_iterator, json, "name", name().c_str(), GRPC_JSON_STRING, false); |
|
|
|
|
json = top_level_json; |
|
|
|
|
PopulateSocketAddressJson(json, "remote", remote_.get()); |
|
|
|
|
PopulateSocketAddressJson(json, "local", local_.get()); |
|
|
|
|
PopulateSocketAddressJson(json, "remote", remote_.c_str()); |
|
|
|
|
PopulateSocketAddressJson(json, "local", local_.c_str()); |
|
|
|
|
// reset json iterators to top level object
|
|
|
|
|
json = top_level_json; |
|
|
|
|
json_iterator = nullptr; |
|
|
|
@ -605,8 +605,7 @@ grpc_json* SocketNode::RenderJson() { |
|
|
|
|
// ListenSocketNode
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
ListenSocketNode::ListenSocketNode(UniquePtr<char> local_addr, |
|
|
|
|
UniquePtr<char> name) |
|
|
|
|
ListenSocketNode::ListenSocketNode(std::string local_addr, std::string name) |
|
|
|
|
: BaseNode(EntityType::kSocket, std::move(name)), |
|
|
|
|
local_addr_(std::move(local_addr)) {} |
|
|
|
|
|
|
|
|
@ -622,10 +621,10 @@ grpc_json* ListenSocketNode::RenderJson() { |
|
|
|
|
json_iterator = nullptr; |
|
|
|
|
json_iterator = grpc_json_add_number_string_child(json, json_iterator, |
|
|
|
|
"socketId", uuid()); |
|
|
|
|
json_iterator = grpc_json_create_child(json_iterator, json, "name", name(), |
|
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
|
json_iterator = grpc_json_create_child( |
|
|
|
|
json_iterator, json, "name", name().c_str(), GRPC_JSON_STRING, false); |
|
|
|
|
json = top_level_json; |
|
|
|
|
PopulateSocketAddressJson(json, "local", local_addr_.get()); |
|
|
|
|
PopulateSocketAddressJson(json, "local", local_addr_.c_str()); |
|
|
|
|
|
|
|
|
|
return top_level_json; |
|
|
|
|
} |
|
|
|
|