Setup and Install OpenTelemetry Go

Get up and running with OpenTelemetry in just a few quick steps! The setup process consists of two phases--getting OpenTelemetry installed and configured, and then validating that configuration to ensure that data is being sent as expected. This guide explains how to download, install, and run OpenTelemetry in Go.

Requirements

  • Go version 1.13 or newer
  • An app to add OpenTelemetry to. You can use this example application or bring your own.
  • A Lightstep account, or another OpenTelemetry backend.

Need an account? Create a free Lightstep account here.

Installation

To install OpenTelemetry, we recommend our handy OTel-Launcher, which simplifies the process.

go get "github.com/lightstep/otel-launcher-go/launcher"

Run OpenTelemetry

Once you've downloaded the launcher, you can run OpenTelemetry using the following basic configuration.

LS Note: When connecting to Lightstep, a project Access Token is required.

The full list of configuration options can be found in the README.

import "github.com/lightstep/otel-launcher-go/launcher"

func main() {
   otel := launcher.ConfigureOpentelemetry(
       launcher.WithServiceName("service-123"),
       launcher.WithAccessToken("<ACCESS TOKEN>"),
   )
   defer otel.Shutdown()
}

Install Instrumentation Libraries

Besides OpenTelemetry core modules, it is important to install instrumentation packages for every important library and framework which your service depends upon. Beyond the critical telemetry data these components emit, library and framework integrations are often required to ensure that the trace context is properly propagated.

Learn more about available instrumentation here.

Validate Installation by Checking for Traces

With your application running, you can now verify that you’ve installed OpenTelemetry correctly by confirming that telemetry data is being reported to your observability backend.

To do this, you need to make sure that your application is actually generating data. Applications will generally not produce traces unless they are being interacted with, and opentelemetry will often buffer data before sending it. So it may take some amount of time and interaction before your application data begins to appear in your backend.

Validate your traces in Lightstep:

  1. Trigger an action in your app that generates a web request.
  2. In Lightstep, click on the Explorer in the sidebar.
  3. Refresh your query until you see traces.
  4. View the traces and verify that important aspects of your application are captured by the trace data.

Auto-instrumentation

Frameworks, database clients, and other 3rd party libraries contain critical data. The fastest and most effective way to instrument your application is to install instrumentation libraries. Often, this is enough instrumentation to get started.

All current instrumentation can be found on Github.

Available instrumentation includes:

Backwards compatibility with Opentracing can be installed in the same manner.

Don’t see support for your framework or library? Join the beta by filing an issue, or try your hand at writing an instrumentation adapter yourself!