Skip to content

Files

Latest commit

Apr 15, 2025
9e07406 · Apr 15, 2025

History

History
This branch is 7 commits ahead of, 21 commits behind master.

example-opentelemetry

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.