The Atatus Go Profiler helps troubleshoot Go application issues and detect performance bottlenecks before they affect users. It continuously captures function call stacks and runtime metrics in production to identify slow functions, excessive CPU usage, goroutine leaks, high memory allocations, and inefficient resource usage.

Installation & Setup

Step 1: Install the Go Module

Install the Atatus profiler module and import it in your application

copy
icon/buttons/copy
go get go.atatus.com/agent/profiler
copy
icon/buttons/copy
import (
    "time"
    "go.atatus.com/agent/profiler"
)

Step 2: Initialize the Profiler

Add the following code at the very top of your main() function:

copy
icon/buttons/copy
func main() {
    // Use this at the top of main()
    err := profiler.Start(
        profiler.WithService("Your-Service-Name"),
        profiler.WithEnv("prod"),
        profiler.WithVersion("1.0.0"),
        profiler.WithAPIKey("lic_apm_*********"),
        profiler.WithLogLevel("none"),
        profiler.WithPeriod(10 * time.Second),
        profiler.WithUploadTimeout(10 * time.Second),
        profiler.WithProfileTypes(
            profiler.CPUProfile,
            profiler.GoroutineProfile,
            profiler.BlockProfile,
            profiler.HeapProfile,
            profiler.MetricsProfile,
            profiler.MutexProfile,
        ),
    )
    if err != nil {
        panic(err)
    }
    defer profiler.Stop()

    // Your application code starts here
}

Step 3: Configure the API Key and Start Your Application

Provide your Atatus API key either through an environment variable or directly in your application configuration, then start your Go application.

Option 1: Using an Environment Variable

copy
icon/buttons/copy
export ATATUS_API_KEY="your License key"
# Restart your Go application

Option 2: Using Application Configuration

// Add this to your profiler.Start() call
profiler.WithAPIKey("your License key"),

Supported Profile Types

Profile Type Constant
CPU profiler.CPUProfile
Goroutine profiler.GoroutineProfile
Block (Delay) profiler.BlockProfile
Heap (Memory) profiler.HeapProfile
Metrics profiler.MetricsProfile
Mutex (Lock) profiler.MutexProfile