|
|
@ -90,9 +90,12 @@ grpc_json* add_num_str(grpc_json* parent, grpc_json* it, const char* name, |
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
Channel::Channel(grpc_channel* channel, size_t channel_tracer_max_nodes) |
|
|
|
Channel::Channel(grpc_channel* channel, size_t channel_tracer_max_nodes) |
|
|
|
: channel_(channel), target_(UniquePtr<char>(grpc_channel_get_target(channel_))), channel_uuid_(ChannelzRegistry::Register(this)) { |
|
|
|
: channel_(channel), |
|
|
|
|
|
|
|
target_(UniquePtr<char>(grpc_channel_get_target(channel_))), |
|
|
|
|
|
|
|
channel_uuid_(ChannelzRegistry::Register(this)) { |
|
|
|
trace_.Init(channel_tracer_max_nodes); |
|
|
|
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() { |
|
|
|
Channel::~Channel() { |
|
|
@ -102,7 +105,8 @@ Channel::~Channel() { |
|
|
|
|
|
|
|
|
|
|
|
void Channel::RecordCallStarted() { |
|
|
|
void Channel::RecordCallStarted() { |
|
|
|
gpr_atm_no_barrier_fetch_add(&calls_started_, (gpr_atm)1); |
|
|
|
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() { |
|
|
|
grpc_connectivity_state Channel::GetConnectivityState() { |
|
|
@ -142,8 +146,8 @@ char* Channel::RenderJSON() { |
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
// reset the parent to be the data object.
|
|
|
|
// reset the parent to be the data object.
|
|
|
|
json = data; |
|
|
|
json = data; |
|
|
|
json_iterator = grpc_json_create_child(json_iterator, json, "target", target_.get(), |
|
|
|
json_iterator = grpc_json_create_child( |
|
|
|
GRPC_JSON_STRING, false); |
|
|
|
json_iterator, json, "target", target_.get(), GRPC_JSON_STRING, false); |
|
|
|
// fill in the channel trace if applicable
|
|
|
|
// fill in the channel trace if applicable
|
|
|
|
grpc_json* trace = trace_->RenderJSON(); |
|
|
|
grpc_json* trace = trace_->RenderJSON(); |
|
|
|
if (trace != nullptr) { |
|
|
|
if (trace != nullptr) { |
|
|
@ -166,10 +170,11 @@ char* Channel::RenderJSON() { |
|
|
|
calls_succeeded_ ? calls_succeeded_ : -1); |
|
|
|
calls_succeeded_ ? calls_succeeded_ : -1); |
|
|
|
json_iterator = add_num_str(json, json_iterator, "callsFailed", |
|
|
|
json_iterator = add_num_str(json, json_iterator, "callsFailed", |
|
|
|
calls_failed_ ? calls_failed_ : -1); |
|
|
|
calls_failed_ ? calls_failed_ : -1); |
|
|
|
gpr_timespec ts = grpc_millis_to_timespec(last_call_started_millis_, GPR_CLOCK_REALTIME); |
|
|
|
gpr_timespec ts = |
|
|
|
json_iterator = grpc_json_create_child( |
|
|
|
grpc_millis_to_timespec(last_call_started_millis_, GPR_CLOCK_REALTIME); |
|
|
|
json_iterator, json, "lastCallStartedTimestamp", |
|
|
|
json_iterator = |
|
|
|
fmt_time(ts), GRPC_JSON_STRING, true); |
|
|
|
grpc_json_create_child(json_iterator, json, "lastCallStartedTimestamp", |
|
|
|
|
|
|
|
fmt_time(ts), GRPC_JSON_STRING, true); |
|
|
|
// render and return the over json object
|
|
|
|
// render and return the over json object
|
|
|
|
char* json_str = grpc_json_dump_to_string(top_level_json, 0); |
|
|
|
char* json_str = grpc_json_dump_to_string(top_level_json, 0); |
|
|
|
grpc_json_destroy(top_level_json); |
|
|
|
grpc_json_destroy(top_level_json); |
|
|
|