grpc-java/examples/example-opentelemetry
Eric Anderson a977385187
Upgrade dependencies
The GSON upgrade slightly changed an error string, so the test was
updated to be less of a change detector.

Some OpenTelemetry dependencies are alpha versions, so needed an
adjustment in build.gradle to accept the versions. Similarly, Undertow
includes Final in its version numbers which needs to be accepted.
2024-07-11 15:09:00 -07:00
..
src/main examples: Add gRPC OpenTelemetry example (#11299) 2024-06-21 14:35:02 -07:00
README.md examples: Add gRPC OpenTelemetry example (#11299) 2024-06-21 14:35:02 -07:00
build.gradle Upgrade dependencies 2024-07-11 15:09:00 -07:00
settings.gradle examples: Add gRPC OpenTelemetry example (#11299) 2024-06-21 14:35:02 -07:00

README.md

gRPC OpenTelemetry Example

The example extends the gRPC "hello world" example by modifying the client and server to showcase a sample configuration for gRPC OpenTelemetry with a Prometheus exporter.

The example requires grpc-java to be pre-built. Using a release tag will download the relevant binaries from a maven repository. But if you need the latest SNAPSHOT binaries you will need to follow COMPILING to build these.

Build the example

The source code is here. To build the example, run in this directory:

$ ../gradlew installDist

The build creates scripts opentelemetry-server and opentelemetry-client in the build/install/example-opentelemetry/bin/ directory which can be used to run this example. The example requires the server to be running before starting the client.

Run the example

opentelemetry-server:

The opentelemetry-server accepts optional arguments for server-port and prometheus-port:

USAGE: opentelemetry-server [server-port [prometheus-port]]

opentelemetry-client:

The opentelemetry-client accepts optional arguments for user-name, target and prometheus-port:

USAGE: opentelemetry-client-client [user-name [target [prometheus-port]]]

The opentelemetry-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.