reportsmash 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reportsmash/engine/transaction.rb +1 -2
- data/lib/reportsmash/engine/transaction.rb~ +116 -0
- data/lib/reportsmash/version.rb +1 -1
- data/lib/reportsmash/version.rb~ +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6a2e361441ac51e42db6603aa00f9e91c0abd8a
|
4
|
+
data.tar.gz: 0b56f90a9bcf219ae89699ae5454206a161e4e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e180024c55614e74a246ee4a493412c669f6a508868676b9b9f5e55c3e2a838dd0c80ad3c9183b547bc464d25e7a697ec951d520e7f2fb25c7ebfdedb482292
|
7
|
+
data.tar.gz: d2bde30cc76bfdb3047ca736ee35a464a5daa00c1c272fedf5d6a3d505039ce2aff1ad3c747ce4dc7272d930a169918e5519fff3b667da57d3aa6d38d63bed51
|
@@ -39,7 +39,7 @@ module ReportsMash::Engine
|
|
39
39
|
@total_duration_ms = (stop_time - start_time) * 1000.0
|
40
40
|
path_params = @request["action_dispatch.request.path_parameters"]
|
41
41
|
controller_action = "static_file_server"
|
42
|
-
if path_params.key?(:controller) && path_params.key?(:action)
|
42
|
+
if path_params && path_params.key?(:controller) && path_params.key?(:action)
|
43
43
|
controller_action = path_params[:controller]+"#"+path_params[:action]
|
44
44
|
end
|
45
45
|
|
@@ -106,7 +106,6 @@ module ReportsMash::Engine
|
|
106
106
|
:external_http_requests => @external_http_requests,
|
107
107
|
:external_memcache_requests => @memcached_stats,
|
108
108
|
:external_redis_requests => @redis_stats,
|
109
|
-
|
110
109
|
:custom_attributes => @user_params
|
111
110
|
}
|
112
111
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module ReportsMash::Engine
|
2
|
+
class Transaction
|
3
|
+
attr_accessor :user_params
|
4
|
+
attr_accessor :payload
|
5
|
+
attr_accessor :db_transactions, :db_duration_ms, :render_transactions, :render_duration_ms
|
6
|
+
attr_accessor :external_http_requests, :external_http_duration_ms
|
7
|
+
attr_accessor :memcached_ops, :redis_ops
|
8
|
+
|
9
|
+
def initialize(engine, request)
|
10
|
+
@engine = engine
|
11
|
+
@request = request
|
12
|
+
@response = nil
|
13
|
+
@tid = SecureRandom.uuid
|
14
|
+
@user_params = []
|
15
|
+
@start_time = nil
|
16
|
+
@total_duration_ms = 0
|
17
|
+
@db_duration_ms = 0
|
18
|
+
@render_duration_ms = 0
|
19
|
+
@payload = {}
|
20
|
+
@db_transactions = []
|
21
|
+
@render_transactions = []
|
22
|
+
@external_http_requests = []
|
23
|
+
@external_http_duration_ms = 0
|
24
|
+
@memcached_ops = []
|
25
|
+
@redis_ops = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def tid
|
29
|
+
@tid
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_user_params(new_params)
|
33
|
+
@user_params.merge!(new_params) if new_params.is_a? Hash
|
34
|
+
end
|
35
|
+
|
36
|
+
def end(start_time, stop_time, status_code, headers)
|
37
|
+
@start_time = start_time
|
38
|
+
response_content_type = (headers && headers["Content-Type"]) ? headers["Content-Type"] : ""
|
39
|
+
@total_duration_ms = (stop_time - start_time) * 1000.0
|
40
|
+
path_params = @request["action_dispatch.request.path_parameters"]
|
41
|
+
controller_action = "static_file_server"
|
42
|
+
if path_params.key?(:controller) && path_params.key?(:action)
|
43
|
+
controller_action = path_params[:controller]+"#"+path_params[:action]
|
44
|
+
end
|
45
|
+
|
46
|
+
@memcached_stats = {}
|
47
|
+
mc_duration_ms = 0
|
48
|
+
mc_counter = 0
|
49
|
+
if @memcached_ops.count > 0
|
50
|
+
%w[get set get_multi].each do |op|
|
51
|
+
stat = {count: 0, duration_ms: 0, avg_ms: 0}
|
52
|
+
@memcached_ops.select{|h| h.key? op.to_sym}.each do |trace|
|
53
|
+
stat[:count] += 1
|
54
|
+
stat[:duration_ms] += trace[op.to_sym]
|
55
|
+
stat[:avg_ms] = (stat[:duration_ms]/Float(stat[:count])).round(2)
|
56
|
+
@memcached_stats[op.to_sym] = stat
|
57
|
+
mc_duration_ms += stat[:duration_ms]
|
58
|
+
mc_counter += 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
#puts "GOT MC_OPS #{@memcached_ops.inspect}: #{@memcached_stats.inspect}"
|
62
|
+
end
|
63
|
+
|
64
|
+
@redis_stats = {}
|
65
|
+
redis_duration_ms = 0
|
66
|
+
redis_counter = 0
|
67
|
+
if @redis_ops.count > 0
|
68
|
+
%w[get set].each do |op|
|
69
|
+
stat = {count: 0, duration_ms: 0, avg_ms: 0}
|
70
|
+
@redis_ops.select{|h| h.key? op.to_sym}.each do |trace|
|
71
|
+
stat[:count] += 1
|
72
|
+
stat[:duration_ms] += trace[op.to_sym]
|
73
|
+
stat[:avg_ms] = (stat[:duration_ms]/Float(stat[:count])).round(2)
|
74
|
+
@redis_stats[op.to_sym] = stat
|
75
|
+
redis_duration_ms += stat[:duration_ms]
|
76
|
+
redis_counter += 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
#puts "GOT REDIS_OPS #{@redis_ops.inspect}: #{@redis_stats.inspect}"
|
80
|
+
end
|
81
|
+
|
82
|
+
@payload = {
|
83
|
+
:time_utc => @start_time.utc.to_i,
|
84
|
+
:user_ip => @request["REMOTE_ADDR"],
|
85
|
+
:user_agent => @request["HTTP_USER_AGENT"],
|
86
|
+
:method => @request["REQUEST_METHOD"],
|
87
|
+
:http_host => @request["HTTP_HOST"],
|
88
|
+
:request_uri => @request["REQUEST_URI"],
|
89
|
+
:request_path => @request["REQUEST_PATH"],
|
90
|
+
:controller_action => controller_action,
|
91
|
+
:response_content_type => response_content_type,
|
92
|
+
:status => status_code,
|
93
|
+
:total_duration_ms => @total_duration_ms.round(2),
|
94
|
+
:db_duration_ms => @db_duration_ms.round(2),
|
95
|
+
:render_duration_ms => @render_duration_ms.round(2),
|
96
|
+
:external_http_duration_ms => @external_http_duration_ms.round(2),
|
97
|
+
:external_memcache_duration_ms => mc_duration_ms.round(2),
|
98
|
+
:external_redis_duration_ms => redis_duration_ms.round(2),
|
99
|
+
:db_counter => @db_transactions.count,
|
100
|
+
:render_counter => @render_transactions.count,
|
101
|
+
:external_http_counter => @external_http_requests.count,
|
102
|
+
:external_memcache_counter => mc_counter,
|
103
|
+
:external_redis_counter => redis_counter,
|
104
|
+
:db_transactions => @db_transactions,
|
105
|
+
:render_transactions => @render_transactions,
|
106
|
+
:external_http_requests => @external_http_requests,
|
107
|
+
:external_memcache_requests => @memcached_stats,
|
108
|
+
:external_redis_requests => @redis_stats,
|
109
|
+
|
110
|
+
:custom_attributes => @user_params
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
data/lib/reportsmash/version.rb
CHANGED
data/lib/reportsmash/version.rb~
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reportsmash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zeljko Tomic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/reportsmash/engine/thread_state.rb
|
80
80
|
- lib/reportsmash/engine/threading.rb
|
81
81
|
- lib/reportsmash/engine/transaction.rb
|
82
|
+
- lib/reportsmash/engine/transaction.rb~
|
82
83
|
- lib/reportsmash/engine/worker.rb
|
83
84
|
- lib/reportsmash/engine/worker.rb~
|
84
85
|
- lib/reportsmash/rack.rb
|