dogapi 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -1
- data/lib/dogapi/v1/event.rb +2 -1
- data/tests/test_base.rb +6 -10
- data/tests/test_client.rb +17 -8
- data/tests/test_comments.rb +4 -2
- data/tests/test_dashes.rb +3 -2
- data/tests/test_search.rb +3 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
= Ruby client for Datadog API v1.
|
1
|
+
= Ruby client for Datadog API v1.4.0
|
2
2
|
|
3
3
|
The Ruby client is a library suitable for inclusion in existing Ruby projects or for development of standalone scripts. It provides an abstraction on top of Datadog's raw HTTP interface for reporting events and metrics.
|
4
4
|
|
5
5
|
= What's new?
|
6
6
|
|
7
|
+
== v1.4.0
|
8
|
+
|
9
|
+
* Added support for the dashboard, search and comment API endpoints.
|
10
|
+
|
7
11
|
== v1.3.6
|
8
12
|
|
9
13
|
* Small fix for capistrano integration
|
data/lib/dogapi/v1/event.rb
CHANGED
@@ -78,7 +78,8 @@ module Dogapi
|
|
78
78
|
params[:sources] = options[:sources]
|
79
79
|
end
|
80
80
|
if options[:tags]
|
81
|
-
|
81
|
+
tags = options[:tags]
|
82
|
+
params[:tags] = tags.kind_of?(Array) ? tags.join(",") : tags
|
82
83
|
end
|
83
84
|
|
84
85
|
request(Net::HTTP::Get, '/api/' + API_VERSION + '/events', params, nil, false)
|
data/tests/test_base.rb
CHANGED
@@ -2,16 +2,7 @@ require 'test/unit'
|
|
2
2
|
require 'dogapi'
|
3
3
|
require 'time'
|
4
4
|
|
5
|
-
|
6
|
-
module Kernel
|
7
|
-
def require_relative(path)
|
8
|
-
require File.join(File.dirname(caller[0]), path.to_str)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
class TestBase < Test::Unit::TestCase
|
5
|
+
module TestBase
|
15
6
|
|
16
7
|
def config_client_test_env
|
17
8
|
@api_key = ENV['DATADOG_API_KEY']
|
@@ -25,5 +16,10 @@ class TestBase < Test::Unit::TestCase
|
|
25
16
|
def setup
|
26
17
|
config_client_test_env()
|
27
18
|
end
|
19
|
+
|
20
|
+
def random
|
21
|
+
Kernel.rand 100000
|
22
|
+
end
|
23
|
+
|
28
24
|
end
|
29
25
|
|
data/tests/test_client.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'dogapi'
|
2
2
|
require 'time'
|
3
|
-
|
3
|
+
require 'test_base.rb'
|
4
4
|
|
5
|
-
class TestClient <
|
5
|
+
class TestClient < Test::Unit::TestCase
|
6
|
+
include TestBase
|
6
7
|
|
7
8
|
def test_tags
|
8
|
-
hostname =
|
9
|
+
hostname = "test.tag.host.#{random}"
|
9
10
|
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
11
|
|
11
12
|
# post a metric to make sure the test host context exists
|
@@ -14,6 +15,8 @@ class TestClient < TestBase
|
|
14
15
|
# Disable this call until we fix the timeouts
|
15
16
|
# dog.all_tags()
|
16
17
|
|
18
|
+
sleep 3
|
19
|
+
|
17
20
|
dog.detach_tags(hostname)
|
18
21
|
code, resp = dog.host_tags(hostname)
|
19
22
|
assert resp["tags"].size == 0
|
@@ -47,6 +50,8 @@ class TestClient < TestBase
|
|
47
50
|
def test_events
|
48
51
|
now = Time.now()
|
49
52
|
|
53
|
+
tags = ["test-run:#{random}"]
|
54
|
+
|
50
55
|
now_ts = now
|
51
56
|
now_title = 'dogapi-rb end test title ' + now_ts.to_i.to_s
|
52
57
|
now_message = 'test message ' + now_ts.to_i.to_s
|
@@ -58,8 +63,11 @@ class TestClient < TestBase
|
|
58
63
|
dog = Dogapi::Client.new(@api_key, @app_key)
|
59
64
|
dog_r = Dogapi::Client.new(@api_key)
|
60
65
|
|
61
|
-
|
62
|
-
|
66
|
+
# Tag the events with the build number, because traivs
|
67
|
+
e1 = Dogapi::Event.new(now_message, :msg_title =>now_title, :date_happened => now_ts, :tags => tags)
|
68
|
+
e2 = Dogapi::Event.new(before_message, :msg_title =>before_title,
|
69
|
+
:date_happened => before_ts, :tags => tags)
|
70
|
+
|
63
71
|
code, resp = dog_r.emit_event(e1)
|
64
72
|
now_event_id = resp["event"]["id"]
|
65
73
|
code, resp = dog_r.emit_event(e2)
|
@@ -67,11 +75,12 @@ class TestClient < TestBase
|
|
67
75
|
|
68
76
|
sleep 3
|
69
77
|
|
70
|
-
code, resp = dog.stream(before_ts, now_ts + 1)
|
78
|
+
code, resp = dog.stream(before_ts, now_ts + 1, :tags => tags)
|
71
79
|
stream = resp["events"]
|
72
80
|
|
73
|
-
|
74
|
-
|
81
|
+
assert_equal 2, stream.length()
|
82
|
+
assert_equal stream.last['title'], before_title
|
83
|
+
assert_equal stream.first['title'], now_title
|
75
84
|
|
76
85
|
code, resp = dog.get_event(now_event_id)
|
77
86
|
now_event = resp['event']
|
data/tests/test_comments.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'dogapi'
|
2
2
|
require 'time'
|
3
|
-
|
3
|
+
require 'test_base.rb'
|
4
|
+
|
5
|
+
class TestComments < Test::Unit::TestCase
|
6
|
+
include TestBase
|
4
7
|
|
5
|
-
class TestComments < TestBase
|
6
8
|
|
7
9
|
def test_comments
|
8
10
|
dog = Dogapi::Client.new(@api_key, @app_key)
|
data/tests/test_dashes.rb
CHANGED
data/tests/test_search.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|