ObserveNow
...
Integrations
Applications

Go

Go Tracing Instrumentation

OpenTelemetry is the recommended approach to instrument for tracing. For your Go applications, please follow the instructions in the following document to instrument:

Summary of Steps

  1. Determine what framework (standard or 3rd-party) your Go apps are using (e.g., net/http, gorilla/mux, etc)
  2. Navigate to OpenTelemetry Registry to find if the packages from (1) have an already existing instrumentation library
  3. Import the instrumented libraries into your app and initialize them (the trace initialization can be a one-time addition to your own shared library or, alternatively, some initTracer() func in each app)
  4. Wrap the handler functions to achieve the "auto" instrumentation

Example

The example in the above links shows the above steps for the net/http package.

Here is another example:

  • This sample Go app is using the gofiber/fiber package.
  • We've found that instrumentation libraries exist on the OpenTelemetry Registry and clicked to verify the library names.
  • Import the instrumented libraries:
Go

  • Trace initialization:
Go


(4) Tell the app to use the middleware to auto-wrap your handlers

Go


For production use, you'll be using the Zipkin exporter (as seen in the code).

This will make the Go application to emit spans which will be collected by the OpenTelemetry collector installed as part of the OpsVerse agent and forwarded to the tracing backend.