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
6 months ago

it doesn't need otel operator to be installed

@user-nd1wz5mh1w
6 months ago

Great content! very useful. Thank you very much!

@20081428s
6 months 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
6 months ago

Jaeger UI not the localhost ?

@danielwojnar3876
6 months ago

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

@thanhkhiet5089
6 months ago

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

@arozendojr
6 months 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
6 months 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
6 months ago

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

@denisrazumnyi6456
6 months ago

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