Profiler is shipped within the following tracing libraries. Select your language below to learn how to enable profiler for your application:
To get notified when a private beta is available for the Node, Ruby, PHP, or .NET Profiler, sign up here.
The Datadog Profiler requires JDK Flight Recorder. The Datadog Profiler library is supported in OpenJDK 11+, Oracle Java 11+, OpenJDK 8 (version 8u262+) and Zulu Java 8+ (minor version 1.8.0_212+). All JVM-based languages, such as Scala, Groovy, Kotlin, and Clojure are supported. To begin profiling applications:
If you are already using Datadog, upgrade your agent to version 7.20.2+ or 6.20.2+. If you don’t have APM enabled to set up your application to send data to Datadog, in your Agent, set the DD_APM_ENABLED
environment variable to true
and listening to the port 8126/TCP
.
Download dd-java-agent.jar
, which contains the Java Agent class files:
wget -O dd-java-agent.jar 'https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.datadoghq&a=dd-java-agent&v=LATEST'
Note: Profiler is available in the dd-java-agent.jar
library in versions 0.55+.
Set -Ddd.profiling.enabled
flag or DD_PROFILING_ENABLED
environment variable to true
. Update to your service invocation should look like:
java -javaagent:dd-java-agent.jar -Ddd.profiling.enabled=true -XX:FlightRecorderOptions=stackdepth=256 -jar <YOUR_SERVICE>.jar <YOUR_SERVICE_FLAGS>
After a minute or two, visualize your profiles on the Datadog APM > Profiling page.
Note:
The -javaagent
argument needs to be before -jar
, adding it as a JVM option rather than an application argument. For more information, see the Oracle documentation:
# Good:
java -javaagent:dd-java-agent.jar ... -jar my-service.jar -more-flags
# Bad:
java -jar my-service.jar -javaagent:dd-java-agent.jar ...
We strongly recommend that you specify the service
and version
as this gives you the ability to slice and dice your profiles across these dimensions. Use environment variables to set the parameters:
Environment variable | Type | Description |
---|---|---|
DD_PROFILING_ENABLED | Boolean | Alternate for -Ddd.profiling.enabled argument. Set to true to enable profiler. |
DD_SERVICE | String | Your service name, for example, web-backend . |
DD_ENV | String | Your environment name, for example: production . |
DD_VERSION | String | The version of your service. |
DD_TAGS | String | Tags to apply to an uploaded profile. Must be a list of <key>:<value> separated by commas such as: layer:api, team:intake . |
The Datadog Profiler requires Python 2.7+. Memory profiling is available on Python 3.5+. To begin profiling applications:
If you are already using Datadog, upgrade your agent to version 7.20.2+ or 6.20.2+.
Install ddtrace
which contains both tracing and profiler:
pip install ddtrace
Note: Profiler is available in the ddtrace
library for versions 0.36+.
To automatically profile your code, set DD_PROFILING_ENABLED
environment variable to true
when you use ddtrace-run
:
DD_PROFILING_ENABLED=true ddtrace-run python app.py
Note: DD_PROFILING_ENABLED
is only supported in dd-trace
version 0.40+. Use the alternate method if you are running an older version of dd-trace
.
Alternate method
If you prefer to instrument the profiler through code, import ddtrace.profile.auto
. After import, the Profiler starts:
import ddtrace.profiling.auto
After a minute or two, visualize your profiles on the Datadog APM > Profiler page.
service
or version
as it provides the ability to slice and dice your profiles across these dimensions, enhancing your overall product experience. Use environment variables to set the parameters:Environment variable | Type | Description |
---|---|---|
DD_PROFILING_ENABLED | Boolean | Set to true to enable profiler. Supported from tracer version 0.40+. |
DD_SERVICE | String | The Datadog service name. |
DD_ENV | String | The Datadog environment name, for example, production . |
DD_VERSION | String | The version of your application. |
DD_TAGS | String | Tags to apply to an uploaded profile. Must be a list of <key>:<value> separated by commas such as: layer:api,team:intake . |
When your process forks using os.fork
, the profiler is stopped in the child process.
For Python 3.7+ on POSIX platforms, a new profiler is started if you enabled the profiler via ddtrace-run
or ddtrace.profiling.auto
.
If you manually create a Profiler()
, use Python < 3.6, or run on a non-POSIX platform, manually restart the profiler in your child with:
ddtrace.profiling.auto.start_profiler()
If you want to manually control the lifecycle of the profiler, use the ddtrace.profiling.profiler.Profiler
object:
from ddtrace.profiling import Profiler
prof = Profiler()
prof.start()
# At shutdown
prof.stop()
The Datadog Profiler requires Go 1.12+. To begin profiling applications:
If you are already using Datadog, upgrade your agent to version 7.20.2+ or 6.20.2+.
Get dd-trace-go
using the command:
go get gopkg.in/DataDog/dd-trace-go.v1
Note: Profiler is available in the dd-trace-go
library for versions 1.23.0+.
Import the profiler at the start of your application:
import "gopkg.in/DataDog/dd-trace-go.v1/profiler"
Add the following snippet to start the profiler:
err := profiler.Start(
profiler.WithService("<SERVICE_NAME>"),
profiler.WithEnv("<ENVIRONMENT>"),
profiler.WithVersion("<APPLICATION_VERSION>"),
profiler.WithTags("<KEY1>:<VALUE1>,<KEY2>:<VALUE2>"),
)
if err != nil {
log.Fatal(err)
}
defer profiler.Stop()
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:
Function | Type | Description |
---|---|---|
WithService | String | The Datadog service name, for example my-web-app . |
WithEnv | String | The Datadog environment name, for example, production . |
WithVersion | String | The version of your application. |
WithTags | String | The tags to apply to an uploaded profile. Must be a list of in the format <KEY1>:<VALUE1>,<KEY2>:<VALUE2> . |
Environment variable | Type | Description |
---|---|---|
DD_SERVICE | String | The Datadog service name. |
DD_ENV | String | The Datadog environment name, for example, production . |
DD_VERSION | String | The version of your application. |
DD_TAGS | String | Tags to apply to an uploaded profile. Must be a list of <key>:<value> separated by commas such as: layer:api,team:intake . |
Additional helpful documentation, links, and articles: