これは公開ベータ版の機能です。

自動コンフィギュレーション

ランタイムメトリクスの収集は、ddtrace-run 環境で実行している場合 DD_RUNTIME_METRICS_ENABLED=true の環境パラメーターで有効にできます。

ddtrace-run を使用していない場合は、コードでランタイムメトリクスの収集を有効にできます。

from ddtrace.runtime import RuntimeMetrics
RuntimeMetrics.enable()

ランタイムメトリクスは、Python サービスと相関して表示できます。Datadog のサービス詳細画面を参照してください。

: ランタイム UI では、ddtrace >= 0.24.0 がサポートされています。

初期設定では、アプリケーションからのランタイムメトリクスは DogStatsD のポート 8125 から Datadog Agent に送信されます。DogStatsD が Agent に対して有効になっていることを確認してください。 Agent をコンテナとして実行している場合は、DD_DOGSTATSD_NON_LOCAL_TRAFFICtrue に設定されていること、また Agent 上でポート 8125 が開いていることを確認してください。 Kubernetes では、DogstatsD ポートをホストポートにバインドし、ECS ではタスク定義で適切なフラグを設定します。

収集データ

以下のメトリクスはランタイムメトリクスを有効にした後、デフォルトで収集されます。

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

APM サービス詳細画面にこれらのメトリクスを表示するだけでなく、Datadog はデフォルトの Python ランタイムメトリクスダッシュボードを提供します。

その他の参考資料