dynamo-autoscale 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.2.9
2
+
3
+ - Fixed a problem where scale events weren't being showed in the scale report
4
+ emails.
5
+
1
6
  v0.2.8
2
7
 
3
8
  - It seems that CloudWatch only has new data every 5 minutes. CloudWatch polling
data/README.md CHANGED
@@ -425,10 +425,11 @@ Report Issues/Feature requests on
425
425
 
426
426
  * Fork the project.
427
427
  * Make your feature addition or bug fix.
428
- * Add tests for it. This is important so we don't break it in a
429
- future version unintentionally.
430
- * Commit, do not modify the rakefile, version, or history.
431
- (if you want to have your own version, that is fine but bump version in a commit by itself so it can be ignored when we pull)
428
+ * Add tests for it. This is important so we don't break it in a future version
429
+ unintentionally.
430
+ * Commit, do not modify the rakefile, version, or history. (if you want to
431
+ have your own version, that is fine but bump version in a commit by itself so
432
+ it can be ignored when we pull)
432
433
  * Send a pull request. Bonus points for topic branches.
433
434
 
434
435
  ### Copyright
@@ -134,7 +134,10 @@ module DynamoAutoscale
134
134
 
135
135
  # Because upscales are not limited, we don't need to queue this operation.
136
136
  if result = scale(metric, to)
137
- table.scale_events[now] = { metric => to }
137
+ table.scale_events[now] = {
138
+ "#{metric}_to".to_sym => to,
139
+ "#{metric}_from".to_sym => from,
140
+ }
138
141
 
139
142
  @provisioned[metric][now] = to
140
143
  @upscales += 1
@@ -163,11 +166,11 @@ module DynamoAutoscale
163
166
  "#{from ? from.round(2) : "Unknown"} -> #{to.round(2)}"
164
167
  end
165
168
 
166
- queue_operation! metric, to
169
+ queue_operation! metric, from, to
167
170
  end
168
171
 
169
- def queue_operation! metric, value
170
- @pending[metric] = value
172
+ def queue_operation! metric, from, to
173
+ @pending[metric] = [from, to]
171
174
  try_flush!
172
175
  end
173
176
 
@@ -192,16 +195,18 @@ module DynamoAutoscale
192
195
  now = Time.now.utc
193
196
 
194
197
  if @pending[:writes] and @pending[:reads]
195
- wvalue = @pending[:writes]
196
- rvalue = @pending[:reads]
198
+ wfrom, wto = @pending[:writes]
199
+ rfrom, rto = @pending[:reads]
197
200
 
198
- if result = scale_both(rvalue, wvalue)
199
- @provisioned[:writes][now] = wvalue
200
- @provisioned[:reads][now] = rvalue
201
+ if result = scale_both(rto, wto)
202
+ @provisioned[:writes][now] = wto
203
+ @provisioned[:reads][now] = rto
201
204
 
202
205
  table.scale_events[now] = {
203
- writes: wvalue,
204
- reads: rvalue,
206
+ writes_from: wfrom,
207
+ writes_to: wto,
208
+ reads_from: rfrom,
209
+ reads_to: rto,
205
210
  }
206
211
 
207
212
  @pending[:writes] = nil
@@ -212,24 +217,24 @@ module DynamoAutoscale
212
217
  logger.error "[flush] Failed to flush a read and write event."
213
218
  end
214
219
  elsif @pending[:writes]
215
- value = @pending[:writes]
220
+ from, to = @pending[:writes]
216
221
 
217
- if result = scale(:writes, value)
218
- @provisioned[:writes][now] = value
219
- table.scale_events[now] = { writes: value }
220
- @pending[:writes] = nil
222
+ if result = scale(:writes, to)
223
+ @provisioned[:writes][now] = to
224
+ table.scale_events[now] = { writes_from: from, writes_to: to }
225
+ @pending[:writes] = nil
221
226
 
222
227
  logger.info "[flush] Flushed a write event."
223
228
  else
224
229
  logger.error "[flush] Failed to flush a write event."
225
230
  end
226
231
  elsif @pending[:reads]
227
- value = @pending[:reads]
232
+ from, to = @pending[:reads]
228
233
 
229
- if result = scale(:reads, value)
230
- @provisioned[:reads][now] = value
231
- table.scale_events[now] = { reads: value }
232
- @pending[:reads] = nil
234
+ if result = scale(:reads, to)
235
+ @provisioned[:reads][now] = to
236
+ table.scale_events[now] = { reads_from: from, reads_to: to }
237
+ @pending[:reads] = nil
233
238
 
234
239
  logger.info "[flush] Flushed a read event."
235
240
  else
@@ -16,12 +16,16 @@ module DynamoAutoscale
16
16
  end
17
17
  end
18
18
 
19
+ def email_content
20
+ @erb.result(binding)
21
+ end
22
+
19
23
  def send
20
24
  return false unless @enabled
21
25
 
22
26
  result = Pony.mail({
23
27
  subject: "Scale event for #{@table.name}",
24
- body: @erb.result(binding),
28
+ body: email_content,
25
29
  })
26
30
 
27
31
  if result
@@ -1,3 +1,3 @@
1
1
  module DynamoAutoscale
2
- VERSION = '0.2.8'
2
+ VERSION = '0.2.9'
3
3
  end
@@ -1,3 +1,9 @@
1
+ Last 5 scale events:
2
+
3
+ <% @table.scale_events.reverse_each.take(5).each do |time, scale_event| %>
4
+ <%= time.iso8601 %>: <%= scale_event %>
5
+ <% end %>
6
+
1
7
  Last 5 triggered rules:
2
8
 
3
9
  <% @table.triggered_rules.reverse_each.take(5).each do |time, rule| %>
@@ -10,8 +16,3 @@ Last 20 data points:
10
16
  <%= time.iso8601 %>: <%= datum %>
11
17
  <% end %>
12
18
 
13
- Last 5 scale events:
14
-
15
- <% @table.scale_events.reverse_each.take(5) do |time, scale_event| %>
16
- <%= time.iso8601 %>: <%= scale_event %>
17
- <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamo-autoscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir:
11
11
  - bin
12
12
  cert_chain: []
13
- date: 2013-07-04 00:00:00.000000000 Z
13
+ date: 2013-07-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk