logjam_agent 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -22,10 +22,11 @@ module LogjamAgent
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def start_request(env)
|
25
|
-
app_name
|
26
|
-
env_name
|
27
|
-
caller_id
|
28
|
-
|
25
|
+
app_name = env["logjam_agent.application_name"] || LogjamAgent.application_name
|
26
|
+
env_name = env["logjam_agent.environment_name"] || LogjamAgent.environment_name
|
27
|
+
caller_id = env["HTTP_X_LOGJAM_CALLER_ID"] || ""
|
28
|
+
caller_action = env["HTTP_X_LOGJAM_ACTION"] || ""
|
29
|
+
Rails.logger.start_request(app_name, env_name, :caller_id => caller_id, :caller_action => caller_action)
|
29
30
|
end
|
30
31
|
|
31
32
|
def finish_request(env)
|
@@ -35,10 +35,9 @@ module LogjamAgent
|
|
35
35
|
|
36
36
|
def after_dispatch(env, result, run_time_ms)
|
37
37
|
status = result ? result.first : 500
|
38
|
-
|
38
|
+
_, additions, view_time, _ = Thread.current.thread_variable_get(:time_bandits_completed_info)
|
39
39
|
|
40
|
-
|
41
|
-
request_info = {:total_time => run_time_ms, :code => status, :action => action_name, :view_time => view_time || 0.0}
|
40
|
+
request_info = {:total_time => run_time_ms, :code => status, :view_time => view_time || 0.0}
|
42
41
|
|
43
42
|
message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % run_time_ms
|
44
43
|
message << " (#{additions.join(' | ')})" unless additions.blank?
|
@@ -114,3 +113,31 @@ module LogjamAgent
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
end
|
116
|
+
|
117
|
+
# patch the actioncontroller logsubscriber to set the action on the logjam logger as soon as it starts processing the request
|
118
|
+
require 'action_controller/metal/instrumentation'
|
119
|
+
require 'action_controller/log_subscriber'
|
120
|
+
|
121
|
+
module ActionController #:nodoc:
|
122
|
+
|
123
|
+
class LogSubscriber
|
124
|
+
def start_processing(event)
|
125
|
+
payload = event.payload
|
126
|
+
params = payload[:params].except(*INTERNAL_PARAMS)
|
127
|
+
format = payload[:format]
|
128
|
+
format = format.to_s.upcase if format.is_a?(Symbol)
|
129
|
+
|
130
|
+
controller = payload[:controller]
|
131
|
+
action = payload[:action]
|
132
|
+
full_name = "#{controller}##{action}"
|
133
|
+
action_name = LogjamAgent.action_name_proc.call(full_name)
|
134
|
+
|
135
|
+
# puts "setting logjam action to #{action_name}"
|
136
|
+
Rails.logger.request.fields[:action] = action_name
|
137
|
+
|
138
|
+
info "Processing by #{full_name} as #{format}"
|
139
|
+
info " Parameters: #{params.inspect}" unless params.empty?
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
data/lib/logjam_agent/request.rb
CHANGED
@@ -6,7 +6,7 @@ end
|
|
6
6
|
|
7
7
|
module LogjamAgent
|
8
8
|
class Request
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :fields
|
10
10
|
|
11
11
|
def initialize(app, env, logger, initial_fields)
|
12
12
|
@logger = logger
|
@@ -27,6 +27,10 @@ module LogjamAgent
|
|
27
27
|
@fields[:caller_id]
|
28
28
|
end
|
29
29
|
|
30
|
+
def caller_action
|
31
|
+
@fields[:caller_action]
|
32
|
+
end
|
33
|
+
|
30
34
|
def add_line(severity, timestamp, message)
|
31
35
|
@mutex.synchronize do
|
32
36
|
@lines << [severity, format_time(timestamp), message.strip]
|
data/lib/logjam_agent/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stefan Kaes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-05-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|