go get

Package redigo provides functions to trace the garyburd/redigo package ( To start tracing Redis commands, use the TracedDial function to create a connection, passing in a service name of choice. Alternatively, provide a redis URL to the TracedDialURL function When using a redigo Pool, set your Dial function to return a traced connection

by signalfx

v1.12.0 (see all)License:BSD-3-Clause
go get

ℹ️  SignalFx was acquired by Splunk in October 2019. See Splunk SignalFx for more information.

SignalFx Tracing Library for Go

GitHub Release Go Reference go.mod CircleCI

The SignalFx Tracing Library for Go helps you automatically instrument Go applications with instrumented library helpers and a tracer to capture and report distributed traces to SignalFx. You can also use the library to manually instrument Go applications with the OpenTracing API.

Requirements and supported software

These are the requirements to use the SignalFx Tracing Library for Go:

These are the supported libraries you can instrument:

database/sqlStandard Library
net/httpStandard Library

Other libraries are available to instrument, but are in beta and aren't officially supported. You can view all the libraries in the contrib directory.

Configuration values

If the default configuration values don't apply for your environment, override them before running the process you instrument.

CodeEnvironment VariableDefault ValueNotes
WithServiceNameSIGNALFX_SERVICE_NAMESignalFx-TracingThe name of the service.
WithEndpointURLSIGNALFX_ENDPOINT_URLhttp://localhost:9080/v1/traceThe URL to send traces to. Send spans to a Smart Agent, OpenTelemetry Collector, or a SignalFx ingest endpoint.
WithAccessTokenSIGNALFX_ACCESS_TOKENnoneThe access token for your SignalFx organization.
WithGlobalTagSIGNALFX_SPAN_TAGSnoneComma-separated list of tags included in every reported span. For example, "key1:val1,key2:val2". Use only string values for tags.
WithRecordedValueMaxLengthSIGNALFX_RECORDED_VALUE_MAX_LENGTH1200The maximum number of characters for any Zipkin-encoded tagged or logged value. Behaviour disabled when set to -1.
-SIGNALFX_TRACE_RESPONSE_HEADER_ENABLEDtrueAdds Server-Timing header to HTTP responses for net/http and instrumentations.

Instrument a Go application

Follow these steps to instrument target libraries with provided instrumentors.

For more information about how to instrument a Go application, see the examples.

  1. Import to your go mod.

  2. Import the instrumentor for the target library you want to instrument and replace utilities with their traced equivalents.

    Find an instrumentor for each supported target library in the contrib directory. Each instrumentor has an example_test.go file that demonstrates how to instrument a target library. Don't import examples directly in your application.

  3. Enable tracing globally with tracing.Start(). This creates a tracer and registers it as the OpenTracing global tracer.

Inject trace context in HTTP requests

Link individual log entries with trace IDs and span IDs associated with corresponding events by passing metadata in HTTP reqeusts.

To inject trace context in HTTP requests, follow these steps:

  1. Replace the default HTTP multiplexer:

    import (
      httptrace ""
      "" // global tracer
      "" // helper
  2. Create the new HTTP multiplexer and attach it to your HTTP instance:

    mux := httptrace.NewServeMux()
    mux.HandleFunc("/", handler) // handler to your function
    // add all other routes
    http.ListenAndServe(":8888", mux)
  3. Use a helper for the tracer to get the span ID and trace ID from each request:

    func TraceIdFromCtx(ctx context.Context) (result string) {
      if span, ok := tracer.SpanFromContext(ctx); ok {
        result = tracer.TraceIDHex(span.Context())

    It cooperates with the global tracer instance.

Example log injection configuration

This is an example of what injecting span IDs and trace IDs can look like in your environment:

package main

import (
  httptrace ""
  "" // global tracer
  "" // helper


func TraceIdFromCtx(ctx context.Context) (result string) {
  if span, ok := tracer.SpanFromContext(ctx); ok {
    result = tracer.TraceIDHex(span.Context())

func handler(w http.ResponseWriter, r *http.Request) {
  ctx := r.Context()
  log.Print("Recevied request for ", r.URL.Path[1:], " ", TraceIdFromCtx(ctx))

func main() {
  defer tracing.Stop()
  mux.HandleFunc("/", handler)
  http.ListenAndServe(":8888", mux)


To run integration tests locally, you should set the INTEGRATION environment variable. The dependencies of the integration tests are best run via Docker. To get an idea about the versions and the set-up take a look at our CI config.

The best way to run the entire test suite is using the CircleCI CLI. Simply run circleci build in the repository root. Note that you might have to increase the resources dedicated to Docker to around 4GB.

GitHub Stars



5mos ago








8mos ago
9mos ago
1yr ago
1yr ago
No alternatives found
No tutorials found
Add a tutorial