The Ruby integration allows you to monitor custom metrics by simply adding a few lines of code to your Ruby application. For example, you can have a metric that returns the number of page views or the time of any function call. For additional information about the Ruby integration, please refer to the guide on submitting metrics. For advanced usage, please refer to the documentation in the repositories listed below. You can also review the API docs for details on how to use the API with Ruby.
Datadog offers two libraries to assist you with the implementation of Ruby application metrics:
To install the Ruby client for the Datadog API:
gem install dogapi
To install the dogstatsd-ruby client for DogStatsD:
gem install dogstatsd-ruby
Start instrumenting your code using the Datadog API: ```ruby
require ‘rubygems’ require ‘dogapi’
api_key = “abcdef123456” application_key = “fedcba654321”
dog = Dogapi::Client.new(api_key, application_key)
dog.emit_event(Dogapi::Event.new(‘Testing done, FTW’), :host => “my_host”)
Start instrumenting your code using the DogStatsD client: ```ruby require 'datadog/statsd' statsd = Datadog::Statsd.new('localhost', 8125) statsd.increment('page.views') statsd.gauge('users.online', 123, :sample_rate=>0.5)
There is nothing that you need to do in the Datadog application to configure Ruby.
Go to the Metrics explorer page and see that it just works!
Need help? Contact Datadog Support.
Learn more about infrastructure monitoring and all our integrations on our blog