dynamo-autoscale 0.3.1 → 0.3.2

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.3.2
2
+
3
+ - Improved formatting in the scaling event emails, to try and make them
4
+ easier to read.
5
+
1
6
  v0.3.1
2
7
 
3
8
  - Mainly quality of life changes. We're playing nicely in the CLI now, with a
@@ -6,7 +6,7 @@ module DynamoAutoscale
6
6
 
7
7
  def initialize table
8
8
  @table = table
9
- @erb = ERB.new(File.read(TEMPLATE))
9
+ @erb = ERB.new(File.read(TEMPLATE), nil, '-')
10
10
 
11
11
  if DynamoAutoscale.config[:dry_run]
12
12
  @enabled = false
@@ -45,5 +45,23 @@ module DynamoAutoscale
45
45
  logger.error "[mailer] Encountered an error: #{e.class}:#{e.message}"
46
46
  false
47
47
  end
48
+
49
+ def formatted_scale_event(scale_event)
50
+ max_length = max_metric_length(scale_event)
51
+ ['reads', 'writes'].map do |type|
52
+ type_from = scale_event["#{type}_from".to_sym].to_s.rjust(max_length)
53
+ type_to = scale_event["#{type}_to".to_sym].to_s.rjust(max_length)
54
+
55
+ "#{type.capitalize.rjust(6)}: #{scale_direction(type_from, type_to)} from #{type_from} to #{type_to}"
56
+ end
57
+ end
58
+
59
+ def max_metric_length(scale_event)
60
+ scale_event.values.max.to_s.length
61
+ end
62
+
63
+ def scale_direction(from, to)
64
+ from > to ? 'DOWN' : ' UP '
65
+ end
48
66
  end
49
67
  end
@@ -1,3 +1,3 @@
1
1
  module DynamoAutoscale
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
data/script/email_test CHANGED
@@ -50,13 +50,13 @@ end
50
50
  }
51
51
  end
52
52
 
53
- report = ScaleReport.new(table)
54
53
 
55
54
  if ARGV[0]
56
55
  DynamoAutoscale.setup_from_config(ARGV[0], dry_run: false)
57
56
 
58
- report.send
57
+ ScaleReport.new(table).send
59
58
  elsif ARGV[0].nil?
59
+ report = ScaleReport.new(table)
60
60
  puts "Subject: #{report.email_subject}"
61
61
  puts
62
62
  puts report.email_content
@@ -1,18 +1,33 @@
1
+ Latest scale event for <%= @table.name %>:
2
+
3
+ <% @table.scale_events.reverse_each.take(1).each do |time, scale_event| -%>
4
+ <%= time.iso8601 %>
5
+
6
+ <% formatted_scale_event(scale_event).each do |line| -%>
7
+ <%= line %>
8
+ <% end -%>
9
+ <% end -%>
10
+
11
+
1
12
  Last 5 scale events:
2
13
 
3
- <% @table.scale_events.reverse_each.take(5).each do |time, scale_event| %>
4
- <%= time.iso8601 %>: <%= scale_event %>
5
- <% end %>
14
+ <% @table.scale_events.reverse_each.take(5).each do |time, scale_event| -%>
15
+ <%= time.iso8601 %>
16
+
17
+ <% formatted_scale_event(scale_event).each do |line| -%>
18
+ <%= line %>
19
+ <% end %>
6
20
 
21
+ <% end -%>
7
22
  Last 5 triggered rules:
8
23
 
9
- <% @table.triggered_rules.reverse_each.take(5).each do |time, rule| %>
10
- <%= time.iso8601 %>: <%= rule.to_english %>
11
- <% end %>
24
+ <% @table.triggered_rules.reverse_each.take(5).each do |time, rule| -%>
25
+ <%= time.iso8601 %>
26
+ <%= rule.to_english %>
12
27
 
28
+ <% end %>
13
29
  Last 20 data points:
14
-
15
30
  <% @table.data.reverse_each.take(20).each do |time, datum| %>
16
- <%= time.iso8601 %>: <%= datum %>
17
- <% end %>
18
-
31
+ <%= time.iso8601 %>
32
+ <%= datum %>
33
+ <% 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.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -193,9 +193,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - - ! '>='
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
- segments:
197
- - 0
198
- hash: 3081011429766319992
199
196
  requirements:
200
197
  - If you want to graph your tables, you'll need R with the ggplot and reshape packages
201
198
  installed.