Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
This feature is in public beta.

Automatic configuration

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

If you are not using ddtrace-run, you can enable runtime metrics collection in code:

from ddtrace.runtime import RuntimeMetrics
RuntimeMetrics.enable()

Runtime metrics can be viewed in correlation with your Python services. See the Service Catalog 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 with 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.

Alternatively, the Agent can ingest metrics with a Unix Domain Socket (UDS) as an alternative to UDP transport. For more information, read DogStatsD over Unix Domain Socket.

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.

Further Reading