lib/rackamole/mole.rb in rackamole-0.2.9 vs lib/rackamole/mole.rb in rackamole-0.3.0
- old
+ new
@@ -80,11 +80,11 @@
# Watches incoming requests and report usage information. The mole will also track request that
# are taking longer than expected and also report any requests that are raising exceptions.
def call( env )
# Bail if application is not moleable
return @app.call( env ) unless moleable?
-
+
@stash = env['mole.stash'] if env['mole.stash']
@stash = Rackamole::Stash::Collector.new( options[:app_name], options[:environment], options[:expiration] ) unless stash
status, headers, body = nil
elapsed = Hitimes::Interval.measure do
@@ -156,11 +156,11 @@
return if attrs.empty?
# send info to configured store
options[:store].mole( attrs )
- # Check for dups. If we've logged this req before don't log it again...
+ # Check for dups. If we've reported this req before don't report it again...
unless duplicated?( env, attrs )
# send email alert ?
if alertable?( :email, attrs[:type] )
logger.debug ">>> Sending out email on mole type #{attrs[:type]} to #{options[:email][:to].join( ", ")}"
Rackamole::Alert::Emole.deliver_alert( logger, options, attrs )
@@ -287,15 +287,19 @@
mole?( :body , info, response.body ) if response
# Gather up browser and client machine info
agent_info = Rackamole::Utils::AgentDetect.parse( user_agent )
%w(browser machine).each { |type| mole?(type.to_sym, info, agent_info[type.to_sym] ) }
-
+
# Dump request params
unless request.params.empty?
info[:params] = filter_params( request.params, options[:param_excludes] || [] )
end
+ if route
+ info[:params] ||= {}
+ info[:params].merge!( filter_params( params_from_route( route ), options[:param_excludes] || [] ) )
+ end
# Dump session var
if session and !session.empty?
info[:session] = filter_params( session, options[:session_excludes] || [] )
end
@@ -308,9 +312,20 @@
info[:stack] = trim_stack( exception )
info[:type] = Rackamole.fault
env['mole.exception'] = nil
end
info
+ end
+
+ # Parse out rails request params if in rails env
+ def params_from_route( route )
+ params = {}
+ except = [:controller, :action]
+ route.each_pair do |k,v|
+ next if except.include?( k )
+ params[k] = v
+ end
+ params
end
# check exclusion to see if the information should be moled
def mole?( key, stash, value )
# puts "Checking #{key} -- #{options[:mole_excludes].inspect}"
\ No newline at end of file