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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a0172ebed9fc844a07a32b5da53ffada18d5b0a
4
- data.tar.gz: 91e401e181020b207c78ef5aade81eb597d87db2
3
+ metadata.gz: 959afc0e7a0386b750f3abbb92cd4e289ddd0d1a
4
+ data.tar.gz: 27dc436065b5622347edb567da5e52856ba67023
5
5
  SHA512:
6
- metadata.gz: 39100605467a6ba214b733235371cdc75ec86d6a2bda6710d549fd93098d012d575fd0bdb81229ad8ef4ce5845d8ca3e63ac30cfbed91188156d14aa523a9f6a
7
- data.tar.gz: 9e90d083a6716a04c7d00108e58ffe83190ff112ececb7a6ea1bc69e7e18ce92af92e9c38cf073a7200a8f3d56ec247a0b7fbadb9cd3b351791dc60076f47167
6
+ metadata.gz: 0943e9aafb8ffac93ec84444a9e9eec05754d72a95210767a016b1133bcdc5121a9402bb6eeb72674e48ce0fc633b2c2bf618d472637fb1717c4b94218fea9f3
7
+ data.tar.gz: 3006307a9676afad7c3b4eed8e7296737a6fe16b2cd31b01afab4250238bf9e778f90f52c20307e6a8ea34fca229801eb4b2e119d0c2f3384e8b116a050d7c17
data/.travis.yml CHANGED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # MetricsMachine
2
2
 
3
+ [![Build Status](https://travis-ci.org/cbeer/metrics_machine.png?branch=master)](https://travis-ci.org/cbeer/metrics_machine)
4
+
3
5
  TODO: Write a gem description
4
6
 
5
7
  ## Installation
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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, "metrics_machine")
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
- initializer "metricsmachine.start_em" do
5
- unless EM.reactor_running?
6
- MetricsMachine.start
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
- initializer "metricsmachine.configure_rails_initialization" do
11
- MetricsMachine.configure do
12
- monitor :mysql, ActiveRecord::Base.connection if ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::Mysql2Adapter
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
 
@@ -1,3 +1,3 @@
1
1
  module MetricsMachine
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metrics_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer