traxor 0.1.3 → 0.1.4

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: d6a5f1c3f6e8e601f0e10067aff36a1c98043ed5a1e9f67d2a29c0c93a4a00c5
4
- data.tar.gz: e8570fa252f2b6540bdc1da0e6af33a761815f11d30a945930bf89131501078a
3
+ metadata.gz: cedd3c6bbff0b1550fed56d2bbbc8aa6d3aa4381b26441ab9382e0cd79ad9d95
4
+ data.tar.gz: f3c9c247555018ba407bc8390a1d42d19153e1df8b4db259e180d8ece047d9d4
5
5
  SHA512:
6
- metadata.gz: '09b00e3b1bb0f3c090a52c1b31c94ea94216dd590b1cf4a93f328a5213505f39236b18011b8df1ad4e85264059242ae9436f83fd9c8ae5022738341bb36b394c'
7
- data.tar.gz: e03db5db0aa0c3b4e519fd365b007768af5208f6acca8ed0cafd6a537c488123039e44a208bb3f0f61f8a787a10903dd56fc914033e2f0631c66ad1eef7759e2
6
+ metadata.gz: 0cc091b94559ec5463d6b1c9ec7133518847305e536fa043ef9b26ec115f2decf36b04a2c77ac4d5e81c60d3bf703a0127abd4143e81eb8533a6dcf39d9f4f25
7
+ data.tar.gz: 9227bb0baf351efeef9b2364c2c38dd3d3153c5e8c185d2cdf9ceb4bd9415587386dcf63c149d067afac8add77ec6ccc14cf462f05da3e8f38f0092facde92d2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traxor (0.1.3)
4
+ traxor (0.1.4)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -16,6 +16,9 @@ module Traxor
16
16
  Metric.count 'rails.action_controller.count', 1, tags
17
17
  Metric.count "rails.action_controller.count.#{controller_path}", 1, tags
18
18
 
19
+ Metric.measure 'rails.action_controller.total.duration', "#{duration.to_f.round(2)}ms", tags
20
+ Metric.measure "rails.action_controller.total.duration.#{controller_path}", "#{duration.to_f.round(2)}ms", tags
21
+
19
22
  Metric.measure 'rails.action_controller.ruby.duration', "#{ruby_runtime.to_f.round(2)}ms", tags
20
23
  Metric.measure "rails.action_controller.ruby.duration.#{controller_path}", "#{ruby_runtime.to_f.round(2)}ms", tags
21
24
 
data/lib/traxor/rails.rb CHANGED
@@ -5,11 +5,6 @@ module Traxor
5
5
  config.logger = ::Rails.logger
6
6
  end
7
7
 
8
- require 'traxor/rack/middleware/pre'
9
- require 'traxor/rack/middleware/post'
10
- app.config.middleware.insert 0, Traxor::Rack::Middleware::Pre
11
- app.config.middleware.use Traxor::Rack::Middleware::Post
12
-
13
8
  ActiveSupport.on_load :action_controller do
14
9
  require 'traxor/rails/action_controller'
15
10
  end
@@ -1,3 +1,3 @@
1
1
  module Traxor
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traxor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hansen
@@ -217,8 +217,6 @@ files:
217
217
  - lib/traxor.rb
218
218
  - lib/traxor/faraday.rb
219
219
  - lib/traxor/metric.rb
220
- - lib/traxor/rack/middleware/post.rb
221
- - lib/traxor/rack/middleware/pre.rb
222
220
  - lib/traxor/rails.rb
223
221
  - lib/traxor/rails/action_controller.rb
224
222
  - lib/traxor/rails/action_mailer.rb
@@ -1,19 +0,0 @@
1
- module Traxor
2
- module Rack
3
- module Middleware
4
- class Post
5
- def initialize(app)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env['traxor.rack.middleware.pre_middleware_end'] = Time.now.to_f
11
- status, headers, response = @app.call(env)
12
- env['traxor.rack.middleware.post_middleware_start'] = Time.now.to_f
13
-
14
- [status, headers, response]
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,51 +0,0 @@
1
- module Traxor
2
- module Rack
3
- module Middleware
4
- class Pre
5
- def initialize(app)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env['traxor.rack.middleware.pre_middleware_start'] = Time.now.to_f
11
- status, headers, body = @app.call(env)
12
- env['traxor.rack.middleware.post_middleware_end'] = Time.now.to_f
13
-
14
- controller = env['action_controller.instance']
15
- times = [
16
- 'traxor.rack.middleware.pre_middleware_start',
17
- 'traxor.rack.middleware.pre_middleware_end',
18
- 'traxor.rack.middleware.post_middleware_start',
19
- 'traxor.rack.middleware.post_middleware_end'
20
- ]
21
-
22
- tags = {}
23
-
24
- if times.all? { |t| env[t].present? }
25
- pre_time = (env['traxor.rack.middleware.pre_middleware_end'].to_f - env['traxor.rack.middleware.pre_middleware_start'].to_f)
26
- post_time = (env['traxor.rack.middleware.post_middleware_end'].to_f - env['traxor.rack.middleware.post_middleware_start'].to_f)
27
- middleware_time = (pre_time + post_time) * 1_000
28
- total_time = (env['traxor.rack.middleware.post_middleware_end'].to_f - env['traxor.rack.middleware.pre_middleware_start'].to_f) * 1_000
29
-
30
- if controller
31
- method = env['REQUEST_METHOD'].to_s
32
- tags = { controller: Traxor.normalize_name(controller.class), action: Traxor.normalize_name(controller.action_name), method: Traxor.normalize_name(method) }
33
- controller_path = tags.values.join('.')
34
-
35
- Metric.measure 'rack.request.middleware.duration', "#{middleware_time.round(2)}ms", tags
36
- Metric.measure "rack.request.middleware.duration.#{controller_path}", "#{middleware_time.round(2)}ms", tags
37
- Metric.measure "rack.request.duration.#{controller_path}", "#{total_time.round(2)}ms", tags
38
- Metric.count "rack.request.count.#{controller_path}", 1, tags
39
- end
40
-
41
- Metric.measure 'rack.request.duration', "#{total_time.round(2)}ms", tags
42
- end
43
-
44
- Metric.count 'rack.request.count', 1, tags
45
-
46
- [status, headers, body]
47
- end
48
- end
49
- end
50
- end
51
- end