dynamo-autoscale 0.2.2 → 0.2.3

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.3
2
+
3
+ - Improved logging.
4
+ - Fixed a bug when downscale limits were hit.
5
+
1
6
  v0.2.2
2
7
 
3
8
  - Fixed a logging error.
@@ -179,7 +179,7 @@ module DynamoAutoscale
179
179
  end
180
180
 
181
181
  def self.current_table
182
- @@current_table
182
+ @@current_table ||= nil
183
183
  end
184
184
  end
185
185
 
@@ -15,7 +15,7 @@ DynamoAutoscale::Logger.logger = ::Logger.new(STDOUT)
15
15
  if config[:style] == "pretty"
16
16
  DynamoAutoscale::Logger.logger.formatter = DynamoAutoscale::PrettyFormatter.new
17
17
  else
18
- DynamoAutoscale::Logger.logger.formatter = Logger::Formatter.new
18
+ DynamoAutoscale::Logger.logger.formatter = DynamoAutoscale::StandardFormatter.new
19
19
  end
20
20
 
21
21
  if ENV['DEBUG']
@@ -203,26 +203,37 @@ module DynamoAutoscale
203
203
 
204
204
  @pending[:writes] = nil
205
205
  @pending[:reads] = nil
206
+
207
+ logger.info "[flush] Flushed a read and a write event."
208
+ else
209
+ logger.error "[flush] Failed to flush a read and write event."
206
210
  end
207
211
  elsif @pending[:writes]
208
212
  value = @pending[:writes]
209
213
 
210
214
  if result = scale(:writes, value)
211
- @provisioned[:writes][Time.now.utc] = value
215
+ @provisioned[:writes][now] = value
212
216
  table.scale_events[now] = { writes: value }
213
217
  @pending[:writes] = nil
218
+
219
+ logger.info "[flush] Flushed a write event."
220
+ else
221
+ logger.error "[flush] Failed to flush a write event."
214
222
  end
215
223
  elsif @pending[:reads]
216
224
  value = @pending[:reads]
217
225
 
218
226
  if result = scale(:reads, value)
219
- @provisioned[:reads][Time.now.utc] = value
227
+ @provisioned[:reads][now] = value
220
228
  table.scale_events[now] = { reads: value }
221
229
  @pending[:reads] = nil
230
+
231
+ logger.info "[flush] Flushed a read event."
232
+ else
233
+ logger.error "[flush] Failed to flush a read event."
222
234
  end
223
235
  end
224
236
 
225
- logger.info "[flush] All pending downscales have been flushed."
226
237
  return result
227
238
  end
228
239
 
@@ -43,7 +43,7 @@ module DynamoAutoscale
43
43
  # When you try to increase throughput greater than 2x or you try to
44
44
  # decrease more than 4 times per day you get this.
45
45
 
46
- aws_description = self.describe_table(table)
46
+ aws_description = self.class.describe_table(table)
47
47
  decreases_today = aws_description[:provisioned_throughput][:number_of_decreases_today]
48
48
 
49
49
  downscales(table, decreases_today)
@@ -0,0 +1,14 @@
1
+ module DynamoAutoscale
2
+ class StandardFormatter
3
+ def initialize
4
+ @formatter = ::Logger::Formatter.new
5
+ end
6
+
7
+ def call(severity, time, progname, msg)
8
+ table = DynamoAutoscale.current_table
9
+ msg = "[#{table.name}] #{msg}" if table
10
+
11
+ @formatter.call(severity, time, progname, msg)
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module DynamoAutoscale
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  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.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -149,6 +149,7 @@ files:
149
149
  - lib/dynamo-autoscale/rule.rb
150
150
  - lib/dynamo-autoscale/rule_set.rb
151
151
  - lib/dynamo-autoscale/scale_report.rb
152
+ - lib/dynamo-autoscale/standard_formatter.rb
152
153
  - lib/dynamo-autoscale/table_tracker.rb
153
154
  - lib/dynamo-autoscale/unit_cost.rb
154
155
  - lib/dynamo-autoscale/version.rb