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 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 'datadog' # Use 'ddtrace' if you're using v1.x

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 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.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
runtime.ruby.global_constant_state
(gauge)
Global constant cache generation
Shown as generation
runtime.ruby.global_method_state
(gauge)
Global method cache generation
Shown as generation
runtime.ruby.constant_cache_invalidations
(gauge)
Constant cache invalidations
Shown as resource
runtime.ruby.constant_cache_misses
(gauge)
Constant cache misses
Shown as resource

Along with displaying these metrics in your APM Service Page, Datadog provides a default Ruby Runtime Dashboard.

Further Reading

PREVIEWING: alai97/reorganize-some-sections-in-dora-metrics