grpc/examples/python/observability/csm
Xuan Wang 4f3fba65fb
[Python CSM] Add example for CSM O11Y (#36829)
Verified that when following User Guide, we're able to collect metrics
and export to GCP.
Images are available at:
*
`us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-client:latest`
*
`us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-server:latest`
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
2024-06-07 11:20:23 -07:00
..
BUILD.bazel [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00
Dockerfile.client [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00
Dockerfile.server [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00
README.md [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00
csm_greeter_client.py [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00
csm_greeter_server.py [Python CSM] Add example for CSM O11Y (#36829) 2024-06-07 11:20:23 -07:00

README.md

gRPC Python CSM Hello World Example

This CSM example builds on the Python xDS Example and changes the gRPC client and server to accept configuration from an xDS control plane and test CSM observability.

Configuration

The client takes the following command-line arguments -

  • --target - By default, the client tries to connect to the target "xds:///helloworld:50051" and gRPC would use xDS to resolve this target and connect to the server backend. This can be overriden to change the target.
  • --secure_mode - Whether to use xDS to retrieve server credentials. Default value is False.
  • --prometheus_endpoint - Endpoint used for prometheus. Default value is localhost:9464.

The server takes the following command-line arguments -

  • --port - Port on which the Hello World service is run. Defaults to 50051.
  • --secure_mode - Whether to use xDS to retrieve server credentials. Default value is False.
  • --server_id - The server ID to return in responses.
  • --prometheus_endpoint - Endpoint used for prometheus. Default value is localhost:9464.

Building

From the gRPC workspace folder:

Client:

docker build -f examples/python/observability/csm/Dockerfile.client -t "us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-client" .

Server:

docker build -f examples/python/observability/csm/Dockerfile.server -t "us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-server" .

And then push the tagged image using docker push.