xref: /aosp_15_r20/external/grpc-grpc-java/examples/example-gcp-observability/README.md (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1*e07d83d3SAndroid Build Coastguard WorkergRPC GCP Observability Example
2*e07d83d3SAndroid Build Coastguard Worker================
3*e07d83d3SAndroid Build Coastguard Worker
4*e07d83d3SAndroid Build Coastguard WorkerThe GCP Observability example consists of a Hello World client and a Hello World server instrumented for logs, metrics and tracing.
5*e07d83d3SAndroid Build Coastguard Worker
6*e07d83d3SAndroid Build Coastguard Worker__Please refer to Microservices Observability user guide for setup.__
7*e07d83d3SAndroid Build Coastguard Worker
8*e07d83d3SAndroid Build Coastguard Worker### Build the example
9*e07d83d3SAndroid Build Coastguard Worker
10*e07d83d3SAndroid Build Coastguard WorkerBuild the Observability client & server. From the `grpc-java/examples/example-gcp-observability`
11*e07d83d3SAndroid Build Coastguard Workerdirectory:
12*e07d83d3SAndroid Build Coastguard Worker```
13*e07d83d3SAndroid Build Coastguard Worker$ ../gradlew installDist
14*e07d83d3SAndroid Build Coastguard Worker```
15*e07d83d3SAndroid Build Coastguard Worker
16*e07d83d3SAndroid Build Coastguard WorkerThis creates the scripts `build/install/example-gcp-observability/bin/gcp-observability-client` and
17*e07d83d3SAndroid Build Coastguard Worker`build/install/example-gcp-observability/bin/gcp-observability-server`.
18*e07d83d3SAndroid Build Coastguard Worker
19*e07d83d3SAndroid Build Coastguard Worker### Run the example with configuration
20*e07d83d3SAndroid Build Coastguard Worker
21*e07d83d3SAndroid Build Coastguard WorkerTo use Observability, you should first setup and configure authorization as mentioned in the user guide.
22*e07d83d3SAndroid Build Coastguard Worker
23*e07d83d3SAndroid Build Coastguard WorkerYou need to set the `GRPC_GCP_OBSERVABILITY_CONFIG_FILE` environment variable to point to the gRPC GCP Observability configuration file (preferred) or if that
24*e07d83d3SAndroid Build Coastguard Workeris not set then `GRPC_GCP_OBSERVABILITY_CONFIG` environment variable to gRPC GCP Observability configuration value. This is needed by both
25*e07d83d3SAndroid Build Coastguard Worker`build/install/example-gcp-observability/bin/gcp-observability-client` and
26*e07d83d3SAndroid Build Coastguard Worker`build/install/example-gcp-observability/bin/gcp-observability-server`.
27*e07d83d3SAndroid Build Coastguard Worker
28*e07d83d3SAndroid Build Coastguard Worker1. To start the observability-enabled example server on its default port of 50051, run:
29*e07d83d3SAndroid Build Coastguard Worker```
30*e07d83d3SAndroid Build Coastguard Worker$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json
31*e07d83d3SAndroid Build Coastguard Worker$ ./build/install/example-gcp-observability/bin/gcp-observability-server
32*e07d83d3SAndroid Build Coastguard Worker```
33*e07d83d3SAndroid Build Coastguard Worker
34*e07d83d3SAndroid Build Coastguard Worker2. In a different terminal window, run the observability-enabled example client:
35*e07d83d3SAndroid Build Coastguard Worker```
36*e07d83d3SAndroid Build Coastguard Worker$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json
37*e07d83d3SAndroid Build Coastguard Worker$ ./build/install/example-gcp-observability/bin/gcp-observability-client
38*e07d83d3SAndroid Build Coastguard Worker```
39*e07d83d3SAndroid Build Coastguard Worker
40