|
|
|
@ -41,25 +41,14 @@ |
|
|
|
|
namespace grpc_core { |
|
|
|
|
namespace channelz { |
|
|
|
|
|
|
|
|
|
ChannelTrace::TraceEvent::TraceEvent( |
|
|
|
|
Severity severity, grpc_slice data, |
|
|
|
|
RefCountedPtr<ChannelNode> referenced_channel) |
|
|
|
|
ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data, |
|
|
|
|
RefCountedPtr<BaseNode> referenced_entity) |
|
|
|
|
: severity_(severity), |
|
|
|
|
data_(data), |
|
|
|
|
timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), |
|
|
|
|
GPR_CLOCK_REALTIME)), |
|
|
|
|
next_(nullptr), |
|
|
|
|
referenced_channel_(std::move(referenced_channel)) {} |
|
|
|
|
|
|
|
|
|
// ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data,
|
|
|
|
|
// RefCountedPtr<SubchannelNode>
|
|
|
|
|
// referenced_subchannel)
|
|
|
|
|
// : severity_(severity),
|
|
|
|
|
// data_(data),
|
|
|
|
|
// timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(),
|
|
|
|
|
// GPR_CLOCK_REALTIME)),
|
|
|
|
|
// next_(nullptr),
|
|
|
|
|
// referenced_subchannel_(std::move(referenced_subchannel)) {}
|
|
|
|
|
referenced_entity_(std::move(referenced_entity)) {} |
|
|
|
|
|
|
|
|
|
ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data) |
|
|
|
|
: severity_(severity), |
|
|
|
@ -119,24 +108,15 @@ void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) { |
|
|
|
|
AddTraceEventHelper(New<TraceEvent>(severity, data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ChannelTrace::AddTraceEventReferencingChannel( |
|
|
|
|
void ChannelTrace::AddTraceEventWithReference( |
|
|
|
|
Severity severity, grpc_slice data, |
|
|
|
|
RefCountedPtr<ChannelNode> referenced_channel) { |
|
|
|
|
RefCountedPtr<BaseNode> referenced_entity) { |
|
|
|
|
if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
|
|
|
|
|
// create and fill up the new event
|
|
|
|
|
AddTraceEventHelper( |
|
|
|
|
New<TraceEvent>(severity, data, std::move(referenced_channel))); |
|
|
|
|
New<TraceEvent>(severity, data, std::move(referenced_entity))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// void ChannelTrace::AddTraceEventReferencingSubchannel(
|
|
|
|
|
// Severity severity, grpc_slice data,
|
|
|
|
|
// RefCountedPtr<SubchannelNode> referenced_subchannel) {
|
|
|
|
|
// if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
|
|
|
|
|
// // create and fill up the new event
|
|
|
|
|
// AddTraceEventHelper(
|
|
|
|
|
// New<TraceEvent>(severity, data, std::move(referenced_subchannel)));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
const char* severity_string(ChannelTrace::Severity severity) { |
|
|
|
@ -165,26 +145,20 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { |
|
|
|
|
json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", |
|
|
|
|
gpr_format_timespec(timestamp_), |
|
|
|
|
GRPC_JSON_STRING, true); |
|
|
|
|
if (referenced_channel_ != nullptr) { |
|
|
|
|
if (referenced_entity_ != nullptr) { |
|
|
|
|
const bool is_channel = |
|
|
|
|
(referenced_entity_->type() == BaseNode::EntityType::kTopLevelChannel || |
|
|
|
|
referenced_entity_->type() == BaseNode::EntityType::kInternalChannel); |
|
|
|
|
char* uuid_str; |
|
|
|
|
gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_channel_->uuid()); |
|
|
|
|
gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_entity_->uuid()); |
|
|
|
|
grpc_json* child_ref = grpc_json_create_child( |
|
|
|
|
json_iterator, json, "channelRef", nullptr, GRPC_JSON_OBJECT, false); |
|
|
|
|
json_iterator = grpc_json_create_child(nullptr, child_ref, "channelId", |
|
|
|
|
uuid_str, GRPC_JSON_STRING, true); |
|
|
|
|
json_iterator, json, is_channel ? "channelRef" : "subchannelRef", |
|
|
|
|
nullptr, GRPC_JSON_OBJECT, false); |
|
|
|
|
json_iterator = grpc_json_create_child( |
|
|
|
|
nullptr, child_ref, is_channel ? "channelId" : "subchannelId", uuid_str, |
|
|
|
|
GRPC_JSON_STRING, true); |
|
|
|
|
json_iterator = child_ref; |
|
|
|
|
} |
|
|
|
|
// else {
|
|
|
|
|
// char* uuid_str;
|
|
|
|
|
// gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_subchannel_->uuid());
|
|
|
|
|
// grpc_json* child_ref = grpc_json_create_child(
|
|
|
|
|
// json_iterator, json, "subchannelRef",
|
|
|
|
|
// nullptr, GRPC_JSON_OBJECT, false);
|
|
|
|
|
// json_iterator = grpc_json_create_child(
|
|
|
|
|
// nullptr, child_ref, "subchannelId",
|
|
|
|
|
// uuid_str, GRPC_JSON_STRING, true);
|
|
|
|
|
// json_iterator = child_ref;
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
grpc_json* ChannelTrace::RenderJson() const { |
|
|
|
|