diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 499cebd721b..f6021c32243 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -27,7 +27,6 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" - namespace grpc_core { namespace channelz { diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 06e2c0e13c9..17c3fc35d99 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -90,9 +90,12 @@ grpc_json* add_num_str(grpc_json* parent, grpc_json* it, const char* name, } // namespace Channel::Channel(grpc_channel* channel, size_t channel_tracer_max_nodes) - : channel_(channel), target_(UniquePtr(grpc_channel_get_target(channel_))), channel_uuid_(ChannelzRegistry::Register(this)) { + : channel_(channel), + target_(UniquePtr(grpc_channel_get_target(channel_))), + channel_uuid_(ChannelzRegistry::Register(this)) { trace_.Init(channel_tracer_max_nodes); - gpr_atm_no_barrier_store(&last_call_started_millis_, (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_call_started_millis_, + (gpr_atm)ExecCtx::Get()->Now()); } Channel::~Channel() { @@ -102,7 +105,8 @@ Channel::~Channel() { void Channel::RecordCallStarted() { gpr_atm_no_barrier_fetch_add(&calls_started_, (gpr_atm)1); - gpr_atm_no_barrier_store(&last_call_started_millis_, (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_call_started_millis_, + (gpr_atm)ExecCtx::Get()->Now()); } grpc_connectivity_state Channel::GetConnectivityState() { @@ -142,8 +146,8 @@ char* Channel::RenderJSON() { GRPC_JSON_STRING, false); // reset the parent to be the data object. json = data; - json_iterator = grpc_json_create_child(json_iterator, json, "target", target_.get(), - GRPC_JSON_STRING, false); + json_iterator = grpc_json_create_child( + json_iterator, json, "target", target_.get(), GRPC_JSON_STRING, false); // fill in the channel trace if applicable grpc_json* trace = trace_->RenderJSON(); if (trace != nullptr) { @@ -166,10 +170,11 @@ char* Channel::RenderJSON() { calls_succeeded_ ? calls_succeeded_ : -1); json_iterator = add_num_str(json, json_iterator, "callsFailed", calls_failed_ ? calls_failed_ : -1); - gpr_timespec ts = grpc_millis_to_timespec(last_call_started_millis_, GPR_CLOCK_REALTIME); - json_iterator = grpc_json_create_child( - json_iterator, json, "lastCallStartedTimestamp", - fmt_time(ts), GRPC_JSON_STRING, true); + gpr_timespec ts = + grpc_millis_to_timespec(last_call_started_millis_, GPR_CLOCK_REALTIME); + json_iterator = + grpc_json_create_child(json_iterator, json, "lastCallStartedTimestamp", + fmt_time(ts), GRPC_JSON_STRING, true); // render and return the over json object char* json_str = grpc_json_dump_to_string(top_level_json, 0); grpc_json_destroy(top_level_json); diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 863447a5a46..68b7c8d26b9 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -35,7 +35,7 @@ namespace grpc_core { namespace channelz { namespace testing { - class ChannelPeer; +class ChannelPeer; } class Channel : public RefCounted { diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 2e7d9360a98..807ab7ae436 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1262,7 +1262,8 @@ static void post_batch_completion(batch_control* bctl) { } if (call->channel != nullptr) { - grpc_core::channelz::Channel* channelz_channel = grpc_channel_get_channelz_channel_node(call->channel); + grpc_core::channelz::Channel* channelz_channel = + grpc_channel_get_channelz_channel_node(call->channel); if (*call->final_op.client.status != GRPC_STATUS_OK) { channelz_channel->RecordCallFailed(); } else { @@ -1270,7 +1271,6 @@ static void post_batch_completion(batch_control* bctl) { } } - GRPC_ERROR_UNREF(error); error = GRPC_ERROR_NONE; } diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 537f1c5b189..95cf5f83ea3 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -46,8 +46,12 @@ namespace testing { // testing peer to access channel internals class ChannelPeer { public: - ChannelPeer (Channel* channel) : channel_(channel) {} - grpc_millis last_call_started_millis() { return (grpc_millis)gpr_atm_no_barrier_load(&channel_->last_call_started_millis_); } + ChannelPeer(Channel* channel) : channel_(channel) {} + grpc_millis last_call_started_millis() { + return (grpc_millis)gpr_atm_no_barrier_load( + &channel_->last_call_started_millis_); + } + private: Channel* channel_; }; diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 57c11616412..d24f7bc6206 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -258,7 +258,8 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { // The following is a quick sanity check on channelz functionality. It // ensures that core properly tracked the one call that occurred in this // simple end2end test. - grpc_core::channelz::Channel* channelz_channel = grpc_channel_get_channelz_channel_node(f.client); + grpc_core::channelz::Channel* channelz_channel = + grpc_channel_get_channelz_channel_node(f.client); char* json = channelz_channel->RenderJSON(); GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"1\"")); GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\"")); @@ -280,7 +281,8 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { // The following is a quick sanity check on channelz functionality. It // ensures that core properly tracked the ten calls that occurred. - grpc_core::channelz::Channel* channelz_channel = grpc_channel_get_channelz_channel_node(f.client); + grpc_core::channelz::Channel* channelz_channel = + grpc_channel_get_channelz_channel_node(f.client); char* json = channelz_channel->RenderJSON(); GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"10\"")); GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"10\""));