if ENV['DATADOG_RAILS_APM']
  Datadog.configure do |c|
    c.use :rails, service_name: 'rails'
    c.use :delayed_job, service_name: 'delayed_job'
    c.use :dalli, service_name: 'memcached'
    c.analytics_enabled = true
  end
end

if ENV['DATADOG_RAILS_APM']
  Datadog.configure do |c|
    c.use :rails, service_name: 'rails'
    c.use :delayed_job, service_name: 'delayed_job'
    c.use :dalli, service_name: 'memcached'
    c.analytics_enabled = true
    c.runtime_metrics_enabled = true
  end
end

Enable Ruby Runtime Metrics in Datadog
Enable Ruby Runtime Metrics in Datadog

This automatically collects a bunch of Ruby's GC-related metrics that
will come in handy while we tune the Unicorn workers. Some of theres
are:

* runtime.ruby.class_count
* runtime.ruby.gc.malloc_increase_bytes
* runtime.ruby.gc.total_allocated_objects
* runtime.ruby.gc.total_freed_objects
* runtime.ruby.gc.heap_marked_slots
* runtime.ruby.gc.heap_available_slots
* runtime.ruby.gc.heap_free_slots
* runtime.ruby.thread_count

Check https://docs.datadoghq.com/tracing/runtime_metrics/ruby/#data-collected for the complete list.

The cool thing is that

> Runtime metrics can be viewed in correlation with your Ruby services
