xref: /aosp_15_r20/external/grpc-grpc/examples/python/observability/README.md (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1gRPC Observability Example
2=====================
3
4The examples here demonstrate how to setup gRPC Python Observability with Opentelemetry.
5
6More details about how to use gRPC Python Observability APIs can be found in [OpenTelemetry Metrics gRFC](https://github.com/grpc/proposal/blob/master/A66-otel-stats.md#opentelemetry-metrics).
7
8### Install Requirements
9
101. Navigate to this directory:
11
12```sh
13cd examples/python/observability
14```
15
162. Install requirements:
17
18```sh
19python -m pip install -r requirements.txt
20```
21
22### Run the Server
23
24Start the server:
25
26```sh
27python -m observability_greeter_server
28```
29
30### Run the Client
31
32Note that client should start within 10 seconds of the server becoming active.
33
34```sh
35python -m observability_greeter_client
36```
37
38### Verifying Metrics
39
40The example will print a list of metric names collected.
41
42Server Side:
43
44```
45Server started, listening on 50051
46Metrics exported on Server side:
47grpc.server.call.started
48grpc.server.call.sent_total_compressed_message_size
49grpc.server.call.rcvd_total_compressed_message_size
50grpc.server.call.duration
51```
52
53Client Side:
54
55```
56Greeter client received: Hello You
57Metrics exported on client side:
58grpc.client.call.duration
59grpc.client.attempt.started
60grpc.client.attempt.sent_total_compressed_message_size
61grpc.client.attempt.rcvd_total_compressed_message_size
62grpc.client.attempt.duration
63```
64