Skip to content

Instantly share code, notes, and snippets.

@alq666
Created September 13, 2012 21:55
Show Gist options
  • Save alq666/3717991 to your computer and use it in GitHub Desktop.
Save alq666/3717991 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'dogapi'
# Create a simple client
# The host is optional here, it's a shortcut to tie event and metrics to a given host
#
# You typically want to do:
# Dogapi::Client.new(your_actual_api_key_as_a_string, ...)
# We are using ENV to let you experiment via an environment variable.
dog = Dogapi::Client.new(ENV['DATADOG_KEY'])
# Emit a list of points in one go as a list of (timestamp, value)
# here we pretend to send a point a minute for the past hour
now = Time.now
points = (0...60).map do |i|
i = 60 - i
t = now - (i*60)
[t, Math.cos(i) + 1.0]
end
# And emit the data in one call
x = Time.now
dog.emit_points('test.api.test_metric', points)
puts Time.now - x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment