LightStep

LightStep Documentation

Welcome to the LightStep developer hub. You'll find comprehensive guides and documentation to help you start working with LightStep as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Golang Quick Start

This Quick Start will have you configure your tracer to communicate with the LightStep Satellites and create a single span - span - Represents a logical unit of work in the system that has a start time and a duration. Spans can be nested. on your service. You install both the OpenTracing API and LightStep tracer and then use the OpenTracing and LightStep APIs to instrument your code.

You need to know OpenTracing before proceeding

While LightStep offers tracers and APIs specific to its tracing software, you will still use the OpenTracing API to fully instrument your code. Be sure you have read and are familiar with both LightStep tracers and the OpenTracing specification in your application's language.

  1. Find your access token in LightStep. You'll need this to configure your LightStep tracer.
    a. Click the Project Settings button.
    b. In the Access Tokens table, click the Copy icon to copy your access token to the clipboard.

  2. Install the OpenTracing and LightStep tracer packages.

go get 'github.com/lightstep/lightstep-tracer-go'
go get 'github.com/opentracing/opentracing-go'
  1. In your application code, add a reference to the LightStep Tracer and to the OpenTracing API.
import (
  "github.com/opentracing/opentracing-go"
  "github.com/lightstep/lightstep-tracer-go"
)
  1. Early in your application’s initialization, configure the LightStep tracer and register it as the OpenTracing Global Tracer. As part of the configuration, you need to add your access token and add a tag to hold the value of your service's name.

Use the right code for your environment!

When initializing the tracer, you pass in properties to the LightStep Satellites that collect the span data. Be sure to use the code for your LightStep Satellite environment - On-Premise, LightStep Public Satellite pool, or Developer Mode Satellite.

package main
. . .
func main() {
  ...
  lightStepTracer := lightstep.NewTracer(lightstep.Options{
    Collector: lightstep.Endpoint{
		  Host:"{your_load_balancer_DNS_name_or_IP_address}",
		  Plaintext: true,
	  },
    AccessToken: "YOUR_ACCESS_TOKEN",
    Tags: map[string]interface{}{
      lightstep.ComponentNameKey: "YOUR_SERVICE_NAME",
    },
  })
  opentracing.SetGlobalTracer(lightStepTracer)
  ...
}
package main
. . .
func main() {
  ...
  lightStepTracer := lightstep.NewTracer(lightstep.Options{
    AccessToken: "YOUR_ACCESS_TOKEN",
    Tags: map[string]interface{}{
      lightstep.ComponentNameKey: "YOUR_SERVICE_NAME",
    },
  })
  opentracing.SetGlobalTracer(lightStepTracer)
  ...
}
package main
. . .
func main() {
  ...
  lightStepTracer := lightstep.NewTracer(lightstep.Options{
    Collector: lightstep.Endpoint{
		  Host:      "localhost",
		  Port:      8360,
		  Plaintext: true,
	  },
    AccessToken: "YOUR_ACCESS_TOKEN",
    Tags: map[string]interface{}{
      lightstep.ComponentNameKey: "YOUR_SERVICE_NAME",
    },
  })
  opentracing.SetGlobalTracer(lightStepTracer)
  ...
}
  1. Before shutdown, be sure to close the tracer so that any remaining spans will be sent.
lightStepTracer.Close(context.Background())
  1. Test that everything is connected by sending a test span.
span = opentracing.GlobalTracer().StartSpan('test_span');
span.SetTag("hello", "world")
span.LogKV("event", "it's a beautiful day")
span.Finish()

// tracer.flush() will ensure that your span is sent
tracer.Flush(context.Background())
  1. Run the app.
  2. Open LightStep. You should see your service in the Service directory list.

If you want to continue adding instrumentation by creating more spans and connecting them into traces, continue on with Go: Add Spans.

Updated about 23 hours ago


Golang Quick Start


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.