Getting Started with the Agent
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:
# Load the Datadog API module. require 'rubygems' require 'dogapi' api_key = "abcdef123456" application_key = "fedcba654321" # Submitting events does not require the application key. dog = Dogapi::Client.new(api_key, application_key) # Send a new event. dog.emit_event(Dogapi::Event.new('Testing done, FTW'), :host => "my_host")
Start instrumenting your code using the DogStatsD client:
# Load the dogstats module. require 'datadog/statsd' # Create a stats instance. statsd = Datadog::Statsd.new('localhost', 8125) # Increment a counter. statsd.increment('page.views') # Record a gauge 50% of the time. 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!