lockistics 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -34,7 +34,7 @@ Total, daily and hourly metrics you get for each key are:
34
34
  - Number of times having to wait for lock
35
35
  - Number of failed locking attempts
36
36
  - Minimum and maximum duration
37
- - Minimum and maximum memory growth (using OS gem)
37
+ - Minimum and maximum memory growth (using OS gem, only when :meter_rss is set to true)
38
38
  - Arbitary metrics you add during execution (more on this in examples)
39
39
 
40
40
  ## Why?
@@ -11,6 +11,7 @@ module Lockistics
11
11
  attr_accessor :retries
12
12
  attr_accessor :raise
13
13
  attr_accessor :pass_through
14
+ attr_accessor :meter_rss
14
15
 
15
16
  def initialize
16
17
  @redis = Redis.new
@@ -19,6 +20,7 @@ module Lockistics
19
20
  @sleep = 0.5
20
21
  @retries = 10
21
22
  @pass_through = false
23
+ @meter_rss = false
22
24
  end
23
25
 
24
26
  def lock_defaults
@@ -29,6 +31,7 @@ module Lockistics
29
31
  :sleep => sleep,
30
32
  :retries => retries,
31
33
  :wait => true,
34
+ :meter_rss => false,
32
35
  :raise => true
33
36
  }
34
37
  end
@@ -121,11 +121,16 @@ module Lockistics
121
121
  Lockistics.known_keys(key)
122
122
  @start_time = Time.now.to_f
123
123
  # Sometimes you get 'Cannot allocate memory - ps -o rss= -p 15964'
124
- begin
125
- @start_rss = OS.rss_bytes
126
- rescue
124
+ if options[:meter_rss]
125
+ begin
126
+ @start_rss = OS.rss_bytes
127
+ rescue
128
+ @start_rss = nil
129
+ end
130
+ else
127
131
  @start_rss = nil
128
132
  end
133
+
129
134
  redis.pipelined do
130
135
  redis.sadd "#{Lockistics.configuration.namespace}.#{key}.hourlies", hourly_timestamp
131
136
  redis.sadd "#{Lockistics.configuration.namespace}.#{key}.dailies", daily_timestamp
@@ -1,3 +1,3 @@
1
1
  module Lockistics
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/lockistics.rb CHANGED
@@ -18,7 +18,7 @@ require "lockistics/meterable"
18
18
  # - Number of times having to wait for lock
19
19
  # - Number of failed locking attempts
20
20
  # - Minimum and maximum duration
21
- # - Minimum and maximum memory growth (using OS gem)
21
+ # - Minimum and maximum memory growth (using OS gem, only when :meter_rss => true)
22
22
  # - Arbitary metrics you add during execution
23
23
  #
24
24
  # Theres also an experimental module you can use to wrap any instance
@@ -46,6 +46,7 @@ module Lockistics
46
46
  # config.retries = 10 # retry times
47
47
  # config.raise = true # raise Lockistics::TimeoutException when lock fails
48
48
  # config.pass_through = false # don't do anything, just pass everything through
49
+ # config.meter_rss = false # measure memory growth during lock, note that it will increase memory consumption
49
50
  # end
50
51
  def self.configure(&block)
51
52
  yield configuration
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockistics
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kimmo Lehto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-06-14 00:00:00 Z
18
+ date: 2014-06-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement