Skip to content

timescale/opentelemetry-demo

Repository files navigation

OpenTelemetry Demo

Summary

This repo contains a environment for demonstrating OpenTelemetry tracing support in Promscale.

Workshop

This repo is used to deliver workshops on OpenTelemetry Traces and SQL. If you are here to explore the workshop, head to this page.

The Password Generator Service

A password generator service is instrumented with OpenTelemetry tracing. This is an absurd service and should not be taken as a shining example of architecture nor coding. It exists as a playground example to generate traces. The lower service generates random lowercase letters. The upper service service generates random uppercase letters. The digit service generates random digits, and the special service generates random special characters. There is a generator service which makes calls to the other services to compose a random password. Finally, there is a load script which continuously calls the generator service in order to simulate user load.

The lower service is a Ruby app using Sinatra framework while the other services use Python with Flask.

There are two versions of the services. Those under the instrumented directory have explicit instrumentation for tracing, whereas the versions under the uninstrumented directory solely use auto-instrumentation.

The Observability Infrastructure

All of the microservices forward their traces to an instance of the OpenTelemetry Collector. The collector sends the traces on to an instance of the Promscale Collector which stores them in a TimescaleDB database. An instance of the Jaeger UI is pointed to the Promscale instance, and an instance of Grafana is pointed at both Jaeger and the TimescaleDB database. In this way, you can use SQL to query the traces directly in the database, and visualize tracing data in Jaeger and Grafana dashboards.

Running the System in Docker

When the system runs in docker it is configured via the docker compose file, and is operated with docker-compose. Run the following command from the root of the repo to (re)start the system.

docker-compose up --remove-orphans --build --detach

Once running, the following links will let you explore the various components of the system:

When you are ready to shutdown the system, use the following command.

docker-compose down

Running the System in Kubernetes

When you want to run the system in k8s you can use the following commands (if you have certmanager installed skip that step):

kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
kubectl apply -k ./yaml

You should wait for the OpenTelemetry Operator pod to come up before you run the second command.

You should see data flowing into Grafana automatically.

To access individual services as per the Docker instructions below you will need to run

sh ./yaml/port-forward.sh

Connecting to TimescaleDB

You can use any SQL client that supports PostgreSQL to connect to the TimescaleDB database. The database is not password protected.

Use the psql client to connect to the Timescaledb instance via:

psql -h localhost -p 5999 -d otel_demo -U postgres

Examples

Note: the default Grafana login credentials are user "admin" and password "admin". Once you log in for the first time you will be asked to update your password.

Request Rates

Grafana Dashboard

Queries

Error Rates

Grafana Dashboard

Queries

Request Durations

Grafana Dashboard

Queries

Service Dependencies

Grafana Dashboard

Queries

Upstream Spans

Grafana Dashboard

Queries

Downstream Spans

Grafana Dashboard

Queries