metriks-librato_metrics 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,27 +27,35 @@ module Metriks
27
27
  else
28
28
  @percentiles = [ 0.95, 0.999 ]
29
29
  end
30
+
31
+ @mutex = Mutex.new
32
+ @running = false
30
33
  end
31
34
 
32
35
  def start
33
- @thread ||= Thread.new do
34
- while true
36
+ if @thread && @thread.alive?
37
+ return
38
+ end
39
+
40
+ @running = true
41
+ @thread = Thread.new do
42
+ while @running
35
43
  @time_tracker.sleep
36
44
 
37
45
  Thread.new do
38
- begin
39
- write
40
- rescue Exception => ex
41
- @on_error[ex] rescue nil
42
- end
46
+ flush
43
47
  end
44
48
  end
45
49
  end
46
50
  end
47
51
 
48
52
  def stop
49
- @thread.kill if @thread
50
- @thread = nil
53
+ @running = false
54
+
55
+ if @thread
56
+ @thread.join
57
+ @thread = nil
58
+ end
51
59
  end
52
60
 
53
61
  def restart
@@ -55,6 +63,16 @@ module Metriks
55
63
  start
56
64
  end
57
65
 
66
+ def flush
67
+ begin
68
+ @mutex.synchronize do
69
+ write
70
+ end
71
+ rescue Exception => ex
72
+ @on_error[ex] rescue nil
73
+ end
74
+ end
75
+
58
76
  def submit
59
77
  return if @data.empty?
60
78
 
@@ -1,5 +1,5 @@
1
1
  require 'metriks/librato_metrics_reporter'
2
2
 
3
3
  module MetriksLibratoMetrics
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'metriks-librato_metrics'
16
- s.version = '1.0.1'
16
+ s.version = '1.0.2'
17
17
  s.date = '2014-04-24'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metriks-librato_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: