traxor 0.1.18 → 0.1.19

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
  SHA256:
3
- metadata.gz: ba90b5e65121c02ec1a419a5e945c43802be46121fec69315c38a0bb327e01f5
4
- data.tar.gz: 4ab56d1a501ce39e962f0108b745f758e3597a152d10d92122ea26e6605863ba
3
+ metadata.gz: 351b5aa13db42137c948cfb5b917b2ba74362cd6963c00f53670050c9c062ca9
4
+ data.tar.gz: 5a8c4de34ba013e1d18332c9deaa3bfa064297ea98eec68783fbab8de3fbd8c3
5
5
  SHA512:
6
- metadata.gz: 31548d74364f241fe3286c46b79018eb0b1e948922cb13f6e8f77db3493d0f17c809d0e19c2bfb4b1adb3fff14b8da302367285eee3f796ef0e649955739571c
7
- data.tar.gz: 77f30d4b35fc7f4f29ebe2243a903d7f7876f393013fe25d274c0d6ecd97549238e4ef38bd981e39c965474930856113bd2f9f8f195c4d32af35469cd6ebfcce
6
+ metadata.gz: d95fdaf39f628c8d4a4fc0247589e92a971d0a70d8f0d406a800997a51ca5f6612d263a5904dd33197e8a6bfca6af40a8a059823ad1ff7e38a57ce28939c2219
7
+ data.tar.gz: 350f0c8ecdea1bf76449e6f3c51b2c43f9447f619e8e4c16653eb3201dbd3fa9fda5853624e3ec80ec39b31508efa72688bc881582f867a2bf8ee8fe15ee3a51
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traxor (0.1.18)
4
+ traxor (0.1.19)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -248,4 +248,4 @@ DEPENDENCIES
248
248
  traxor!
249
249
 
250
250
  BUNDLED WITH
251
- 1.16.1
251
+ 1.16.4
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A tool for logging ruby application performance metrics to the [Akkeris](https://github.com/akkeris) platform.
4
4
 
5
- Supported Gems:
5
+ Supported Frameworks:
6
6
 
7
7
  - Rack
8
8
  - Sidekiq
@@ -17,7 +17,7 @@ How does this help me?
17
17
  It logs things that help you troubleshoot performance issues. Just some of the things it can help with:
18
18
 
19
19
  - How much time is spent in rack middleware?
20
- - Are requests getting backed up in the [queue](https://devcenter.heroku.com/articles/http-routing#heroku-headers)
20
+ - Are requests getting backed up in the [queue](https://devcenter.heroku.com/articles/http-routing#heroku-headers)?
21
21
  - How many ActiveRecord models are loaded in a request?
22
22
  - Which sidekiq jobs are the slowest?
23
23
  - How much time is being spent in calls to external services?
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- traxor (0.1.18)
4
+ traxor (0.1.19)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -249,4 +249,4 @@ DEPENDENCIES
249
249
  traxor!
250
250
 
251
251
  BUNDLED WITH
252
- 1.16.1
252
+ 1.16.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- traxor (0.1.18)
4
+ traxor (0.1.19)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -249,4 +249,4 @@ DEPENDENCIES
249
249
  traxor!
250
250
 
251
251
  BUNDLED WITH
252
- 1.16.1
252
+ 1.16.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- traxor (0.1.18)
4
+ traxor (0.1.19)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -249,4 +249,4 @@ DEPENDENCIES
249
249
  traxor!
250
250
 
251
251
  BUNDLED WITH
252
- 1.16.1
252
+ 1.16.4
@@ -18,7 +18,9 @@ module Traxor
18
18
  end
19
19
  end
20
20
 
21
- ActiveSupport::Notifications.subscribe('request.faraday') do |*args|
22
- event = ActiveSupport::Notifications::Event.new(*args)
23
- Traxor::Faraday.record(event)
21
+ if Traxor.enabled? && Traxor.scopes.include?(:faraday)
22
+ ActiveSupport::Notifications.subscribe('request.faraday') do |*args|
23
+ event = ActiveSupport::Notifications::Event.new(*args)
24
+ Traxor::Faraday.record(event)
25
+ end
24
26
  end
data/lib/traxor/metric.rb CHANGED
@@ -27,6 +27,8 @@ module Traxor
27
27
  end
28
28
 
29
29
  def self.log(string)
30
+ return unless Traxor.enabled?
31
+
30
32
  logger.info(normalize_values(string))
31
33
  end
32
34
 
@@ -38,12 +38,14 @@ module Traxor
38
38
  end
39
39
  end
40
40
 
41
- ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |*args|
42
- event = ActiveSupport::Notifications::Event.new(*args)
43
- Traxor::Rails::ActionController.set_controller_tags(event)
44
- end
41
+ if Traxor.enabled? && Traxor.scopes.include?(:action_controller)
42
+ ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |*args|
43
+ event = ActiveSupport::Notifications::Event.new(*args)
44
+ Traxor::Rails::ActionController.set_controller_tags(event)
45
+ end
45
46
 
46
- ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
47
- event = ActiveSupport::Notifications::Event.new(*args)
48
- Traxor::Rails::ActionController.record(event)
47
+ ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
48
+ event = ActiveSupport::Notifications::Event.new(*args)
49
+ Traxor::Rails::ActionController.record(event)
50
+ end
49
51
  end
@@ -15,7 +15,9 @@ module Traxor
15
15
  end
16
16
  end
17
17
 
18
- ActiveSupport::Notifications.subscribe 'deliver.action_mailer' do |*args|
19
- event = ActiveSupport::Notifications::Event.new(*args)
20
- Traxor::Rails::ActionMailer.record(event)
18
+ if Traxor.enabled? && Traxor.scopes.include?(:action_mailer)
19
+ ActiveSupport::Notifications.subscribe 'deliver.action_mailer' do |*args|
20
+ event = ActiveSupport::Notifications::Event.new(*args)
21
+ Traxor::Rails::ActionMailer.record(event)
22
+ end
21
23
  end
@@ -36,12 +36,14 @@ module Traxor
36
36
  end
37
37
  end
38
38
 
39
- ActiveSupport::Notifications.subscribe 'sql.active_record' do |*args|
40
- event = ActiveSupport::Notifications::Event.new(*args)
41
- Traxor::Rails::ActiveRecord.record(event)
42
- end
39
+ if Traxor.enabled? && Traxor.scopes.include?(:active_record)
40
+ ActiveSupport::Notifications.subscribe 'sql.active_record' do |*args|
41
+ event = ActiveSupport::Notifications::Event.new(*args)
42
+ Traxor::Rails::ActiveRecord.record(event)
43
+ end
43
44
 
44
- ActiveSupport::Notifications.subscribe 'instantiation.active_record' do |*args|
45
- event = ActiveSupport::Notifications::Event.new(*args)
46
- Traxor::Rails::ActiveRecord.record_instantiations(event)
45
+ ActiveSupport::Notifications.subscribe 'instantiation.active_record' do |*args|
46
+ event = ActiveSupport::Notifications::Event.new(*args)
47
+ Traxor::Rails::ActiveRecord.record_instantiations(event)
48
+ end
47
49
  end
@@ -10,28 +10,34 @@ module Traxor
10
10
  Traxor.initialize_logger(::Rails.root.join('log', 'traxor.log'))
11
11
  end
12
12
 
13
- require 'traxor/rack'
14
- app.config.middleware.insert 0, Traxor::Rack::Middleware::Pre
15
- app.config.middleware.use Traxor::Rack::Middleware::Post
13
+ if Traxor.enabled?
14
+ if Traxor.scopes.include?(:rack)
15
+ require 'traxor/rack'
16
+ app.config.middleware.insert 0, Traxor::Rack::Middleware::Pre
17
+ app.config.middleware.use Traxor::Rack::Middleware::Post
18
+ end
16
19
 
17
- ActiveSupport.on_load :action_controller do
18
- require 'traxor/rails/action_controller'
19
- end
20
- ActiveSupport.on_load :active_record do
21
- require 'traxor/rails/active_record'
22
- end
23
- ActiveSupport.on_load :action_mailer do
24
- require 'traxor/rails/action_mailer'
20
+ ActiveSupport.on_load :action_controller do
21
+ require 'traxor/rails/action_controller'
22
+ end
23
+ ActiveSupport.on_load :active_record do
24
+ require 'traxor/rails/active_record'
25
+ end
26
+ ActiveSupport.on_load :action_mailer do
27
+ require 'traxor/rails/action_mailer'
28
+ end
25
29
  end
26
30
  end
27
31
 
28
32
  config.before_configuration do
29
- require 'traxor/faraday' if defined?(Faraday)
33
+ if Traxor.enabled?
34
+ require 'traxor/faraday' if defined?(Faraday)
30
35
 
31
- if defined?(Sidekiq)
32
- require 'traxor/sidekiq'
33
- ::Sidekiq.server_middleware do |chain|
34
- chain.add Traxor::Sidekiq
36
+ if defined?(Sidekiq) && Traxor.scopes.include?(:sidekiq)
37
+ require 'traxor/sidekiq'
38
+ ::Sidekiq.server_middleware do |chain|
39
+ chain.add Traxor::Sidekiq
40
+ end
35
41
  end
36
42
  end
37
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Traxor
4
- VERSION = '0.1.18'
4
+ VERSION = '0.1.19'
5
5
  end
data/lib/traxor.rb CHANGED
@@ -1,15 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
- require 'traxor/faraday' if defined?(Faraday)
5
- require 'traxor/metric'
6
- require 'traxor/rack' if defined?(Rack)
7
- require 'traxor/rails' if defined?(Rails::Engine)
8
- require 'traxor/sidekiq' if defined?(Sidekiq)
9
- require 'traxor/tags'
10
- require 'traxor/version'
4
+ require 'active_support/core_ext/object/blank'
11
5
 
12
6
  module Traxor
7
+ DEFAULT_SCOPES = 'rack,action_controller,action_mailer,active_record,faraday,sidekiq'
8
+
13
9
  def self.logger
14
10
  defined?(@logger) ? @logger : initialize_logger
15
11
  end
@@ -21,4 +17,25 @@ module Traxor
21
17
  end
22
18
  @logger
23
19
  end
20
+
21
+ def self.enabled?
22
+ @enabled ||= ENV.fetch('TRAXOR_ENABLED', true).present?
23
+ end
24
+
25
+ def self.scopes
26
+ @scopes ||= ENV
27
+ .fetch('TRAXOR_SCOPES', DEFAULT_SCOPES)
28
+ .to_s
29
+ .downcase
30
+ .split(',')
31
+ .map(&:to_sym)
32
+ end
24
33
  end
34
+
35
+ require 'traxor/faraday' if defined?(Faraday)
36
+ require 'traxor/metric'
37
+ require 'traxor/rack' if defined?(Rack)
38
+ require 'traxor/rails' if defined?(Rails::Engine)
39
+ require 'traxor/sidekiq' if defined?(Sidekiq)
40
+ require 'traxor/tags'
41
+ require 'traxor/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traxor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hansen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -278,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
278
  version: '0'
279
279
  requirements: []
280
280
  rubyforge_project:
281
- rubygems_version: 2.7.6
281
+ rubygems_version: 2.7.7
282
282
  signing_key:
283
283
  specification_version: 4
284
284
  summary: Log metrics to akkeris platform