DataDog/dd-trace-go

Failed to configure Datadog Profiler locally

nuxzero opened this issue · 1 comments

I'he tried to configure the Datadog Profiler in my application locally. Somehow I got the below error and I can see traces from my local but I cannot see profiling data from the trace's code hotspots and profile tab. I'm not really sure if I missed any configuration. Could you guide me how to set up Datadog Profiler please?

Configuration

err := profiler.Start(
	profiler.WithService(os.Getenv("DD_SERVICE")),
	profiler.WithEnv(os.Getenv("DD_ENV")),
	profiler.WithVersion(os.Getenv("DD_VERSION")),
	profiler.CPUDuration(60*time.Second),
	profiler.WithPeriod(60*time.Second),
	profiler.WithProfileTypes(
		profiler.CPUProfile,
		profiler.HeapProfile,
	),
)
if err != nil {
	fmt.Println("Failed to start profiler: ", err)
}
defer profiler.Stop()

Profile env

DD_PROFILING_EXECUTION_TRACE_ENABLED=true
DD_PROFILING_EXECUTION_TRACE_PERIOD=15m

Error logs

2024/06/20 15:05:19 Datadog Tracer v1.65.0 DEBUG: Sending payload: size: 1322 traces: 1
2024/06/20 15:05:19 Datadog Tracer v1.65.0 DEBUG: sent traces after 1 attempts
2024/06/20 15:06:09 Datadog Tracer v1.65.0 ERROR: Error getting metrics profile: period between metrics collection is too small min=1s observed=46.019ms; skipping. (occurred: 20 Jun 24 15:05 +07)

I ran Datadog Agent locally with Docker.

docker run --name dd-agent \
-p 8126:8126 \
-p 8127:8125/udp \
-e DD_API_KEY=$DATADOG_API_KEY \
-e DD_SITE=$DATADOG_SITE \
-e DD_ENV=development \
-e DD_APM_ENABLED=true \
-v /opt/datadog/apm:/opt/datadog/apm \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-v /var/lib/docker/containers:/var/lib/docker/containers:ro \
gcr.io/datadoghq/agent:7

Go version 1.20
dd-trace-go version 1.65.0

In my case, I have the custom interface and the config was located in the start function. So, I moved the profiler.Stop() to the stop function instead. And it's worked.