metrics_machine 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +2 -0
- data/Rakefile +5 -0
- data/lib/metrics_machine/monitor.rb +5 -1
- data/lib/metrics_machine/railtie.rb +9 -7
- data/lib/metrics_machine/version.rb +1 -1
- data/lib/metrics_machine.rb +4 -4
- data/spec/lib/metrics_machine/metrics_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959afc0e7a0386b750f3abbb92cd4e289ddd0d1a
|
4
|
+
data.tar.gz: 27dc436065b5622347edb567da5e52856ba67023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0943e9aafb8ffac93ec84444a9e9eec05754d72a95210767a016b1133bcdc5121a9402bb6eeb72674e48ce0fc633b2c2bf618d472637fb1717c4b94218fea9f3
|
7
|
+
data.tar.gz: 3006307a9676afad7c3b4eed8e7296737a6fe16b2cd31b01afab4250238bf9e778f90f52c20307e6a8ea34fca229801eb4b2e119d0c2f3384e8b116a050d7c17
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ module MetricsMachine
|
|
9
9
|
def initialize reporter, options = {}, &block
|
10
10
|
@reporter = reporter
|
11
11
|
@monitors = {}
|
12
|
-
@prefix = options.fetch(:prefix,
|
12
|
+
@prefix = options.fetch(:prefix, self.class.default_prefix)
|
13
13
|
instance_eval &block
|
14
14
|
run!
|
15
15
|
end
|
@@ -47,5 +47,9 @@ module MetricsMachine
|
|
47
47
|
monitors[key] = c
|
48
48
|
end
|
49
49
|
|
50
|
+
def self.default_prefix
|
51
|
+
`hostname`.strip
|
52
|
+
end
|
53
|
+
|
50
54
|
end
|
51
55
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module MetricsMachine
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if Rails.env.production?
|
5
|
+
initializer "metricsmachine.start_em" do
|
6
|
+
unless EM.reactor_running?
|
7
|
+
MetricsMachine.start
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
initializer "metricsmachine.configure_rails_initialization" do
|
12
|
+
MetricsMachine.configure do
|
13
|
+
monitor :mysql, ActiveRecord::Base.connection if ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
data/lib/metrics_machine.rb
CHANGED
@@ -8,7 +8,7 @@ module MetricsMachine
|
|
8
8
|
autoload :Monitor, "metrics_machine/monitor"
|
9
9
|
autoload :Railtie, "metrics_machine/railtie"
|
10
10
|
|
11
|
-
def self.start &block
|
11
|
+
def self.start options = {}, &block
|
12
12
|
|
13
13
|
thread = if defined?(PhusionPassenger)
|
14
14
|
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
@@ -27,12 +27,12 @@ module MetricsMachine
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
Monitor.new reporter, &block if block_given?
|
30
|
+
Monitor.new reporter, options, &block if block_given?
|
31
31
|
thread
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.configure &block
|
35
|
-
Monitor.new reporter, &block if block_given?
|
34
|
+
def self.configure options = {}, &block
|
35
|
+
Monitor.new reporter, options, &block if block_given?
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.die_gracefully_on_signal
|
@@ -17,6 +17,8 @@ describe MetricsMachine do
|
|
17
17
|
reporter = double()
|
18
18
|
|
19
19
|
reporter.should_receive(:gauge).at_least(3).at_most(6).times.with("metrics_machine.dummy_monitor.some_value", 50)
|
20
|
+
MetricsMachine::Monitor.stub(:default_prefix => "metrics_machine")
|
21
|
+
|
20
22
|
MetricsMachine.stub(:reporter => reporter)
|
21
23
|
|
22
24
|
|