app_monit_rails 0.0.1 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0769d189aabb5b61c156b284e4da0b101fb7589b
4
- data.tar.gz: d4022043cde9af84b6a27709a457649dbf6c9fa0
3
+ metadata.gz: 03d5fafb91520a7cff4f077ca1e59529f9347b79
4
+ data.tar.gz: 0ab9267e9d1763eca83c2f9dae22a5826a45b3eb
5
5
  SHA512:
6
- metadata.gz: 69105b1f1c655666bc87cd01cd3c30671f1c2e3017666fd38496fb4e92187aa25e3ff2e0328131ba27f44ee1845dea0787e27e1c0802e8cf21a8773e21e9cde0
7
- data.tar.gz: 20826e4ad2f2c35ba3eb280b1465c4e75e2d80ec07b05f6989088b983409a78ef5373d5ef50c12135fdd9af3392f645a009504ef4f429e11ea70005a702cde7f
6
+ metadata.gz: 30a433805844c93c78e5ce0766c3268f75e3309ece3ade0be543919e6920eae2110c417127ef79324fc99796beecfc7ef30977278886d9a98aac9f694188c0db
7
+ data.tar.gz: 845d116ad99b534847cd50f8e0c7ed1fe0cea176bd78e80b337c32f4804e74ff3cee89752941e1d86ac97b626a8d2457c9f20a8b4026e52538b62f72fae41e08
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ coverage
11
11
  tmp
12
12
  .idea
13
13
  .rspec
14
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_monit_rails (0.0.5)
4
+ app_monit_rails (0.0.3)
5
5
  app_monit (>= 0.0.7)
6
6
 
7
7
  GEM
@@ -0,0 +1,13 @@
1
+ module AppMonit
2
+ module Rails
3
+ class Config
4
+ class << self
5
+ attr_writer :enabled
6
+
7
+ def enabled?
8
+ @enabled.nil? ? ::Rails.env != "test" : @enabled
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,9 +1,11 @@
1
1
  module AppMonit
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
- initializer 'app_monit.configure' do |app|
5
- AppMonit::Rails::Subscriber.register
6
- AppMonit::Rails.logger.debug '[RAILSRUNNER] started'
4
+ config.after_initialize do |app|
5
+ if AppMonit::Rails::Config.enabled?
6
+ AppMonit::Rails::Subscriber.register
7
+ AppMonit::Rails.logger.debug '[RAILSRUNNER] started'
8
+ end
7
9
  end
8
10
  end
9
11
  end
@@ -1,5 +1,5 @@
1
1
  module AppMonit
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -116,13 +116,14 @@ module AppMonit
116
116
  def send_to_collector
117
117
  AppMonit::Rails.logger.debug "Sending to collector"
118
118
 
119
- events = convert_requests_to_events
120
- errors = convert_errors_to_events
119
+ events = convert_requests_to_events + convert_errors_to_events
121
120
 
122
- AppMonit::Http.post('/v1/events', event: (events + errors))
121
+ if events.any?
122
+ AppMonit::Http.post('/v1/events', event: events)
123
123
 
124
- @requests.clear
125
- @errors.clear
124
+ @requests.clear
125
+ @errors.clear
126
+ end
126
127
 
127
128
  reset
128
129
  end
@@ -4,6 +4,7 @@ module AppMonit
4
4
  Event = Struct.new(:minute, :endpoint, :durations)
5
5
  Error = Struct.new(:minute, :endpoint, :duration)
6
6
 
7
+ require 'app_monit/rails/config'
7
8
  require 'app_monit/rails/subscriber'
8
9
  require 'app_monit/rails/railtie'
9
10
  require 'app_monit/rails/worker'
@@ -0,0 +1 @@
1
+ AppMonit::Rails::Config.enabled = true
@@ -1,11 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  feature 'Triggered events' do
4
-
5
4
  scenario 'User creates a new Post' do
6
- AppMonit::Config.end_point = 'http://localhost:3000'
7
- AppMonit::Config.api_key = 'api_key'
8
- AppMonit::Config.env = 'test'
5
+ AppMonit::Config.end_point = 'http://test.local'
6
+ AppMonit::Config.api_key = 'api_key'
7
+ AppMonit::Config.env = 'test'
9
8
 
10
9
  10.times do
11
10
  visit '/posts/'
@@ -37,9 +36,7 @@ feature 'Triggered events' do
37
36
 
38
37
  @worker = AppMonit::Rails::Worker.instance
39
38
  end
40
- AppMonit::Rails::Worker.instance.push(:flush)
41
- sleep 1.0
42
39
 
43
- puts AppMonit::Rails::Worker.instance.requests.count
40
+ puts AppMonit::Rails::Worker.instance.requests.inspect
44
41
  end
45
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_monit_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redmar Kerkhoff
@@ -139,6 +139,7 @@ files:
139
139
  - README.rdoc
140
140
  - Rakefile
141
141
  - appmonit_rails_gem.gemspec
142
+ - lib/app_monit/rails/config.rb
142
143
  - lib/app_monit/rails/railtie.rb
143
144
  - lib/app_monit/rails/subscriber.rb
144
145
  - lib/app_monit/rails/version.rb
@@ -179,6 +180,7 @@ files:
179
180
  - spec/dummy/config/environments/development.rb
180
181
  - spec/dummy/config/environments/production.rb
181
182
  - spec/dummy/config/environments/test.rb
183
+ - spec/dummy/config/initializers/app_monit.rb
182
184
  - spec/dummy/config/initializers/backtrace_silencers.rb
183
185
  - spec/dummy/config/initializers/filter_parameter_logging.rb
184
186
  - spec/dummy/config/initializers/inflections.rb
@@ -258,6 +260,7 @@ test_files:
258
260
  - spec/dummy/config/environments/development.rb
259
261
  - spec/dummy/config/environments/production.rb
260
262
  - spec/dummy/config/environments/test.rb
263
+ - spec/dummy/config/initializers/app_monit.rb
261
264
  - spec/dummy/config/initializers/backtrace_silencers.rb
262
265
  - spec/dummy/config/initializers/filter_parameter_logging.rb
263
266
  - spec/dummy/config/initializers/inflections.rb