dogapi 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,8 @@ module Dogapi
12
12
  :msg_text,
13
13
  :priority,
14
14
  :parent,
15
- :tags
15
+ :tags,
16
+ :aggregation_key
16
17
 
17
18
  # Optional arguments:
18
19
  # :date_happened => time in seconds since the epoch (defaults to now)
@@ -24,13 +25,15 @@ module Dogapi
24
25
  # :alert_type => 'success', 'error'
25
26
  # :event_type => String
26
27
  # :source_type_name => String
28
+ # :aggregation_key => String
27
29
  def initialize(msg_text, options={})
28
30
  defaults = {
29
31
  :date_happened => Time.now.to_i,
30
32
  :msg_title => '',
31
33
  :priority => "normal",
32
34
  :parent => nil,
33
- :tags => []
35
+ :tags => [],
36
+ :aggregation_key => nil
34
37
  }
35
38
  options = defaults.merge(options)
36
39
 
@@ -40,7 +43,7 @@ module Dogapi
40
43
  @priority = options[:priority]
41
44
  @parent = options[:parent]
42
45
  @tags = options[:tags]
43
- @event_object = options[:event_object]
46
+ @aggregation_key = options[:event_object] || options[:aggregation_key]
44
47
  @alert_type = options[:alert_type]
45
48
  @event_type = options[:event_type]
46
49
  @source_type_name = options[:source_type_name]
@@ -20,9 +20,10 @@ module Dogapi
20
20
  :text => event.msg_text,
21
21
  :date_happened => event.date_happened.to_i,
22
22
  :host => scope.host,
23
- :device => scope.device
23
+ :device => scope.device,
24
+ :aggregation_key => event.aggregation_key.to_s
24
25
  })
25
-
26
+
26
27
  request(Net::HTTP::Post, '/api/v1/events', params, body, true)
27
28
  end
28
29
 
@@ -61,20 +61,23 @@ class TestClient < Test::Unit::TestCase
61
61
  now = Time.now()
62
62
 
63
63
  now_ts = now
64
- now_title = 'end test title ' + now_ts.to_i.to_s
64
+ now_title = 'dogapi-rb end test title ' + now_ts.to_i.to_s
65
65
  now_message = 'test message ' + now_ts.to_i.to_s
66
66
 
67
67
  before_ts = (now - 5*60)
68
- before_title = 'start test title ' + before_ts.to_i.to_s
68
+ before_title = 'dogapi-rb start test title ' + before_ts.to_i.to_s
69
69
  before_message = 'test message ' + before_ts.to_i.to_s
70
70
 
71
71
  dog = Dogapi::Client.new(@api_key, @app_key)
72
72
  dog_r = Dogapi::Client.new(@api_key)
73
73
 
74
- code, resp = dog_r.emit_event(Dogapi::Event.new(now_message, :msg_title =>now_title, :date_happened => now_ts))
74
+ e1 = Dogapi::Event.new(now_message, :msg_title =>now_title, :date_happened => now_ts)
75
+ e2 = Dogapi::Event.new(before_message, :msg_title =>before_title, :date_happened => before_ts)
76
+ code, resp = dog_r.emit_event(e1)
75
77
  now_event_id = resp["event"]["id"]
76
- code, resp = dog_r.emit_event(Dogapi::Event.new(before_message, :msg_title =>before_title, :date_happened => before_ts))
78
+ code, resp = dog_r.emit_event(e2)
77
79
  before_event_id = resp["event"]["id"]
80
+
78
81
  sleep 3
79
82
 
80
83
  code, resp = dog.stream(before_ts, now_ts + 1)
@@ -97,7 +100,23 @@ class TestClient < Test::Unit::TestCase
97
100
  code, resp = dog.get_event(low_event_id)
98
101
  low_event = resp['event']
99
102
  puts low_event
100
- assert low_event['priority'] == "low"
103
+ assert low_event['priority'] == "low"
104
+
105
+ # Testing aggregates
106
+ agg_ts = Time.now()
107
+ code, resp = dog_r.emit_event(Dogapi::Event.new("Testing Aggregation (first)", :aggregation_key => now_ts.to_i))
108
+ first = resp["event"]["id"]
109
+ code, resp = dog_r.emit_event(Dogapi::Event.new("Testing Aggregation (second)", :aggregation_key => now_ts.to_i))
110
+ second = resp["event"]["id"]
111
+
112
+ sleep 3
113
+
114
+ code, resp = dog.get_event(first)
115
+ agg1 = resp["event"]
116
+ code, resp = dog.get_event(second)
117
+ agg2 = resp["event"]
118
+
119
+ # FIXME Need to export is_aggregate/children fields
101
120
  end
102
121
 
103
122
  def test_metrics
@@ -110,5 +129,4 @@ class TestClient < Test::Unit::TestCase
110
129
 
111
130
  dog_r.emit_points('test.metric.metric', [[Time.now-60, 20], [Time.now-30, 10], [Time.now, 5]], :tags => ["test:tag.1", "test:tag2"])
112
131
  end
113
-
114
132
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 1
9
- version: 1.3.1
8
+ - 2
9
+ version: 1.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Datadog, Inc.
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-05-24 00:00:00 -04:00
17
+ date: 2012-06-04 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency