This Quick Start will have you configure your tracer to communicate with the LightStep Satellites and create a single span on your service. You install both the OpenTracing API and LightStep tracer and then use the OpenTracing and LightStep APIs to instrument your code.

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.
    • Click the Project Settings button.
    • 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.

    1
    2
    
    go get 'github.com/lightstep/lightstep-tracer-go'
    go get 'github.com/opentracing/opentracing-go'
    
  3. In your application code, add a reference to the LightStep Tracer and to the OpenTracing API.

    1
    2
    3
    4
    
    import (
      "github.com/opentracing/opentracing-go"
      "github.com/lightstep/lightstep-tracer-go"
    )
    
  4. 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.

    On-Premise:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    
    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)
      ...
    }
    


    Public:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
     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)
     ...
     }
    


    Developer:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
     package main
     . . .
     func main() {
      ...
     lightStepTracer := lightstep.NewTracer(lightstep.Options{
         Collector: lightstep.Endpoint{
          Host:      "localhost",
         Port:      8360,
          Plaintext: true,
         },
         AccessToken: "developer",
         Tags: map[string]interface{}{
         lightstep.ComponentNameKey: "YOUR_SERVICE_NAME",
         },
      })
     opentracing.SetGlobalTracer(lightStepTracer)
      ...
     }
    
  5. Before shutdown, be sure to close the tracer so that any remaining spans will be sent.

    1
    
    lightStepTracer.Close(context.Background())
    
  6. Test that everything is connected by sending a test span.

    1
    2
    3
    4
    5
    6
    7
    
    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())
    
  7. Run the app.
  8. 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.