opentelemetry-demo
is a collection of examples and tutorials for OpenTelemetry, an open-source observability framework. It provides a hands-on experience with various aspects of OpenTelemetry, including tracing, metrics, and logs. In this guide, we will walk you through the process of deploying and installing opentelemetry-demo
in various environments.
Prerequisites
Before we begin, ensure you have the following prerequisites in place:
- Docker: To run the demo containers, you need Docker installed on your system. You can download Docker from the official website.
- Git: To clone the
opentelemetry-demo
repository, you need Git installed on your system. You can download Git from the official website. - Kubernetes (Optional): If you plan to deploy
opentelemetry-demo
on Kubernetes, you need a Kubernetes cluster. You can set up a local Kubernetes cluster using Minikube or use a managed Kubernetes service like Google Kubernetes Engine (GKE) or Amazon Elastic Kubernetes Service (EKS).
Installing opentelemetry-demo
Locally
To install opentelemetry-demo
locally, follow these steps:
- Clone the
opentelemetry-demo
repository:
git clone https://github.com/open-telemetry/opentelemetry-demo.git
cd opentelemetry-demo
- Build the Docker images:
make docker-images
This command builds the Docker images for all the demo applications.
- Run the demo applications:
make run
This command starts the demo applications in separate containers. By default, it starts the go-micro
and java-spring-boot
demos.
Installing opentelemetry-demo
on Docker Swarm
To install opentelemetry-demo
on Docker Swarm, follow these steps:
- Clone the
opentelemetry-demo
repository:
git clone https://github.com/open-telemetry/opentelemetry-demo.git
cd opentelemetry-demo
- Build the Docker images:
make docker-images
- Create a
docker-compose.yml
file in theopentelemetry-demo
directory with the following content:
version: '3.3'
services:
go-micro:
image: ghcr.io/open-telemetry/opentelemetry-demo:go-micro
ports:
- "50051:50051"
- "9000:9000"
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/etc/google.json
java-spring-boot:
image: ghcr.io/open-telemetry/opentelemetry-demo:java-spring-boot
ports:
- "8080:8080"
depends_on:
- go-micro
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/etc/google.json
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "6831:6831"
- "6832:6832"
environment:
- JAEGER_ZIPKIN_HTTP_PORT=9000
- JAEGER_ZIPKIN_HOST=go-micro
- JAEGER_COLLECTOR_OTLP_ENDPOINT=http://localhost:4317
otlp-gateway:
image: opentelemetry/opentelemetry-collector:latest
ports:
- "4317:4317"
depends_on:
- go-micro
- java-spring-boot
- jaeger
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/etc/google.json
- OTEL_EXPORTER_JAEGER_ENDPOINT=http://jaeger:14268/api/traces
- OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317/v1/traces
- OTEL_EXPORTER_OTLP_HEADERS="Content-Type:application/json; X-OpenTelemetry-Traceid:{}"
- OTEL_EXPORTER_OTLP_INJECT=all
This file defines a Docker Swarm stack with the go-micro
, java-spring-boot
, jaeger
, and otlp-gateway
services.
- Start the demo applications:
docker stack deploy opentelemetry-demo --compose-file docker-compose.yml
This command deploys the opentelemetry-demo
stack defined in the docker-compose.yml
file.
Installing opentelemetry-demo
on Kubernetes
To install opentelemetry-demo
on Kubernetes, follow these steps:
- Clone the
opentelemetry-demo
repository:
git clone https://github.com/open-telemetry/opentelemetry-demo.git
cd opentelemetry-demo
- Create a
values.yaml
file in theopentelemetry-demo/k8s/jaeger
directory with the following content:
replicaCount: 1
image:
repository: jaegertracing/all-in-one
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 16686
targetPort: 16686
externalPort: 16686
This file defines the configuration for the Jaeger service in the Kubernetes deployment.
- Create a
values.yaml
file in theopentelemetry-demo/k8s/otlp-gateway
directory with the following content:
replicaCount: 1
image:
repository: opentelemetry/opentelemetry-collector
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 4317
targetPort: 4317
externalPort: 4317
This file defines the configuration for the OpenTelemetry Collector service in the Kubernetes deployment.
- Create a
values.yaml
file in theopentelemetry-demo/k8s/go-micro
directory with the following content:
image:
repository: ghcr.io/open-telemetry/opentelemetry-demo
tag: go-micro
pullPolicy: IfNotPresent
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/google.json
containerPorts:
- containerPort: 50051
- containerPort: 9000
service:
type: ClusterIP
port: 50051
targetPort: 50051
externalPort: 50051
name: go-micro
---
apiVersion: v1
kind: Service
metadata:
name: go-micro-jaeger
spec:
selector:
app: go-micro
ports:
- name: jaeger
port: 14268
targetPort: 14268
- name: grpc
port: 50051
targetPort: 50051
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: go-micro-otlp
spec: