grpc/examples/cpp/otel
Yash Tibrewal ac303a09f6 [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686)
Public Changes -
* Add a pkgconfig installer for `grpcpp_otel_plugin`

Example Changes -
* Add example of how to use the pkgconfig for `grpcpp_otel_plugin` with the existing OpenTelemetry example.
* Add another OpenTelemetry example that uses OTel's OStream exporter. This makes it easier to test the pkgconfig file for `grpcpp_otel_plugin` since the OStream exporter does not require any additional dependencies, as opposed to the Prometheus exporter.

Test changes -
* Modify `run_distrib_test_cmake_pkgconfig.sh` test to install opentelemetry and build the example with the OStream exporter.

Closes #36686

PiperOrigin-RevId: 636965475
2024-05-24 10:41:11 -07:00
..
ostream [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
BUILD [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
CMakeLists.txt [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
Makefile [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
README.md [OTel C++] Add CMake build support (#36063) 2024-03-07 16:12:10 -08:00
greeter_callback_client.cc [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
greeter_callback_server.cc [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
util.cc [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00
util.h [OTel] Generate pkg-config file for grpcpp_otel_plugin (#36686) 2024-05-24 10:41:11 -07:00

README.md

gRPC C++ OpenTelemetry Example

The opentelemetry example builds on the Hello World Example and changes the gRPC client and server to show a sample way of configuring the gRPC OpenTelemetry plugin with a prometheus exporter.

For more information on the gRPC OpenTelemetry plugin, please refer to - * A66: OpenTelemetry Metrics

  • https://opentelemetry.io/

Running the example

To run the server -

$ tools/bazel run examples/cpp/otel:greeter_callback_server

To run the client -

$ tools/bazel run examples/cpp/otel:greeter_callback_client

The client continuously sends an RPC to the server every second.

To make sure that the server and client metrics are being exported properly, in a separate terminal, run the following -

$ curl localhost:9464/metrics
$ curl localhost:9465/metrics

NOTE: If the prometheus endpoint configured is overridden, please update the target in the above curl command.

CMake Instructions

The following libraries need to be installed before building the example with CMake -

  • absl
  • protobuf
  • prometheus-cpp
  • opentelemetry-cpp (with the options -DWITH_ABSEIL=ON -DWITH_PROMETHEUS=ON)
  • grpc (with the option -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON)

You can find a complete set of instructions for building gRPC and running the Hello World app in the C++ Quick Start.