channelz_sampler.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
19 
20 #include <unistd.h>
21 
22 #include <cstdlib>
23 #include <fstream>
24 #include <iostream>
25 #include <memory>
26 #include <ostream>
27 #include <queue>
28 #include <string>
29 
30 #include "absl/flags/flag.h"
31 #include "absl/strings/str_format.h"
32 #include "absl/strings/str_join.h"
33 #include "google/protobuf/text_format.h"
34 
35 #include <grpc/grpc.h>
36 #include <grpcpp/channel.h>
37 #include <grpcpp/client_context.h>
38 #include <grpcpp/create_channel.h>
40 #include <grpcpp/grpcpp.h>
43 #include <grpcpp/server.h>
44 #include <grpcpp/server_builder.h>
45 #include <grpcpp/server_context.h>
46 
47 #include "src/core/lib/json/json.h"
49 #include "src/proto/grpc/channelz/channelz.pb.h"
53 
54 ABSL_FLAG(std::string, server_address, "", "channelz server address");
55 ABSL_FLAG(std::string, custom_credentials_type, "", "custom credentials type");
56 ABSL_FLAG(int64_t, sampling_times, 1, "number of sampling");
57 // TODO(Capstan): Consider using absl::Duration
59  "sampling interval in seconds");
60 ABSL_FLAG(std::string, output_json, "", "output filename in json format");
61 
62 namespace {
64 using grpc::Status;
65 using grpc::StatusCode;
66 using grpc::channelz::v1::GetChannelRequest;
67 using grpc::channelz::v1::GetChannelResponse;
68 using grpc::channelz::v1::GetServersRequest;
69 using grpc::channelz::v1::GetServersResponse;
70 using grpc::channelz::v1::GetSocketRequest;
71 using grpc::channelz::v1::GetSocketResponse;
72 using grpc::channelz::v1::GetSubchannelRequest;
73 using grpc::channelz::v1::GetSubchannelResponse;
74 using grpc::channelz::v1::GetTopChannelsRequest;
75 using grpc::channelz::v1::GetTopChannelsResponse;
76 } // namespace
77 
78 class ChannelzSampler final {
79  public:
80  // Get server_id of a server
82  return server.ref().server_id();
83  }
84 
85  // Get channel_id of a channel
87  return channel.ref().channel_id();
88  }
89 
90  // Get subchannel_id of a subchannel
93  return subchannel.ref().subchannel_id();
94  }
95 
96  // Get socket_id of a socket
98  return socket.ref().socket_id();
99  }
100 
101  // Get name of a server
103  return server.ref().name();
104  }
105 
106  // Get name of a channel
109  return channel.ref().name();
110  }
111 
112  // Get name of a subchannel
115  return subchannel.ref().name();
116  }
117 
118  // Get name of a socket
120  return socket.ref().name();
121  }
122 
123  // Get a channel based on channel_id
125  GetChannelRequest get_channel_request;
126  get_channel_request.set_channel_id(channel_id);
127  GetChannelResponse get_channel_response;
128  ClientContext get_channel_context;
129  get_channel_context.set_deadline(
131  Status status = channelz_stub_->GetChannel(
132  &get_channel_context, get_channel_request, &get_channel_response);
133  if (!status.ok()) {
134  gpr_log(GPR_ERROR, "GetChannelRPC failed: %s",
135  get_channel_context.debug_error_string().c_str());
136  GPR_ASSERT(0);
137  }
138  return get_channel_response.channel();
139  }
140 
141  // Get a subchannel based on subchannel_id
143  GetSubchannelRequest get_subchannel_request;
144  get_subchannel_request.set_subchannel_id(subchannel_id);
145  GetSubchannelResponse get_subchannel_response;
146  ClientContext get_subchannel_context;
147  get_subchannel_context.set_deadline(
149  Status status = channelz_stub_->GetSubchannel(&get_subchannel_context,
150  get_subchannel_request,
151  &get_subchannel_response);
152  if (!status.ok()) {
153  gpr_log(GPR_ERROR, "GetSubchannelRPC failed: %s",
154  get_subchannel_context.debug_error_string().c_str());
155  GPR_ASSERT(0);
156  }
157  return get_subchannel_response.subchannel();
158  }
159 
160  // get a socket based on socket_id
162  GetSocketRequest get_socket_request;
163  get_socket_request.set_socket_id(socket_id);
164  GetSocketResponse get_socket_response;
165  ClientContext get_socket_context;
166  get_socket_context.set_deadline(
168  Status status = channelz_stub_->GetSocket(
169  &get_socket_context, get_socket_request, &get_socket_response);
170  if (!status.ok()) {
171  gpr_log(GPR_ERROR, "GetSocketRPC failed: %s",
172  get_socket_context.debug_error_string().c_str());
173  GPR_ASSERT(0);
174  }
175  return get_socket_response.socket();
176  }
177 
178  // get the descedent channels/subchannels/sockets of a channel
179  // push descedent channels/subchannels to queue for layer traverse
180  // store descedent channels/subchannels/sockets for dumping data
183  std::queue<grpc::channelz::v1::Channel>& channel_queue,
184  std::queue<grpc::channelz::v1::Subchannel>& subchannel_queue) {
185  std::cout << " Channel ID" << GetChannelID(channel) << "_"
186  << GetChannelName(channel) << " descendence - ";
187  if (channel.channel_ref_size() > 0 || channel.subchannel_ref_size() > 0) {
188  if (channel.channel_ref_size() > 0) {
189  std::cout << "channel: ";
190  for (const auto& _channelref : channel.channel_ref()) {
191  int64_t ch_id = _channelref.channel_id();
192  std::cout << "ID" << ch_id << "_" << _channelref.name() << " ";
194  channel_queue.push(ch);
195  if (CheckID(ch_id)) {
196  all_channels_.push_back(ch);
198  }
199  }
200  if (channel.subchannel_ref_size() > 0) {
201  std::cout << ", ";
202  }
203  }
204  if (channel.subchannel_ref_size() > 0) {
205  std::cout << "subchannel: ";
206  for (const auto& _subchannelref : channel.subchannel_ref()) {
207  int64_t subch_id = _subchannelref.subchannel_id();
208  std::cout << "ID" << subch_id << "_" << _subchannelref.name() << " ";
210  subchannel_queue.push(subch);
211  if (CheckID(subch_id)) {
212  all_subchannels_.push_back(subch);
213  StoreSubchannelInJson(subch);
214  }
215  }
216  }
217  } else if (channel.socket_ref_size() > 0) {
218  std::cout << "socket: ";
219  for (const auto& _socketref : channel.socket_ref()) {
220  int64_t so_id = _socketref.socket_id();
221  std::cout << "ID" << so_id << "_" << _socketref.name() << " ";
223  if (CheckID(so_id)) {
224  all_sockets_.push_back(so);
225  StoreSocketInJson(so);
226  }
227  }
228  }
229  std::cout << std::endl;
230  }
231 
232  // get the descedent channels/subchannels/sockets of a subchannel
233  // push descedent channels/subchannels to queue for layer traverse
234  // store descedent channels/subchannels/sockets for dumping data
237  std::queue<grpc::channelz::v1::Channel>& channel_queue,
238  std::queue<grpc::channelz::v1::Subchannel>& subchannel_queue) {
239  std::cout << " Subchannel ID" << GetSubchannelID(subchannel) << "_"
240  << GetSubchannelName(subchannel) << " descendence - ";
241  if (subchannel.channel_ref_size() > 0 ||
242  subchannel.subchannel_ref_size() > 0) {
243  if (subchannel.channel_ref_size() > 0) {
244  std::cout << "channel: ";
245  for (const auto& _channelref : subchannel.channel_ref()) {
246  int64_t ch_id = _channelref.channel_id();
247  std::cout << "ID" << ch_id << "_" << _channelref.name() << " ";
249  channel_queue.push(ch);
250  if (CheckID(ch_id)) {
251  all_channels_.push_back(ch);
253  }
254  }
255  if (subchannel.subchannel_ref_size() > 0) {
256  std::cout << ", ";
257  }
258  }
259  if (subchannel.subchannel_ref_size() > 0) {
260  std::cout << "subchannel: ";
261  for (const auto& _subchannelref : subchannel.subchannel_ref()) {
262  int64_t subch_id = _subchannelref.subchannel_id();
263  std::cout << "ID" << subch_id << "_" << _subchannelref.name() << " ";
265  subchannel_queue.push(subch);
266  if (CheckID(subch_id)) {
267  all_subchannels_.push_back(subch);
268  StoreSubchannelInJson(subch);
269  }
270  }
271  }
272  } else if (subchannel.socket_ref_size() > 0) {
273  std::cout << "socket: ";
274  for (const auto& _socketref : subchannel.socket_ref()) {
275  int64_t so_id = _socketref.socket_id();
276  std::cout << "ID" << so_id << "_" << _socketref.name() << " ";
278  if (CheckID(so_id)) {
279  all_sockets_.push_back(so);
280  StoreSocketInJson(so);
281  }
282  }
283  }
284  std::cout << std::endl;
285  }
286 
287  // Set up the channelz sampler client
288  // Initialize json as an array
290  const std::string& server_address) {
293  grpc::ChannelArguments channel_args;
294  std::shared_ptr<grpc::ChannelCredentials> channel_creds =
296  custom_credentials_type, &channel_args);
297  if (!channel_creds) {
299  "Wrong user credential type: %s. Allowed credential types: "
300  "INSECURE_CREDENTIALS, ssl, alts, google_default_credentials.",
301  custom_credentials_type.c_str());
302  GPR_ASSERT(0);
303  }
304  std::shared_ptr<grpc::Channel> channel =
305  CreateChannel(server_address, channel_creds);
306  channelz_stub_ = grpc::channelz::v1::Channelz::NewStub(channel);
307  }
308 
309  // Get all servers, keep querying until getting all
310  // Store servers for dumping data
311  // Need to check id repeating for servers
312  void GetServersRPC() {
313  int64_t server_start_id = 0;
314  while (true) {
315  GetServersRequest get_servers_request;
316  GetServersResponse get_servers_response;
317  ClientContext get_servers_context;
318  get_servers_context.set_deadline(
320  get_servers_request.set_start_server_id(server_start_id);
321  Status status = channelz_stub_->GetServers(
322  &get_servers_context, get_servers_request, &get_servers_response);
323  if (!status.ok()) {
324  if (status.error_code() == StatusCode::UNIMPLEMENTED) {
326  "Error status UNIMPLEMENTED. Please check and make sure "
327  "channelz has been registered on the server being queried.");
328  } else {
330  "GetServers RPC with GetServersRequest.server_start_id=%d, "
331  "failed: %s",
332  int(server_start_id),
333  get_servers_context.debug_error_string().c_str());
334  }
335  GPR_ASSERT(0);
336  }
337  for (const auto& _server : get_servers_response.server()) {
338  all_servers_.push_back(_server);
340  }
341  if (!get_servers_response.end()) {
342  server_start_id = GetServerID(all_servers_.back()) + 1;
343  } else {
344  break;
345  }
346  }
347  std::cout << "Number of servers = " << all_servers_.size() << std::endl;
348  }
349 
350  // Get sockets that belongs to servers
351  // Store sockets for dumping data
353  for (const auto& _server : all_servers_) {
354  std::cout << "Server ID" << GetServerID(_server) << "_"
355  << GetServerName(_server) << " listen_socket - ";
356  for (const auto& _socket : _server.listen_socket()) {
357  int64_t so_id = _socket.socket_id();
358  std::cout << "ID" << so_id << "_" << _socket.name() << " ";
359  if (CheckID(so_id)) {
361  all_sockets_.push_back(so);
362  StoreSocketInJson(so);
363  }
364  }
365  std::cout << std::endl;
366  }
367  }
368 
369  // Get all top channels, keep querying until getting all
370  // Store channels for dumping data
371  // No need to check id repeating for top channels
373  int64_t channel_start_id = 0;
374  while (true) {
375  GetTopChannelsRequest get_top_channels_request;
376  GetTopChannelsResponse get_top_channels_response;
377  ClientContext get_top_channels_context;
378  get_top_channels_context.set_deadline(
380  get_top_channels_request.set_start_channel_id(channel_start_id);
381  Status status = channelz_stub_->GetTopChannels(
382  &get_top_channels_context, get_top_channels_request,
383  &get_top_channels_response);
384  if (!status.ok()) {
386  "GetTopChannels RPC with "
387  "GetTopChannelsRequest.channel_start_id=%d failed: %s",
388  int(channel_start_id),
389  get_top_channels_context.debug_error_string().c_str());
390  GPR_ASSERT(0);
391  }
392  for (const auto& _topchannel : get_top_channels_response.channel()) {
393  top_channels_.push_back(_topchannel);
394  all_channels_.push_back(_topchannel);
395  StoreChannelInJson(_topchannel);
396  }
397  if (!get_top_channels_response.end()) {
398  channel_start_id = GetChannelID(top_channels_.back()) + 1;
399  } else {
400  break;
401  }
402  }
403  std::cout << std::endl
404  << "Number of top channels = " << top_channels_.size()
405  << std::endl;
406  }
407 
408  // layer traverse for each top channel
410  for (const auto& _topchannel : top_channels_) {
411  int tree_depth = 0;
412  std::queue<grpc::channelz::v1::Channel> channel_queue;
413  std::queue<grpc::channelz::v1::Subchannel> subchannel_queue;
414  std::cout << "Tree depth = " << tree_depth << std::endl;
415  GetChannelDescedence(_topchannel, channel_queue, subchannel_queue);
416  while (!channel_queue.empty() || !subchannel_queue.empty()) {
417  ++tree_depth;
418  std::cout << "Tree depth = " << tree_depth << std::endl;
419  int ch_q_size = channel_queue.size();
420  int subch_q_size = subchannel_queue.size();
421  for (int i = 0; i < ch_q_size; ++i) {
422  grpc::channelz::v1::Channel ch = channel_queue.front();
423  channel_queue.pop();
424  GetChannelDescedence(ch, channel_queue, subchannel_queue);
425  }
426  for (int i = 0; i < subch_q_size; ++i) {
427  grpc::channelz::v1::Subchannel subch = subchannel_queue.front();
428  subchannel_queue.pop();
429  GetSubchannelDescedence(subch, channel_queue, subchannel_queue);
430  }
431  }
432  std::cout << std::endl;
433  }
434  }
435 
436  // dump data of all entities to stdout
437  void DumpStdout() {
438  std::string data_str;
439  for (const auto& _channel : all_channels_) {
440  std::cout << "channel ID" << GetChannelID(_channel) << "_"
441  << GetChannelName(_channel) << " data:" << std::endl;
442  // TODO(mohanli): TextFormat::PrintToString records time as seconds and
443  // nanos. Need a more human readable way.
445  printf("%s\n", data_str.c_str());
446  }
447  for (const auto& _subchannel : all_subchannels_) {
448  std::cout << "subchannel ID" << GetSubchannelID(_subchannel) << "_"
449  << GetSubchannelName(_subchannel) << " data:" << std::endl;
451  &data_str);
452  printf("%s\n", data_str.c_str());
453  }
454  for (const auto& _server : all_servers_) {
455  std::cout << "server ID" << GetServerID(_server) << "_"
456  << GetServerName(_server) << " data:" << std::endl;
458  printf("%s\n", data_str.c_str());
459  }
460  for (const auto& _socket : all_sockets_) {
461  std::cout << "socket ID" << GetSocketID(_socket) << "_"
462  << GetSocketName(_socket) << " data:" << std::endl;
463  ::google::protobuf::TextFormat::PrintToString(_socket.data(), &data_str);
464  printf("%s\n", data_str.c_str());
465  }
466  }
467 
468  // Store a channel in Json
471  std::string type = "Channel";
474  grpc_core::Json description_json = grpc_core::Json(description);
475  StoreEntityInJson(id, type, description_json);
476  }
477 
478  // Store a subchannel in Json
481  std::string type = "Subchannel";
484  &description);
485  grpc_core::Json description_json = grpc_core::Json(description);
486  StoreEntityInJson(id, type, description_json);
487  }
488 
489  // Store a server in Json
492  std::string type = "Server";
495  grpc_core::Json description_json = grpc_core::Json(description);
496  StoreEntityInJson(id, type, description_json);
497  }
498 
499  // Store a socket in Json
502  std::string type = "Socket";
505  grpc_core::Json description_json = grpc_core::Json(description);
506  StoreEntityInJson(id, type, description_json);
507  }
508 
509  // Store an entity in Json
511  const grpc_core::Json& description) {
514  now_,
515  gpr_time_from_seconds(absl::GetFlag(FLAGS_sampling_interval_seconds),
516  GPR_TIMESPAN));
517  std::stringstream ss;
518  const time_t time_now = now_.tv_sec;
519  ss << std::put_time(std::localtime(&time_now), "%F %T");
520  finish = ss.str(); // example: "2019-02-01 12:12:18"
521  ss.str("");
522  const time_t time_ago = ago.tv_sec;
523  ss << std::put_time(std::localtime(&time_ago), "%F %T");
524  start = ss.str();
526  grpc_core::Json::Object{{"Task", absl::StrFormat("%s_ID%s", type, id)},
527  {"Start", start},
528  {"Finish", finish},
529  {"ID", id},
530  {"Type", type},
531  {"Description", description}};
532  json_.mutable_array()->push_back(obj);
533  }
534 
535  // Dump data in json
536  std::string DumpJson() { return json_.Dump(); }
537 
538  // Check if one entity has been recorded
539  bool CheckID(int64_t id) {
540  if (id_set_.count(id) == 0) {
541  id_set_.insert(id);
542  return true;
543  } else {
544  return false;
545  }
546  }
547 
548  // Record current time
550 
551  private:
552  std::unique_ptr<grpc::channelz::v1::Channelz::Stub> channelz_stub_;
553  std::vector<grpc::channelz::v1::Channel> top_channels_;
554  std::vector<grpc::channelz::v1::Server> all_servers_;
555  std::vector<grpc::channelz::v1::Channel> all_channels_;
556  std::vector<grpc::channelz::v1::Subchannel> all_subchannels_;
557  std::vector<grpc::channelz::v1::Socket> all_sockets_;
558  std::unordered_set<int64_t> id_set_;
562 };
563 
564 int main(int argc, char** argv) {
565  grpc::testing::TestEnvironment env(&argc, argv);
566  grpc::testing::InitTest(&argc, &argv, true);
567  std::ofstream output_file(absl::GetFlag(FLAGS_output_json));
568  for (int i = 0; i < absl::GetFlag(FLAGS_sampling_times); ++i) {
569  ChannelzSampler channelz_sampler;
570  channelz_sampler.Setup(absl::GetFlag(FLAGS_custom_credentials_type),
571  absl::GetFlag(FLAGS_server_address));
572  std::cout << "Wait for sampling interval "
573  << absl::GetFlag(FLAGS_sampling_interval_seconds) << "s..."
574  << std::endl;
575  const gpr_timespec kDelay = gpr_time_add(
577  gpr_time_from_seconds(absl::GetFlag(FLAGS_sampling_interval_seconds),
578  GPR_TIMESPAN));
579  gpr_sleep_until(kDelay);
580  std::cout << "##### " << i << "th sampling #####" << std::endl;
581  channelz_sampler.RecordNow();
582  channelz_sampler.GetServersRPC();
583  channelz_sampler.GetSocketsOfServers();
584  channelz_sampler.GetTopChannelsRPC();
585  channelz_sampler.TraverseTopChannels();
586  channelz_sampler.DumpStdout();
587  if (!absl::GetFlag(FLAGS_output_json).empty()) {
588  output_file << channelz_sampler.DumpJson() << "\n" << std::flush;
589  }
590  }
591  output_file.close();
592  return 0;
593 }
ChannelzSampler::now_
gpr_timespec now_
Definition: channelz_sampler.cc:561
grpc_core::Json::Array
std::vector< Json > Array
Definition: src/core/lib/json/json.h:55
test_credentials_provider.h
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
grpc::testing::InitTest
void InitTest(int *argc, char ***argv, bool remove_flags)
Definition: test_config_cc.cc:28
gpr_timespec::tv_sec
int64_t tv_sec
Definition: gpr_types.h:51
ChannelzSampler::GetSocketRPC
grpc::channelz::v1::Socket GetSocketRPC(int64_t socket_id)
Definition: channelz_sampler.cc:161
obj
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1671
cleanup.Json
Json
Definition: cleanup.py:49
ChannelzSampler::DumpStdout
void DumpStdout()
Definition: channelz_sampler.cc:437
ChannelzSampler::GetSubchannelRPC
grpc::channelz::v1::Subchannel GetSubchannelRPC(int64_t subchannel_id)
Definition: channelz_sampler.cc:142
grpc_timeout_seconds_to_deadline
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s)
Definition: test/core/util/test_config.cc:81
grpc::testing::CredentialsProvider::GetChannelCredentials
virtual std::shared_ptr< ChannelCredentials > GetChannelCredentials(const std::string &type, ChannelArguments *args)=0
ChannelzSampler::StoreSocketInJson
void StoreSocketInJson(const grpc::channelz::v1::Socket &socket)
Definition: channelz_sampler.cc:500
generate.env
env
Definition: generate.py:37
ChannelzSampler::GetChannelName
std::string GetChannelName(const grpc::channelz::v1::Channel &channel)
Definition: channelz_sampler.cc:107
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
finish
static int finish(struct hexdump_ctx *ctx)
Definition: hexdump.c:148
ChannelzSampler::all_subchannels_
std::vector< grpc::channelz::v1::Subchannel > all_subchannels_
Definition: channelz_sampler.cc:556
ChannelzSampler::top_channels_
std::vector< grpc::channelz::v1::Channel > top_channels_
Definition: channelz_sampler.cc:553
CreateChannel
static grpc_channel * CreateChannel()
Definition: bm_call_create.cc:98
ChannelzSampler::Setup
void Setup(const std::string &custom_credentials_type, const std::string &server_address)
Definition: channelz_sampler.cc:289
ChannelzSampler::GetChannelDescedence
void GetChannelDescedence(const grpc::channelz::v1::Channel &channel, std::queue< grpc::channelz::v1::Channel > &channel_queue, std::queue< grpc::channelz::v1::Subchannel > &subchannel_queue)
Definition: channelz_sampler.cc:181
ChannelzSampler::GetChannelRPC
grpc::channelz::v1::Channel GetChannelRPC(int64_t channel_id)
Definition: channelz_sampler.cc:124
ChannelzSampler::GetSocketID
int64_t GetSocketID(const grpc::channelz::v1::Socket &socket)
Definition: channelz_sampler.cc:97
setup.description
description
Definition: setup.py:544
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
subchannel
RingHashSubchannelData * subchannel
Definition: ring_hash.cc:285
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
framework.rpc.grpc_channelz.Server
Server
Definition: grpc_channelz.py:42
time_now
static uint64_t time_now()
Definition: speed.cc:134
status
absl::Status status
Definition: rls.cc:251
server_address
std::string server_address("0.0.0.0:10000")
ChannelzSampler::all_servers_
std::vector< grpc::channelz::v1::Server > all_servers_
Definition: channelz_sampler.cc:554
ChannelzSampler::StoreServerInJson
void StoreServerInJson(const grpc::channelz::v1::Server &server)
Definition: channelz_sampler.cc:490
channelz_service_plugin.h
ChannelzSampler::channelz_stub_
std::unique_ptr< grpc::channelz::v1::Channelz::Stub > channelz_stub_
Definition: channelz_sampler.cc:552
framework.rpc.grpc_channelz.Channel
Channel
Definition: grpc_channelz.py:32
start
static uint64_t start
Definition: benchmark-pound.c:74
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
channelz_service.h
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
gpr_time_sub
GPRAPI gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:168
sampling_interval_seconds
std::string sampling_interval_seconds
Definition: channelz_sampler_test.cc:65
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
ChannelzSampler::GetSocketsOfServers
void GetSocketsOfServers()
Definition: channelz_sampler.cc:352
ChannelzSampler::GetServerName
std::string GetServerName(const grpc::channelz::v1::Server &server)
Definition: channelz_sampler.cc:102
gpr_sleep_until
GPRAPI void gpr_sleep_until(gpr_timespec until)
ChannelzSampler::StoreChannelInJson
void StoreChannelInJson(const grpc::channelz::v1::Channel &channel)
Definition: channelz_sampler.cc:469
ChannelzSampler::DumpJson
std::string DumpJson()
Definition: channelz_sampler.cc:536
grpc.h
custom_credentials_type
std::string custom_credentials_type("INSECURE_CREDENTIALS")
ChannelzSampler::GetTopChannelsRPC
void GetTopChannelsRPC()
Definition: channelz_sampler.cc:372
ChannelzSampler::GetSubchannelDescedence
void GetSubchannelDescedence(grpc::channelz::v1::Subchannel &subchannel, std::queue< grpc::channelz::v1::Channel > &channel_queue, std::queue< grpc::channelz::v1::Subchannel > &subchannel_queue)
Definition: channelz_sampler.cc:235
ChannelzSampler::GetServersRPC
void GetServersRPC()
Definition: channelz_sampler.cc:312
grpcpp.h
channel.h
ChannelzSampler::StoreSubchannelInJson
void StoreSubchannelInJson(const grpc::channelz::v1::Subchannel &subchannel)
Definition: channelz_sampler.cc:479
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition: gpr_types.h:36
ChannelzSampler::GetSocketName
std::string GetSocketName(const grpc::channelz::v1::Socket &socket)
Definition: channelz_sampler.cc:119
absl::GetFlag
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
Definition: abseil-cpp/absl/flags/flag.h:98
grpc::StatusCode
StatusCode
Definition: grpcpp/impl/codegen/status_code_enum.h:26
json.h
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
output_json
std::string output_json("output.json")
ChannelzSampler::GetChannelID
int64_t GetChannelID(const grpc::channelz::v1::Channel &channel)
Definition: channelz_sampler.cc:86
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
ChannelzSampler::CheckID
bool CheckID(int64_t id)
Definition: channelz_sampler.cc:539
ChannelzSampler::StoreEntityInJson
void StoreEntityInJson(std::string &id, std::string &type, const grpc_core::Json &description)
Definition: channelz_sampler.cc:510
server_credentials.h
google_benchmark.example.empty
def empty(state)
Definition: example.py:31
grpc::ClientContext
Definition: grpcpp/impl/codegen/client_context.h:195
test_config.h
ChannelzSampler::TraverseTopChannels
void TraverseTopChannels()
Definition: channelz_sampler.cc:409
grpc_core::Json::Object
std::map< std::string, Json > Object
Definition: src/core/lib/json/json.h:54
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
client_context.h
credentials.h
grpc::UNIMPLEMENTED
@ UNIMPLEMENTED
Operation is not implemented or not supported/enabled in this service.
Definition: grpcpp/impl/codegen/status_code_enum.h:117
ChannelzSampler::all_channels_
std::vector< grpc::channelz::v1::Channel > all_channels_
Definition: channelz_sampler.cc:555
gpr_time_add
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:135
server
Definition: examples/python/async_streaming/server.py:1
grpc::testing::GetCredentialsProvider
CredentialsProvider * GetCredentialsProvider()
Definition: test_credentials_provider.cc:169
framework.rpc.grpc_channelz.Socket
Socket
Definition: grpc_channelz.py:46
ChannelzSampler::GetServerID
int64_t GetServerID(const grpc::channelz::v1::Server &server)
Definition: channelz_sampler.cc:81
ChannelzSampler::json_
grpc_core::Json json_
Definition: channelz_sampler.cc:559
google::protobuf::TextFormat::PrintToString
static bool PrintToString(const Message &message, std::string *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:2395
server_context.h
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
framework.rpc.grpc_channelz.Subchannel
Subchannel
Definition: grpc_channelz.py:38
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
ChannelzSampler
Definition: channelz_sampler.cc:78
absl::Status::ok
ABSL_MUST_USE_RESULT bool ok() const
Definition: third_party/abseil-cpp/absl/status/status.h:802
test_config.h
tests.unit._contextvars_propagation_test._server
def _server()
Definition: _contextvars_propagation_test.py:54
main
int main(int argc, char **argv)
Definition: channelz_sampler.cc:564
ChannelzSampler::GetSubchannelName
std::string GetSubchannelName(const grpc::channelz::v1::Subchannel &subchannel)
Definition: channelz_sampler.cc:113
ABSL_FLAG
ABSL_FLAG(std::string, server_address, "", "channelz server address")
test_server.socket
socket
Definition: test_server.py:65
ChannelzSampler::RecordNow
void RecordNow()
Definition: channelz_sampler.cc:549
ChannelzSampler::all_sockets_
std::vector< grpc::channelz::v1::Socket > all_sockets_
Definition: channelz_sampler.cc:557
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
server.h
gpr_timespec
Definition: gpr_types.h:50
grpc_core::Json::mutable_array
Array * mutable_array()
Definition: src/core/lib/json/json.h:180
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
ChannelzSampler::GetSubchannelID
int64_t GetSubchannelID(const grpc::channelz::v1::Subchannel &subchannel)
Definition: channelz_sampler.cc:91
sampling_times
std::string sampling_times
Definition: channelz_sampler_test.cc:64
to_string
static bool to_string(zval *from)
Definition: protobuf/php/ext/google/protobuf/convert.c:333
grpc_core::Json
Definition: src/core/lib/json/json.h:37
ChannelzSampler::rpc_timeout_seconds_
int64_t rpc_timeout_seconds_
Definition: channelz_sampler.cc:560
tests.fork.methods._channel
def _channel(args)
Definition: fork/methods.py:36
server_builder.h
grpc_core::Json::Dump
std::string Dump(int indent=0) const
Definition: json_writer.cc:336
ChannelzSampler::id_set_
std::unordered_set< int64_t > id_set_
Definition: channelz_sampler.cc:558
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
create_channel.h
gpr_time_from_seconds
GPRAPI gpr_timespec gpr_time_from_seconds(int64_t s, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:123
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:53