traxor 0.1.16 → 0.1.17

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
  SHA256:
3
- metadata.gz: f653d55d85f92371818f8b7b54b042b2f3f5a22ff0132c79bd188b6394275e3f
4
- data.tar.gz: 59b6e815cdba3b93aa754e5bceefd992a7f38c6112615ea9c0cf1ff9dcb0fcaf
3
+ metadata.gz: 2fe3fcda84fda172b21244d7b16fac08c989c226611e40975f6b8345405054a0
4
+ data.tar.gz: 37a553b7fe9e3972c8634758762ccee699154794423693d47457feba000ed685
5
5
  SHA512:
6
- metadata.gz: 0cdda8a4bd223a5eed22fc3069db8669c492e36f8d45a18ff85a1ded44a3c5db8d855b2b4c6ab3e13dfa9deb8b75f2ba90f14292858eed6a0efcae3530bac901
7
- data.tar.gz: 92c9a20fac4f19a625659b2e74b6b4a9b6096d4d562897130aef16f2843b7214cb5df907a1a27839511af1b9bc881c3dbeaf94213cd44a02b14555914a58bccc
6
+ metadata.gz: 6d3429761f18b3ed1c06d5a1446efad8a9b82939ffa83b4ea201d187a740202155987575ead5ff7af561052344312c063121df525963a019110188550daf5b5d
7
+ data.tar.gz: 19b4916aceb4cbcb70a71ec3350bc18ba3679e0c61cb336dd4cee1baa93c58223c87207de112094440c916ed118d349a9d33a824c4cc15724a3b41366017fd89
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traxor (0.1.16)
4
+ traxor (0.1.17)
5
5
  activesupport
6
+ rails (>= 4.2)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -12,7 +12,10 @@ module Traxor
12
12
  Middleware.request_start_at = QueueTime.parse(env)
13
13
 
14
14
  Middleware.pre_start_at = Time.now.utc
15
+ GC::Profiler.enable
16
+ Middleware.gc_stat_before = GC.stat
15
17
  status, headers, body = @app.call(env)
18
+ Middleware.gc_stat_after = GC.stat
16
19
  Middleware.post_finish_at = Time.now.utc
17
20
 
18
21
  record_metrics
@@ -25,6 +28,14 @@ module Traxor
25
28
  Metric.measure 'rack.request.duration'.freeze, "#{Middleware.request_total.round(2)}ms" if Middleware.request_total.positive?
26
29
  Metric.measure 'rack.request.queue.duration'.freeze, "#{Middleware.request_queue_total.round(2)}ms" if Middleware.request_queue_total.positive?
27
30
  Metric.count 'rack.request.count'.freeze, 1
31
+
32
+ Metric.measure 'ruby.gc.duration'.freeze, "#{(GC::Profiler.total_time * 1_000).to_f.round(2)}ms"
33
+ Metric.count 'ruby.gc.count'.freeze, Middleware.gc_count
34
+ Metric.count 'ruby.gc.major.count'.freeze, Middleware.gc_major_count
35
+ Metric.count 'ruby.gc.minor.count'.freeze, Middleware.gc_minor_count
36
+ Metric.count 'ruby.gc.allocated_objects.count'.freeze, Middleware.gc_allocated_objects_count
37
+
38
+ GC::Profiler.clear
28
39
  end
29
40
  end
30
41
  end
@@ -8,7 +8,9 @@ module Traxor
8
8
  :pre_finish_at,
9
9
  :post_start_at,
10
10
  :post_finish_at,
11
- :request_start_at
11
+ :request_start_at,
12
+ :gc_stat_before,
13
+ :gc_stat_after
12
14
 
13
15
  def self.time_before
14
16
  return 0 unless pre_start_at
@@ -37,6 +39,22 @@ module Traxor
37
39
 
38
40
  (pre_start_at.to_f - request_start_at.to_f) * 1_000
39
41
  end
42
+
43
+ def self.gc_count
44
+ gc_stat_after[:count].to_i - gc_stat_before[:count].to_i
45
+ end
46
+
47
+ def self.gc_major_count
48
+ gc_stat_after[:major_gc_count].to_i - gc_stat_before[:major_gc_count].to_i
49
+ end
50
+
51
+ def self.gc_minor_count
52
+ gc_stat_after[:minor_gc_count].to_i - gc_stat_before[:minor_gc_count].to_i
53
+ end
54
+
55
+ def self.gc_allocated_objects_count
56
+ gc_stat_after[:total_allocated_objects].to_i - gc_stat_before[:total_allocated_objects].to_i
57
+ end
40
58
  end
41
59
  end
42
60
  end
data/lib/traxor/rails.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'traxor/rack'
2
-
3
1
  module Traxor
4
2
  class Rails < ::Rails::Engine
5
3
  initializer 'traxor.setup'.freeze do |app|
@@ -7,6 +5,7 @@ module Traxor
7
5
  Traxor.initialize_logger(::Rails.root.join('log'.freeze, 'traxor.log'.freeze))
8
6
  end
9
7
 
8
+ require 'traxor/rack'
10
9
  app.config.middleware.insert 0, Traxor::Rack::Middleware::Pre
11
10
  app.config.middleware.use Traxor::Rack::Middleware::Post
12
11
 
@@ -1,3 +1,3 @@
1
1
  module Traxor
2
- VERSION = '0.1.16'.freeze
2
+ VERSION = '0.1.17'.freeze
3
3
  end
data/lib/traxor.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'logger'
2
- require 'traxor/faraday' if defined?(Faraday)
2
+ require 'rails'
3
3
  require 'traxor/metric'
4
- require 'traxor/rack' if defined?(Rack)
5
- require 'traxor/rails' if defined?(Rails::Engine)
6
- require 'traxor/sidekiq' if defined?(Sidekiq)
4
+ require 'traxor/rails'
7
5
  require 'traxor/tags'
8
6
  require 'traxor/version'
9
7
 
data/traxor.gemspec CHANGED
@@ -20,7 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
+ spec.required_ruby_version = '>= 2.2'
24
+
23
25
  spec.add_dependency 'activesupport'
26
+ spec.add_dependency 'rails', '>= 4.2'
24
27
 
25
28
  spec.add_development_dependency 'bundler'
26
29
  spec.add_development_dependency 'faraday'
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.16
4
+ version: 0.1.17
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-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -272,7 +286,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
286
  requirements:
273
287
  - - ">="
274
288
  - !ruby/object:Gem::Version
275
- version: '0'
289
+ version: '2.2'
276
290
  required_rubygems_version: !ruby/object:Gem::Requirement
277
291
  requirements:
278
292
  - - ">="