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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/traxor/rails/action_controller.rb +3 -0
- data/lib/traxor/rails.rb +0 -5
- data/lib/traxor/version.rb +1 -1
- metadata +1 -3
- data/lib/traxor/rack/middleware/post.rb +0 -19
- data/lib/traxor/rack/middleware/pre.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cedd3c6bbff0b1550fed56d2bbbc8aa6d3aa4381b26441ab9382e0cd79ad9d95
|
4
|
+
data.tar.gz: f3c9c247555018ba407bc8390a1d42d19153e1df8b4db259e180d8ece047d9d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc091b94559ec5463d6b1c9ec7133518847305e536fa043ef9b26ec115f2decf36b04a2c77ac4d5e81c60d3bf703a0127abd4143e81eb8533a6dcf39d9f4f25
|
7
|
+
data.tar.gz: 9227bb0baf351efeef9b2364c2c38dd3d3153c5e8c185d2cdf9ceb4bd9415587386dcf63c149d067afac8add77ec6ccc14cf462f05da3e8f38f0092facde92d2
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/traxor/version.rb
CHANGED
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.
|
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
|