Skip to content

ajimenez1503/opentelemetry-go-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opentelemetry-go-examples

Example of open telemetry in Go

Example 1 - Fibonacci

cd fibonacci
go run .
cat traces.txt

Example 2 - Zipkin

Send an example span to a Zipkin service.

docker run -p 9411:9411 openzipkin/zipkin
go run main.go

Example 3 - Jaeger

Send an example span to a Jaeger service.

docker run --name jaeger \
  -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
  -p 5775:5775/udp \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 14268:14268 \
  -p 9411:9411 \
  jaegertracing/all-in-one:1.6
go run main.go

alt text

Example 4 - Prometheus

Send metris to a Prometheus service.

go run main.go

alt text

Example 5 - Opentelemetry colector k8s

This example illustrates how to export trace and metric data from the OpenTelemetry-Go SDK to the OpenTelemetry Collector. From there, we bring the trace data to Jaeger and the metric data to Prometheus The complete flow is:

                                          -----> Jaeger (trace)
App + SDK ---> OpenTelemetry Collector ---|
                                          -----> Prometheus (metrics)
  • Ref: https://github.com/open-telemetry/opentelemetry-go/tree/main/example/otel-collector

  • Prerequisites:

    • MicroK8s
      sudo snap install microk8s --classic
      microk8s enable dns storage
      microk8s enable observability
      
  • Running:

    • Terminal 1
      
        // Create namespace 
        microk8s kubectl apply -f k8s/namespace.yaml
      
        // Deploy jaeger 
        microk8s kubectl create -n observability -f https://github.com/jaegertracing/jaeger-operator/releases/download/v1.41.0/jaeger-operator.yaml
      
        microk8s kubectl apply -f k8s/jaeger.yaml
      
        // Deploy prometheus
        microk8s kubectl apply -f k8s/prometheus-service.yaml   # Prometheus instance
          microk8s kubectl apply -f k8s/prometheus-monitor.yaml   # Service monitor
      
        // Deploy opentelemetry colector 
        microk8s kubectl apply -f k8s/otel-collector.yaml
      
    • Terminal 2:
        go run main.go
      
  • Clean up

microk8s kubectl delete -f k8s/otel-collector.yaml

microk8s kubectl delete -f k8s/prometheus-monitor.yaml
microk8s kubectl delete -f k8s/prometheus-service.yaml

microk8s kubectl delete -f k8s/jaeger.yaml

microk8s kubectl delete -n observability -f https://github.com/jaegertracing/jaeger-operator/releases/download/v1.41.0/jaeger-operator.yaml
microk8s kubectl delete namespaces observability

Example 6 - Opentelemetry colector docker-compose

This example illustrates how to export trace and metric data from the OpenTelemetry-Go SDK to the OpenTelemetry Collector. From there, we bring the trace data to Jaeger and the metric data to Prometheus The complete flow is:

                                          -----> Jaeger (trace)
                                          -----> zipkin (trace)
App + SDK ---> OpenTelemetry Collector ---|
                                          -----> Prometheus (metrics)

About

Example of open telemetry in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published