err:=profiler.Start(profiler.WithService("<SERVICE_NAME>"),profiler.WithEnv("<ENVIRONMENT>"),profiler.WithVersion("<APPLICATION_VERSION>"),profiler.WithTags("<KEY1>:<VALUE1>","<KEY2>:<VALUE2>"),profiler.WithProfileTypes(profiler.CPUProfile,profiler.HeapProfile,// The profiles below are disabled by default to keep overhead
// low, but can be enabled as needed.
// profiler.BlockProfile,
// profiler.MutexProfile,
// profiler.GoroutineProfile,
),)iferr!=nil{log.Fatal(err)}deferprofiler.Stop()
Starting Go 1.21, the Go compiler supports Profile-Guided Optimization (PGO). PGO enables additional optimizations on code identified as hot by CPU profiles of production workloads. This is compatible with Datadog Go Continuous Profiler and can be used for production builds.
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.