interferon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,41 +103,39 @@ module Interferon::Destinations
103
103
  end
104
104
 
105
105
  # log whenever we've encountered errors
106
- if resp
107
- code = resp[0].to_i
108
-
109
- # client error
110
- if code == 400
111
- statsd.gauge('datadog.api.unknown_error', 0, :tags => ["alert:#{alert}"])
112
- statsd.gauge('datadog.api.client_error', 1, :tags => ["alert:#{alert}"])
113
- statsd.gauge('datadog.api.success', 0, :tags => ["alert:#{alert}"])
114
-
115
- @stats[:api_client_errors] += 1
116
- log.error("client error while #{action} alert '#{alert['name']}';" \
117
- " query was '#{alert['metric']['datadog_query'].strip}'")
118
-
119
- # unknown (prob. datadog) error:
120
- elsif code >= 400 || code == -1
121
- statsd.gauge('datadog.api.unknown_error', 1, :tags => ["alert:#{alert}"])
122
- statsd.gauge('datadog.api.client_error', 0, :tags => ["alert:#{alert}"])
123
- statsd.gauge('datadog.api.success', 0, :tags => ["alert:#{alert}"])
124
-
125
- @stats[:api_unknown_errors] += 1
126
- log.error("unknown error while #{action} alert '#{alert['name']}':" \
127
- " query was '#{alert['metric']['datadog_query'].strip}'" \
128
- " response was #{resp[0]}:'#{resp[1].inspect}'")
129
-
130
- # assume this was a success
131
- else
132
- statsd.gauge('datadog.api.unknown_error', 0, :tags => ["alert:#{alert}"])
133
- statsd.gauge('datadog.api.client_error', 0, :tags => ["alert:#{alert}"])
134
- statsd.gauge('datadog.api.success', 1, :tags => ["alert:#{alert}"])
135
-
136
- @stats[:api_successes] += 1
137
- @stats[:alerts_created] += 1 if action == :creating
138
- @stats[:alerts_updated] += 1 if action == :updating
139
- @stats[:alerts_silenced] += 1 if alert_opts[:silenced]
140
- end
106
+ code = @dry_run ? 200 : resp[0].to_i
107
+
108
+ # client error
109
+ if code == 400
110
+ statsd.gauge('datadog.api.unknown_error', 0, :tags => ["alert:#{alert}"])
111
+ statsd.gauge('datadog.api.client_error', 1, :tags => ["alert:#{alert}"])
112
+ statsd.gauge('datadog.api.success', 0, :tags => ["alert:#{alert}"])
113
+
114
+ @stats[:api_client_errors] += 1
115
+ log.error("client error while #{action} alert '#{alert['name']}';" \
116
+ " query was '#{alert['metric']['datadog_query'].strip}'")
117
+
118
+ # unknown (prob. datadog) error:
119
+ elsif code >= 400 || code == -1
120
+ statsd.gauge('datadog.api.unknown_error', 1, :tags => ["alert:#{alert}"])
121
+ statsd.gauge('datadog.api.client_error', 0, :tags => ["alert:#{alert}"])
122
+ statsd.gauge('datadog.api.success', 0, :tags => ["alert:#{alert}"])
123
+
124
+ @stats[:api_unknown_errors] += 1
125
+ log.error("unknown error while #{action} alert '#{alert['name']}':" \
126
+ " query was '#{alert['metric']['datadog_query'].strip}'" \
127
+ " response was #{resp[0]}:'#{resp[1].inspect}'")
128
+
129
+ # assume this was a success
130
+ else
131
+ statsd.gauge('datadog.api.unknown_error', 0, :tags => ["alert:#{alert}"])
132
+ statsd.gauge('datadog.api.client_error', 0, :tags => ["alert:#{alert}"])
133
+ statsd.gauge('datadog.api.success', 1, :tags => ["alert:#{alert}"])
134
+
135
+ @stats[:api_successes] += 1
136
+ @stats[:alerts_created] += 1 if action == :creating
137
+ @stats[:alerts_updated] += 1 if action == :updating
138
+ @stats[:alerts_silenced] += 1 if alert_opts[:silenced]
141
139
  end
142
140
 
143
141
  # lets key alerts by their name
@@ -1,3 +1,3 @@
1
1
  module Interferon
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interferon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2015-05-07 00:00:00.000000000 Z
12
+ date: 2015-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dogapi