proceso-rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/proceso/middleware.rb +8 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0932393e7e50f1cf3c47d1b22e1b899f69379c8
4
- data.tar.gz: 2a5b660eeb65c1b4de77a9837080ea0433acbc6c
3
+ metadata.gz: ca1730839e3a56e64a0fa39483d1df2f31b70a60
4
+ data.tar.gz: e63dbca299acbaae43df058395c602b6bfc11465
5
5
  SHA512:
6
- metadata.gz: df5f58f5981ae148771f7761a250a28edb0d1b33c3afb24a0b5ebe2c953dce1b216192de858a2e83425fb89183b5cbfdb4e052875205e31009565a8da6475ee2
7
- data.tar.gz: c24c0ff17d03f11e7585fbfc4ad0b14e4108fdb50cf470dbcdf78bff20a6add88462a50eb22f44f002cb5e3c64d5677bd952078bab54339ae717fe8b1c7ecb1a
6
+ metadata.gz: 6744cae6d910fc86dda8837cf86fe48ed9ef1180c1e6dfc4a64d3e291af8839287162b522215c813a93e4216a68d75e45bff4ba53e9a19ecdd148450dc89a5a1
7
+ data.tar.gz: 95ddbc9ad62aea0c3dee489aa49718eb7a4ef7b95c63ad5449f897cf2f21aa1fa109679e93337695096d51cfbc8bfe3b124c9a4008c2db8c745e5fb579ad5c4a
@@ -1,3 +1,4 @@
1
+ require 'proceso/version'
1
2
  require 'rack'
2
3
 
3
4
  module Proceso
@@ -23,7 +24,7 @@ module Proceso
23
24
  end
24
25
 
25
26
  def logger
26
- @@logger ||= begin
27
+ @logger ||= begin
27
28
  Rails.configuration.logger || ActiveSupport::Logger.new(STDOUT)
28
29
  end
29
30
  end
@@ -47,10 +48,11 @@ module Proceso
47
48
  end
48
49
 
49
50
  def capture_process_usage(env)
50
- mem_1, cpu_1, resp_1 = build_process_payload
51
+ request = Rack::Request.new(env)
52
+ mem_1, cpu_1 = build_process_payload
51
53
  response = yield
52
- mem_2, cpu_2, resp_2 = build_process_payload
53
- process_payload = calculate_process_times(env, mem_1, mem_2, cpu_1, cpu_2, resp_1, resp_2)
54
+ mem_2, cpu_2 = build_process_payload
55
+ process_payload = calculate_process_usage(request, mem_1, mem_2, cpu_1, cpu_2)
54
56
  notifier.instrument(SUBSCRIPTION, process_payload)
55
57
  response
56
58
  end
@@ -58,20 +60,16 @@ module Proceso
58
60
  def build_process_payload
59
61
  mem = process.mem_size
60
62
  cpu = process.user_cpu_times
61
- resp = Time.now.to_i
62
- [mem, cpu, resp]
63
+ [mem, cpu]
63
64
  end
64
65
 
65
- def calculate_process_times(env, m1, m2, c1, c2, r1, r2)
66
+ def calculate_process_usage(req, m1, m2, c1, c2)
66
67
  mem_used = m2 - m1
67
68
  cpu_used = c2 - c2
68
- resp_time = r2 - r1
69
- req = Rack::Request.new(env)
70
69
  {
71
70
  pid: process.pid,
72
71
  mem_used: mem_used,
73
72
  cpu_used: cpu_used,
74
- resp_time: resp_time,
75
73
  request: req
76
74
  }
77
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proceso-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Goines