dogapi 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dogapi/facade.rb +10 -3
- data/lib/dogapi/v1/metric.rb +13 -2
- data/tests/test_client.rb +10 -0
- metadata +7 -12
data/lib/dogapi/facade.rb
CHANGED
@@ -42,14 +42,17 @@ module Dogapi
|
|
42
42
|
# :timestamp => Ruby stdlib Time
|
43
43
|
# :host => String
|
44
44
|
# :device => String
|
45
|
+
# :options => Map
|
46
|
+
#
|
47
|
+
# options[:type] = "counter" to specify a counter metric
|
48
|
+
# options[:tags] = ["tag1", "tag2"] to tag the point
|
45
49
|
def emit_point(metric, value, options={})
|
46
50
|
defaults = {:timestamp => Time.now, :host => nil, :device => nil}
|
47
51
|
options = defaults.merge(options)
|
48
52
|
|
49
53
|
self.emit_points(metric,
|
50
54
|
[[options[:timestamp], value]],
|
51
|
-
|
52
|
-
:device => options[:device])
|
55
|
+
options)
|
53
56
|
end
|
54
57
|
|
55
58
|
# Record a set of points of metric data
|
@@ -59,6 +62,10 @@ module Dogapi
|
|
59
62
|
# Optional arguments:
|
60
63
|
# :host => String
|
61
64
|
# :device => String
|
65
|
+
# :options => Map
|
66
|
+
#
|
67
|
+
# options[:type] = "counter" to specify a counter metric
|
68
|
+
# options[:tags] = ["tag1", "tag2"] to tag the point
|
62
69
|
def emit_points(metric, points, options={})
|
63
70
|
defaults = {:host => nil, :device => nil}
|
64
71
|
options = defaults.merge(options)
|
@@ -71,7 +78,7 @@ module Dogapi
|
|
71
78
|
p[1] = p[1].to_f # TODO: stupid to_f will never raise an exception
|
72
79
|
end
|
73
80
|
|
74
|
-
@metric_svc.submit(metric, points, scope)
|
81
|
+
@metric_svc.submit(metric, points, scope, options)
|
75
82
|
end
|
76
83
|
|
77
84
|
#
|
data/lib/dogapi/v1/metric.rb
CHANGED
@@ -9,22 +9,33 @@ module Dogapi
|
|
9
9
|
API_VERSION = "v1"
|
10
10
|
|
11
11
|
# Records an Event with no duration
|
12
|
-
def submit(metric, points, scope)
|
12
|
+
def submit(metric, points, scope, options={})
|
13
13
|
params = {
|
14
14
|
:api_key => @api_key
|
15
15
|
}
|
16
|
+
typ = options[:type] || "gauge"
|
17
|
+
|
18
|
+
if typ != "gauge" && typ == "counter"
|
19
|
+
raise ArgumentError, "metric type must be gauge or counter"
|
20
|
+
end
|
16
21
|
|
17
22
|
body = { :series => [
|
18
23
|
{
|
19
24
|
:metric => metric,
|
20
25
|
:points => points,
|
21
|
-
:type =>
|
26
|
+
:type => typ,
|
22
27
|
:host => scope.host,
|
23
28
|
:device => scope.device
|
24
29
|
}
|
25
30
|
]
|
26
31
|
}
|
27
32
|
|
33
|
+
|
34
|
+
# Add tags if there are any
|
35
|
+
if not options[:tags].nil?
|
36
|
+
body[:series][0][:tags] = options[:tags]
|
37
|
+
end
|
38
|
+
|
28
39
|
request(Net::HTTP::Post, '/api/' + API_VERSION + '/series', params, body, true)
|
29
40
|
end
|
30
41
|
end
|
data/tests/test_client.rb
CHANGED
@@ -90,6 +90,14 @@ class TestClient < Test::Unit::TestCase
|
|
90
90
|
|
91
91
|
assert now_event['text'] == now_message
|
92
92
|
assert before_event['text'] == before_message
|
93
|
+
|
94
|
+
# Testing priorities
|
95
|
+
code, resp = dog_r.emit_event(Dogapi::Event.new(now_message, :msg_title =>now_title, :date_happened => now_ts, :priority => "low"))
|
96
|
+
low_event_id = resp["event"]["id"]
|
97
|
+
code, resp = dog.get_event(low_event_id)
|
98
|
+
low_event = resp['event']
|
99
|
+
puts low_event
|
100
|
+
assert low_event['priority'] == "low"
|
93
101
|
end
|
94
102
|
|
95
103
|
def test_metrics
|
@@ -99,6 +107,8 @@ class TestClient < Test::Unit::TestCase
|
|
99
107
|
|
100
108
|
dog_r.emit_point('test.metric.metric', 10, :host => 'test.metric.host')
|
101
109
|
dog_r.emit_points('test.metric.metric', [[Time.now-5*60, 0]], :host => 'test.metric.host')
|
110
|
+
|
111
|
+
dog_r.emit_points('test.metric.metric', [[Time.now-60, 20], [Time.now-30, 10], [Time.now, 5]], :tags => ["test:tag.1", "test:tag2"])
|
102
112
|
end
|
103
113
|
|
104
114
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
8
|
+
- 1
|
9
|
+
version: 1.3.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Datadog, Inc.
|
@@ -15,17 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2012-
|
17
|
+
date: 2012-05-24 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
24
|
requirements:
|
26
25
|
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 1
|
29
27
|
segments:
|
30
28
|
- 1
|
31
29
|
- 5
|
@@ -55,6 +53,7 @@ files:
|
|
55
53
|
- lib/dogapi.rb
|
56
54
|
- tests/test_client.rb
|
57
55
|
- README.rdoc
|
56
|
+
has_rdoc: true
|
58
57
|
homepage: http://datadoghq.com/
|
59
58
|
licenses:
|
60
59
|
- BSD
|
@@ -69,27 +68,23 @@ rdoc_options:
|
|
69
68
|
require_paths:
|
70
69
|
- lib
|
71
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
71
|
requirements:
|
74
72
|
- - ">="
|
75
73
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 3
|
77
74
|
segments:
|
78
75
|
- 0
|
79
76
|
version: "0"
|
80
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
78
|
requirements:
|
83
79
|
- - ">="
|
84
80
|
- !ruby/object:Gem::Version
|
85
|
-
hash: 3
|
86
81
|
segments:
|
87
82
|
- 0
|
88
83
|
version: "0"
|
89
84
|
requirements: []
|
90
85
|
|
91
86
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.3.6
|
93
88
|
signing_key:
|
94
89
|
specification_version: 3
|
95
90
|
summary: Ruby bindings for Datadog's API
|