Enabling the Go Profiler

Enabling the Go Profiler

The profiler is shipped within Datadog tracing libraries. If you are already using APM to collect traces for your application, you can skip installing the library and go directly to enabling the profiler.


The Datadog Profiler requires Go 1.12+.


To begin profiling applications:

  1. If you are already using Datadog, upgrade your agent to version 7.20.2+ or 6.20.2+.

  2. Get dd-trace-go using the command:

    go get gopkg.in/DataDog/dd-trace-go.v1/profiler

    Note: Profiler is available in the dd-trace-go library for versions 1.23.0+.

  3. Import the profiler at the start of your application:

    import "gopkg.in/DataDog/dd-trace-go.v1/profiler"
  4. Add the following snippet to start the profiler:

    err := profiler.Start(
          // The profiles below are disabled by default to keep overhead
          // low, but can be enabled as needed.
          // profiler.BlockProfile,
          // profiler.MutexProfile,
          // profiler.GoroutineProfile,
    if err != nil {
    defer profiler.Stop()
  5. After a minute or two, visualize your profiles in the Datadog APM > Profiler page.

Note: By default only the CPU and Heap profile are enabled. Use profiler.WithProfileTypes to enable additional profile types.


You can set profiler parameters in code with these functions:

WithServiceStringThe Datadog service name, for example my-web-app.
WithEnvStringThe Datadog environment name, for example, production.
WithVersionStringThe version of your application.
WithTagsStringThe tags to apply to an uploaded profile. Must be a list of in the format <KEY1>:<VALUE1>,<KEY2>:<VALUE2>.

Alternatively you can set profiler configuration using environment variables:

Environment variableTypeDescription
DD_SERVICEStringThe Datadog service name.
DD_ENVStringThe Datadog environment name, for example, production.
DD_VERSIONStringThe version of your application.
DD_TAGSStringTags to apply to an uploaded profile. Must be a list of <key>:<value> separated by commas such as: layer:api,team:intake.

Not sure what to do next?

The Getting Started with Profiler guide takes a sample service with a performance problem and shows you how to use Continuous Profiler to understand and fix the problem.

Further Reading