Created
September 13, 2012 21:55
-
-
Save alq666/3717991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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