Python Runtime Metrics
Security Monitoring is now available Security Monitoring is now available

Python Runtime Metrics

This feature is currently in private beta. Reach out to support to turn on this feature for your account.

Automatic Configuration

Runtime metrics collection can be enabled with the DD_RUNTIME_METRICS_ENABLED=true environment parameter when running with ddtrace-run:

Runtime metrics can be viewed in correlation with your Python services. See the Service page in Datadog.

Note: For the runtime UI, ddtrace >= 0.24.0 is supported.

By default, runtime metrics from your application are sent to the Datadog Agent thanks to DogStatsD over port 8125. Make sure that DogStatsD is enabled for the Agent. If you are running the Agent as a container, ensure that DD_DOGSTATSD_NON_LOCAL_TRAFFIC is set to true, and that port 8125 is open on the Agent. In Kubernetes, bind the DogstatsD port to a host port; in ECS, set the appropriate flags in your task definition.

Data Collected

The following metrics are collected by default after enabling runtime metrics:

runtime.python.cpu.time.sys
(gauge)
Number of seconds executing in the kernel
Shown as second
runtime.python.cpu.time.user
(gauge)
Number of seconds executing outside the kernel
Shown as second
runtime.python.cpu.percent
(gauge)
CPU utilization percentage
Shown as percent
runtime.python.cpu.ctx_switch.voluntary
(gauge)
Number of voluntary context switches
Shown as invocation
runtime.python.cpu.ctx_switch.involuntary
(gauge)
Number of involuntary context switches
Shown as invocation
runtime.python.gc.count.gen0
(gauge)
Number of generation 0 objects
Shown as resource
runtime.python.gc.count.gen1
(gauge)
Number of generation 1 objects
Shown as resource
runtime.python.gc.count.gen2
(gauge)
Number of generation 2 objects
Shown as resource
runtime.python.mem.rss
(gauge)
Resident set memory
Shown as byte
runtime.python.thread_count
(gauge)
Number of threads
Shown as thread

Along with displaying these metrics in your APM Service Page, Datadog provides a default Python Runtime Metrics Dashboard with the service and runtime-id tags that are applied to these metrics.

Further Reading