Tutorial on OpenTelemetry in Golang: Tracing with Grafana, Kubernetes, and Tempo

Posted by

OpenTelemetry Golang Tutorial

OpenTelemetry Golang Tutorial

In this tutorial, we will learn how to set up tracing in Grafana and Kubernetes using OpenTelemetry with Golang. We will also explore Tempo, an open-source distributed tracing system for monitoring and troubleshooting distributed systems.

Setting up OpenTelemetry with Golang

To get started with OpenTelemetry in Golang, you first need to install the necessary packages. You can do this by using the following command:

    go get go.opentelemetry.io/otel
    go get go.opentelemetry.io/otel/exporters/otlp
    go get go.opentelemetry.io/otel/sdk
  

Tracing in Grafana

Once you have set up OpenTelemetry in your Golang application, you can start tracing your application. To view these traces in Grafana, you will need to set up an OpenTelemetry exporter that sends the traces to Grafana. Here is an example of how you can set up the exporter:

    exporter, err := otlp.NewExporter(
      otlp.WithInsecure(),
      otlp.WithAddress("localhost:4317"),
    )
  

Tracing in Kubernetes

Tracing in Kubernetes can be done by configuring the OpenTelemetry exporter to send the traces to a centralized tracing system like Tempo. Here is an example of how you can set up the exporter to send traces to Tempo:

    exporter, err := otlp.NewExporter(
      otlp.WithSecure(),
      otlp.WithAddress("tempo.example.com:4317"),
    )
  

Using Tempo for Distributed Tracing

Tempo is an open-source tracing system that is designed to store and analyze trace data in a scalable and cost-effective way. By sending your traces to Tempo, you can easily monitor and troubleshoot your distributed systems. To configure your OpenTelemetry exporter to send traces to Tempo, use the following code:

    exporter, err := otlp.NewExporter(
      otlp.WithSecure(),
      otlp.WithAddress("tempo.example.com:4317"),
    )
  

By following this tutorial, you can set up tracing in Grafana and Kubernetes using OpenTelemetry with Golang and utilize Tempo for monitoring and troubleshooting your distributed systems.

0 0 votes
Article Rating
11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@bhanusudheer493
1 month ago

it doesn't need otel operator to be installed

@user-nd1wz5mh1w
1 month ago

Great content! very useful. Thank you very much!

@20081428s
1 month ago

Good video! Is it possible to integrate opentelemetry without editing the application code, since adding the ‘trace.xxx’ is really painful in large application. I would expect if there is a library for adding the hooks in the start and end of all functions, and record the called function as span with its name.

@arozendojr
1 month ago

Jaeger UI not the localhost ?

@danielwojnar3876
1 month ago

Great content! One of the best channels to learn from.

@thanhkhiet5089
1 month ago

oh very detail explanation and useful, thank a lot!!!

@arozendojr
1 month ago

Is it normal to have to manually place Jaeger Tracing in the application to be able to place the body inside Jaeger Web or is there an automatic way to see the body on a Tracing platform like Jaeger Web?

@agun21st
1 month ago

Very helpful video about tracing. I will implement on my project. Please make video on nodejs microservices Tracing with Opentelemetry and Tempo on AWS EKS.

@YordisPrieto
1 month ago

I wish you showed case using helm to add the tempo data source using terraform as well

@denisrazumnyi6456
1 month ago

Well done
what about make video about Grafana-agent? It's a very promising thing and can replace all exporters in the cluste.