Debian Codegraph @

examples/python/debug/README.md

raw
1 # gRPC Python Debug Example
2
3 This example demonstrate the usage of Channelz. For a better looking website,
4 the [gdebug](https://github.com/grpc/grpc-experiments/tree/master/gdebug) uses
5 gRPC-Web protocol and will serve all useful information in web pages.
6
7 ## Channelz: Live Channel Tracing
8
9 Channelz is a channel tracing feature. It will track statistics like how many
10 messages have been sent, how many of them failed, what are the connected
11 sockets. Since it is implemented in C-Core and has low-overhead, it is
12 recommended to turn on for production services. See [Channelz design
13 doc](https://github.com/grpc/proposal/blob/master/A14-channelz.md).
14
15 ## How to enable tracing log
16 The tracing log generation might have larger overhead, especially when you try
17 to trace transport. It would result in replicating the traffic loads. However,
18 it is still the most powerful tool when you need to dive in.
19
20 ### The Most Verbose Tracing Log
21
22 Specify environment variables, then run your application:
23
24 ```
25 GRPC_VERBOSITY=debug
26 GRPC_TRACE=all
27 ```
28
29 For more granularity, please see
30 [environment_variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md).
31
32 ### Debug Transport Protocol
33
34 ```
35 GRPC_VERBOSITY=debug
36 GRPC_TRACE=tcp,http,secure_endpoint,transport_security
37 ```
38
39 ### Debug Connection Behavior
40
41 ```
42 GRPC_VERBOSITY=debug
43 GRPC_TRACE=call_error,connectivity_state,pick_first,round_robin,glb
44 ```
45
46 ## How to debug your application?
47
48 `pdb` is a debugging tool that is available for Python interpreters natively.
49 You can set breakpoint, and execute commands while the application is stopped.
50
51 The simplest usage is add a single line in the place you want to inspect:
52 `import pdb; pdb.set_trace()`. When interpreter see this line, it would pop out
53 a interactive command line interface for you to inspect the application state.
54
55 For more detailed usage, see https://docs.python.org/3/library/pdb.html.
56
57 **Caveat**: gRPC Python uses C-Extension under-the-hood, so `pdb` may not be
58 able to trace through the whole stack.
59
60 ## gRPC Command Line Tool
61
62 `grpc_cli` is a handy tool to interact with gRPC backend easily. Imageine you can
63 inspect what service does a server provide without writing any code, and make
64 gRPC calls just like `curl`.
65
66 The installation guide: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md#code-location
67 The usage guide: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md#usage
68 The source code: https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc