19 #ifndef GRPC_CORE_LIB_CHANNEL_CHANNELZ_H
20 #define GRPC_CORE_LIB_CHANNEL_CHANNELZ_H
42 #define GRPC_ARG_CHANNELZ_CHANNEL_NODE "grpc.channelz_channel_node"
45 #define GRPC_ARG_CHANNELZ_PARENT_UUID "grpc.channelz_parent_uuid"
49 #define GRPC_ENABLE_CHANNELZ_DEFAULT true
55 #define GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT 1024 * 4
66 class ListenSocketNode;
69 class CallCountingHelperPeer;
70 class ChannelNodePeer;
101 intptr_t
uuid()
const {
return uuid_; }
102 const std::string&
name()
const {
return name_; }
150 sizeof(Atomic<gpr_cycle_counter>)];
161 void CollectData(CounterData* out);
164 InlinedVector<AtomicCounterData, 1> per_cpu_counter_data_storage_;
165 size_t num_cores_ = 0;
171 ChannelNode(std::string target,
size_t channel_tracer_max_nodes,
190 std::move(referenced_channel));
217 const intptr_t parent_uuid_;
227 std::map<intptr_t, bool> child_channels_;
228 std::map<intptr_t, bool> child_subchannels_;
258 std::move(referenced_channel));
268 std::map<intptr_t, RefCountedPtr<SocketNode>> child_sockets_;
269 std::map<intptr_t, RefCountedPtr<ListenSocketNode>> child_listen_sockets_;
294 const std::string&
remote() {
return remote_; }
299 Atomic<int64_t> streams_failed_{0};
300 Atomic<int64_t> messages_sent_{0};
301 Atomic<int64_t> messages_received_{0};
302 Atomic<int64_t> keepalives_sent_{0};
303 Atomic<gpr_cycle_counter> last_local_stream_created_cycle_{0};
304 Atomic<gpr_cycle_counter> last_remote_stream_created_cycle_{0};
305 Atomic<gpr_cycle_counter> last_message_sent_cycle_{0};
306 Atomic<gpr_cycle_counter> last_message_received_cycle_{0};
320 std::string local_addr_;
Atomic< int64_t > calls_failed
Definition: channelz.h:11
AtomicCounterData()=default
uint8_t padding[GPR_CACHELINE_SIZE - 3 *sizeof(Atomic< intptr_t >) - sizeof(Atomic< gpr_cycle_counter >)]
Definition: channelz.h:15
Atomic< gpr_cycle_counter > last_call_started_cycle
Definition: channelz.h:12
Atomic< int64_t > calls_started
Definition: channelz.h:9
Atomic< int64_t > calls_succeeded
Definition: channelz.h:10
T FetchAdd(Arg arg, MemoryOrder order=MemoryOrder::SEQ_CST)
Definition: atomic.h:71
Definition: ref_counted.h:248
Definition: ref_counted_ptr.h:35
Definition: channelz.h:74
virtual grpc_json * RenderJson()=0
char * RenderJsonString()
Definition: channelz.cc:97
intptr_t uuid() const
Definition: channelz.h:101
EntityType
Definition: channelz.h:79
virtual ~BaseNode()
Definition: channelz.cc:95
EntityType type() const
Definition: channelz.h:100
const std::string & name() const
Definition: channelz.h:102
BaseNode(EntityType type, std::string name)
Definition: channelz.cc:89
Definition: channelz.h:118
CallCountingHelper()
Definition: channelz.cc:109
friend class testing::CallCountingHelperPeer
Definition: channelz.h:131
void RecordCallSucceeded()
Definition: channelz.cc:130
void RecordCallFailed()
Definition: channelz.cc:125
void PopulateCallCounts(grpc_json *json)
Definition: channelz.cc:154
void RecordCallStarted()
Definition: channelz.cc:117
Definition: channelz.h:169
void RemoveChildChannel(intptr_t child_uuid)
Definition: channelz.cc:300
void RemoveChildSubchannel(intptr_t child_uuid)
Definition: channelz.cc:310
void AddChildSubchannel(intptr_t child_uuid)
Definition: channelz.cc:305
void RecordCallStarted()
Definition: channelz.h:192
void AddTraceEventWithReference(ChannelTrace::Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_channel)
Definition: channelz.h:186
friend class testing::ChannelNodePeer
Definition: channelz.h:212
intptr_t parent_uuid() const
Definition: channelz.h:178
static const char * GetChannelConnectivityStateChangeString(grpc_connectivity_state state)
Definition: channelz.cc:193
void RecordCallFailed()
Definition: channelz.h:193
void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice &data)
Definition: channelz.h:183
void RecordCallSucceeded()
Definition: channelz.h:194
void AddChildChannel(intptr_t child_uuid)
Definition: channelz.cc:295
ChannelNode(std::string target, size_t channel_tracer_max_nodes, intptr_t parent_uuid)
Definition: channelz.cc:184
grpc_json * RenderJson() override
Definition: channelz.cc:210
void SetConnectivityState(grpc_connectivity_state state)
Definition: channelz.cc:289
Definition: channel_trace.h:42
Severity
Definition: channel_trace.h:47
void AddTraceEventWithReference(Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_entity)
Definition: channel_trace.cc:118
void AddTraceEvent(Severity severity, const grpc_slice &data)
Definition: channel_trace.cc:110
Definition: channelz_registry.h:36
Definition: channelz.h:312
grpc_json * RenderJson() override
Definition: channelz.cc:613
~ListenSocketNode() override
Definition: channelz.h:315
ListenSocketNode(std::string local_addr, std::string name)
Definition: channelz.cc:609
Definition: channelz.h:232
char * RenderServerSockets(intptr_t start_socket_id, intptr_t max_results)
Definition: channelz.cc:344
ServerNode(grpc_server *server, size_t channel_tracer_max_nodes)
Definition: channelz.cc:319
void AddChildSocket(RefCountedPtr< SocketNode > node)
Definition: channelz.cc:324
void RemoveChildSocket(intptr_t child_uuid)
Definition: channelz.cc:329
void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice &data)
Definition: channelz.h:251
void RemoveChildListenSocket(intptr_t child_uuid)
Definition: channelz.cc:339
void RecordCallFailed()
Definition: channelz.h:261
void AddTraceEventWithReference(ChannelTrace::Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_channel)
Definition: channelz.h:254
void RecordCallSucceeded()
Definition: channelz.h:262
~ServerNode() override
Definition: channelz.cc:322
void RecordCallStarted()
Definition: channelz.h:260
grpc_json * RenderJson() override
Definition: channelz.cc:379
void AddChildListenSocket(RefCountedPtr< ListenSocketNode > node)
Definition: channelz.cc:334
Definition: channelz.h:273
void RecordMessageReceived()
Definition: channelz.cc:506
void RecordStreamSucceeded()
Definition: channelz.h:282
SocketNode(std::string local, std::string remote, std::string name)
Definition: channelz.cc:484
grpc_json * RenderJson() override
Definition: channelz.cc:512
void RecordStreamFailed()
Definition: channelz.h:285
void RecordStreamStartedFromRemote()
Definition: channelz.cc:495
void RecordStreamStartedFromLocal()
Definition: channelz.cc:489
const std::string & remote()
Definition: channelz.h:294
void RecordMessagesSent(uint32_t num_sent)
Definition: channelz.cc:501
void RecordKeepaliveSent()
Definition: channelz.h:290
~SocketNode() override
Definition: channelz.h:276
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
grpc_arg MakeParentUuidArg(intptr_t parent_uuid)
Definition: channelz.cc:65
intptr_t GetParentUuidFromArgs(const grpc_channel_args &args)
Definition: channelz.cc:78
Round Robin Policy.
Definition: backend_metric.cc:24
MemoryOrder
Definition: atomic.h:30
A single argument...
Definition: grpc_types.h:103
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: server.cc:222
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60