Ruby Runtime Metrics
Datadog の調査レポート: サーバーレスの状態 レポート: サーバーレスの状態

Ruby 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 uses the dogstatsd-ruby gem to send metrics via DogStatsD to the Agent. To collect runtime metrics, you must add this gem to your Ruby application, and make sure that DogStatsD is enabled for the Agent.

Metrics collection is disabled by default. You can enable it by setting the DD_RUNTIME_METRICS_ENABLED environment variable to true, or by setting the following configuration in your Ruby application:

# config/initializers/datadog.rb
require 'datadog/statsd'
require 'ddtrace'

Datadog.configure do |c|
  # To enable runtime metrics collection, set `true`. Defaults to `false`
  # You can also set DD_RUNTIME_METRICS_ENABLED=true to configure this.
  c.runtime_metrics_enabled = true

  # Optionally, you can configure the DogStatsD instance used for sending runtime metrics.
  # DogStatsD is automatically configured with default settings if `dogstatsd-ruby` is available.
  # You can configure with host and port of Datadog agent; defaults to 'localhost:8125'.
  c.runtime_metrics statsd: Datadog::Statsd.new
end

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

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.ruby.class_count
(gauge)
Total number of classes loaded
Shown as resource
runtime.ruby.gc.remembered_wb_unprotected_objects
(gauge)
Number of write-barrier unprotected objects in the remembered set
Shown as resource
runtime.ruby.gc.remembered_wb_unprotected_objects_limit
(gauge)
Limit on write-barrier unprotected objects allowed in the remembered set
Shown as resource
runtime.ruby.gc.oldmalloc_increase_bytes
(gauge)
Total bytes allocated to old objects
Shown as byte
runtime.ruby.gc.oldmalloc_increase_bytes_limit
(gauge)
Bytes limit that will trigger garbage collection of old objects
Shown as byte
runtime.ruby.gc.malloc_increase_bytes
(gauge)
Total bytes allocated to objects
Shown as byte
runtime.ruby.gc.malloc_increase_bytes_limit
(gauge)
Bytes limit that will trigger garbage collection of objects
Shown as byte
runtime.ruby.gc.total_allocated_objects
(gauge)
Total number of allocated objects over the lifetime of this process
Shown as resource
runtime.ruby.gc.total_freed_objects
(gauge)
Total number of freed objects over the lifetime of this process
Shown as resource
runtime.ruby.gc.total_allocated_pages
(gauge)
Total number of allocated pages over the lifetime of this process
Shown as page
runtime.ruby.gc.total_freed_pages
(gauge)
Total number of freed pages over the lifetime of this process
Shown as page
runtime.ruby.gc.heap_live_slots
(gauge)
Number of live objects slots
Shown as resource
runtime.ruby.gc.heap_final_slots
(gauge)
Number of object slots with finalizers attached to them
Shown as resource
runtime.ruby.gc.heap_marked_slots
(gauge)
Count of old objects which survived more than 3 GC cycles and number of write-barrier unprotected objects
Shown as resource
runtime.ruby.gc.heap_available_slots
(gauge)
Total number of slots in heap pages
Shown as resource
runtime.ruby.gc.heap_free_slots
(gauge)
Number of free slots in heap pages
Shown as resource
runtime.ruby.thread_count
(gauge)
Total number of threads
Shown as thread
runtime.ruby.gc.old_objects
(gauge)
Total number of old objects
Shown as resource
runtime.ruby.gc.old_objects_limit
(gauge)
Limit on number of old objects
Shown as resource

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

Further Reading