From 885c33da8bb363014e4231f8b5f3da024923f287 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 30 Jul 2018 22:36:25 -0700 Subject: [PATCH] reviewer feedback --- .../filters/client_channel/client_channel_channelz.cc | 11 +++++------ .../filters/client_channel/client_channel_channelz.h | 7 ++++--- src/core/lib/channel/channelz.cc | 9 ++++----- src/core/lib/channel/channelz.h | 8 ++++---- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index 7120ec57f1a..d904fc28b2a 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -155,12 +155,11 @@ SubchannelNode::SubchannelNode(grpc_subchannel* subchannel, size_t channel_tracer_max_nodes) : BaseNode(EntityType::kSubchannel), subchannel_(subchannel), - target_(UniquePtr( - gpr_strdup(grpc_subchannel_get_target(subchannel_)))) { - trace_.Init(channel_tracer_max_nodes); -} + target_( + UniquePtr(gpr_strdup(grpc_subchannel_get_target(subchannel_)))), + trace_(channel_tracer_max_nodes) {} -SubchannelNode::~SubchannelNode() { trace_.Destroy(); } +SubchannelNode::~SubchannelNode() {} void SubchannelNode::PopulateConnectivityState(grpc_json* json) { grpc_connectivity_state state; @@ -199,7 +198,7 @@ grpc_json* SubchannelNode::RenderJson() { grpc_json_create_child(nullptr, json, "target", target_.get(), GRPC_JSON_STRING, false); // fill in the channel trace if applicable - grpc_json* trace_json = trace_->RenderJson(); + grpc_json* trace_json = trace_.RenderJson(); if (trace_json != nullptr) { trace_json->key = "trace"; // this object is named trace in channelz.proto grpc_json_link_child(json, trace_json, nullptr); diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index 5e01fdf2a38..9a3fc1d6f1a 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -23,6 +23,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/inlined_vector.h" @@ -78,12 +79,12 @@ class SubchannelNode : public BaseNode { // proxy methods to composed classes. void AddTraceEvent(ChannelTrace::Severity severity, grpc_slice data) { - trace_->AddTraceEvent(severity, data); + trace_.AddTraceEvent(severity, data); } void AddTraceEventWithReference(ChannelTrace::Severity severity, grpc_slice data, RefCountedPtr referenced_channel) { - trace_->AddTraceEventWithReference(severity, data, referenced_channel); + trace_.AddTraceEventWithReference(severity, data, referenced_channel); } void RecordCallStarted() { call_counter_.RecordCallStarted(); } void RecordCallFailed() { call_counter_.RecordCallFailed(); } @@ -93,7 +94,7 @@ class SubchannelNode : public BaseNode { grpc_subchannel* subchannel_; UniquePtr target_; CallCountingHelper call_counter_; - ManualConstructor trace_; + ChannelTrace trace_; void PopulateConnectivityState(grpc_json* json); }; diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index a75a05023af..b908363b1b7 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -92,11 +92,10 @@ ChannelNode::ChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes, : BaseNode(is_top_level_channel ? EntityType::kTopLevelChannel : EntityType::kInternalChannel), channel_(channel), - target_(UniquePtr(grpc_channel_get_target(channel_))) { - trace_.Init(channel_tracer_max_nodes); -} + target_(UniquePtr(grpc_channel_get_target(channel_))), + trace_(channel_tracer_max_nodes) {} -ChannelNode::~ChannelNode() { trace_.Destroy(); } +ChannelNode::~ChannelNode() {} grpc_json* ChannelNode::RenderJson() { // We need to track these three json objects to build our object @@ -123,7 +122,7 @@ grpc_json* ChannelNode::RenderJson() { grpc_json_create_child(nullptr, json, "target", target_.get(), GRPC_JSON_STRING, false); // fill in the channel trace if applicable - grpc_json* trace_json = trace_->RenderJson(); + grpc_json* trace_json = trace_.RenderJson(); if (trace_json != nullptr) { trace_json->key = "trace"; // this object is named trace in channelz.proto grpc_json_link_child(json, trace_json, nullptr); diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 74b203af443..66753c96eec 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -133,12 +133,12 @@ class ChannelNode : public BaseNode { // proxy methods to composed classes. void AddTraceEvent(ChannelTrace::Severity severity, grpc_slice data) { - trace_->AddTraceEvent(severity, data); + trace_.AddTraceEvent(severity, data); } void AddTraceEventWithReference(ChannelTrace::Severity severity, grpc_slice data, RefCountedPtr referenced_channel) { - trace_->AddTraceEventWithReference(severity, data, referenced_channel); + trace_.AddTraceEventWithReference(severity, data, referenced_channel); } void RecordCallStarted() { call_counter_.RecordCallStarted(); } void RecordCallFailed() { call_counter_.RecordCallFailed(); } @@ -150,7 +150,7 @@ class ChannelNode : public BaseNode { // provides access to call_counter_ for child. CallCountingHelper* call_counter() { return &call_counter_; } // provides access to channel trace for child. - ChannelTrace* trace() { return trace_.get(); } + ChannelTrace* trace() { return &trace_; } private: // to allow the channel trace test to access trace(); @@ -158,7 +158,7 @@ class ChannelNode : public BaseNode { grpc_channel* channel_ = nullptr; UniquePtr target_; CallCountingHelper call_counter_; - ManualConstructor trace_; + ChannelTrace trace_; }; // Handles channelz bookkeeping for servers