overall_request_times 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cfb784b756679539fbcc5f3b86bad33a3fde701
4
- data.tar.gz: af6e82fa47bc035370942cad03a944693742518a
3
+ metadata.gz: f58db41c069691725293eddd56fa4b0dc5305e1a
4
+ data.tar.gz: 02813a0d13297f01e0863bd16c2543407171f192
5
5
  SHA512:
6
- metadata.gz: 6b409c978b34f335ddd57eea9a0c33eb91a1f259d765b4511d707e80d15b6b1a5e37c2d843aaaf9946619fb12be05f8c462ded50bce0b292736a12469af775dc
7
- data.tar.gz: 7bf0ab514ed14e6231418b8fc337695986b9648aa849b3db717d030b2533cdc7116946ba188ce27b265634acc41c5697b323fc69d93687b19629daa91915a2c8
6
+ metadata.gz: d244ef863bfc6a7324952f1f5ba17d8a5be55d18ad70f7354e44cd06bf9726dbba77b2dd1cfade604e250db2bc07a718b12a2d983c848b051a595adb2f828324
7
+ data.tar.gz: 0665a15ea6ea43e129073cb03cf5eef3114ef0bb41f7bdfe3ceae7efc0fe91d5fab6e24a92b7fc2e30160d67958a053b54f512c95cd6f24f7fe146f6f64b5a10
data/README.md CHANGED
@@ -57,7 +57,8 @@ OverallRequestTimes.stop(:remote_service_name)
57
57
  Then to extract the totals to log:
58
58
 
59
59
  ```ruby
60
- OverallRequestTimes.total_for(:remote_service_name)
60
+ OverallRequestTimes.total_for(:remote_service_name) # => 12.5
61
+ OverallRequestTimes.call_count_for(:remote_service_name) # => 3
61
62
  ```
62
63
 
63
64
  And reset the totals at the start of your request cycle:
@@ -31,6 +31,13 @@ module OverallRequestTimes
31
31
  end
32
32
  end
33
33
 
34
+ def call_count_for(remote_app_name)
35
+ @mutex.synchronize do
36
+ timer = @registry[remote_app_name]
37
+ timer ? timer.call_count : 0
38
+ end
39
+ end
40
+
34
41
  def totals
35
42
  @mutex.synchronize do
36
43
  @registry.each_with_object({}) do |(remote_app_name, timer), acc|
@@ -16,14 +16,22 @@ module OverallRequestTimes
16
16
  end
17
17
  end
18
18
 
19
+ def call_count
20
+ @timer_mutex.synchronize do
21
+ @counter
22
+ end
23
+ end
24
+
19
25
  def reset!
20
26
  @timer_mutex.synchronize do
21
27
  @total = 0
28
+ @counter = 0
22
29
  end
23
30
  end
24
31
 
25
32
  def add(some_time)
26
33
  @timer_mutex.synchronize do
34
+ @counter += 1
27
35
  @total += some_time
28
36
  end
29
37
  end
@@ -1,3 +1,3 @@
1
1
  module OverallRequestTimes
2
- VERSION = "0.5.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -28,6 +28,10 @@ module OverallRequestTimes
28
28
  registry.total_for(remote_app_name)
29
29
  end
30
30
 
31
+ def self.call_count_for(remote_app_name)
32
+ registry.call_count_for(remote_app_name)
33
+ end
34
+
31
35
  def self.totals
32
36
  registry.totals
33
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overall_request_times
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Plummer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday