The sample app consists of two simple Golang web services that simply print out I am a GO application running inside Docker. to the page. For the purposes of this demo, one of the services (located in the /src/fast directory), has normal performance. You’ll let that run for a bit to get some baseline data. Then, deploy the the service in the /src/slow directory to emulate poor performance after a deploy. Once you “investigate” that performance in Lightstep in a later step, you’ll rollback the deploy of the slow service and notice the performance improvement.

Both services are instrumented using OpenTelemetry. They use the Go tracer and exporter to batch and transport telemetry data to a backend system, in this case, Lightstep.

Here’s the snippet of code that initializes the tracer to use the exporter.

1
2
3
4
5
6
7
8
9
10
11
12
func initTracer() {
	lExporter, err := lightstep.NewExporter(
		lightstep.WithAccessToken(getEnvOrDefault("LS_KEY", "your_access_token")),
		lightstep.WithServiceName(getEnvOrDefault("SERVICE_NAME", "web-service")))

	tp, err := sdktrace.NewProvider(sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
		sdktrace.WithSyncer(lExporter))
	if err != nil {
		log.Fatal(err)
	}
	global.SetTraceProvider(tp)
}

What Did We Learn?

  • OpenTelemetry uses tracers and exporters to collect and report telemetry data to a backend system.
  • OpenTelemetry uses attributes to collect metadata about spans in a trace. The service.version attribute is used by Lightstep to understand when a new deploy occurs.