Join us at the Dash conference! July 16-17, NYC

Tracing Go Applications

Installation and Getting Started

For configuration instructions and details about using the API, see the Datadog API documentation. For manual instrumentation, use the integrations section below for Go libraries and frameworks supporting automatic instrumentation.

For a description of the terminology used in APM, see the Getting started with APM section. For details about contributing, check the official repository

Consult the migration document if you need to migrate from an older version of the tracer (e.g. v<0.6.x) to the newest version.


First install and configure the Datadog Agent. See the additional documentation for tracing Docker applications or Kubernetes applications.

Next, install the Go tracer from its canonical import path:

go get

You are now ready to import the tracer and start instrumenting your code.

Automatic Instrumentation

Datadog has a series of pluggable packages which provide out-of-the-box support for instrumenting a series of libraries and frameworks. Find the list of supported integrations below.


To begin tracing your Go applications, your environment must first meet the following requirements:

  • Runing the Datadog Agent >= 5.21.1.
  • Using Go 1.9+


Framework Compatibility

Integrate the Go tracer with the following list of web frameworks using one of the following helper packages.

Framework Support Type GoDoc Datadog Documentation
Gin Fully Supported
Gorilla Mux Fully Supported
gRPC Fully Supported
gRPC v1.2 Fully Supported

Library Compatibility

The Go tracer includes support for the following data stores and libraries.

Library Support Type Examples and Documentation
AWS SDK Fully Supported
Elasticsearch Fully Supported
Cassandra Fully Supported
GraphQL Fully Supported
HTTP Fully Supported
HTTP router Fully Supported
Redis (go-redis) Fully Supported
Redis (redigo) Fully Supported
SQL Fully Supported
SQLx Fully Supported
MongoDB v0.2.0 only
BuntDB Fully Supported
LevelDB Fully Supported
miekg/dns Fully Supported
Kafka (confluent) Fully Supported
Kafka (sarama) Fully Supported
Google API Fully Supported
go-restful Fully Supported

Note: The integrations documentation provides a detailed overview of the supported packages and their APIs, along with usage examples.

Packages must be imported, i.e.:

import "<package_dir>/<package_name>"


The tracer is configured with options parameters when the Start function is called. An example for generating a trace using the HTTP library:

package main

import (
    httptrace ""

func sayHello(w http.ResponseWriter, r *http.Request) {
  message := r.URL.Path
  message = strings.TrimPrefix(message, "/")
  message = "Hello " + message

func main() {
    // start the tracer with zero or more options
    defer tracer.Stop()

    mux := httptrace.NewServeMux() // init the http tracer
    mux.HandleFunc("/", sayHello) // use the tracer to handle the urls

    err := http.ListenAndServe(":9090", mux) // set listen port
    if err != nil {
        log.Fatal("ListenAndServe: ", err)

For more tracer settings, see available options in the configuration documentation.

Change Agent Hostname

Configure your application level tracers to submit traces to a custom Agent hostname:

The Go Tracing Module automatically looks for and initializes with the ENV variables DD_AGENT_HOST and DD_TRACE_AGENT_PORT

package main

import (


func main() {
    addr := net.JoinHostPort(
    defer tracer.Stop()

Further Reading