lib/appsignal/transaction.rb in appsignal-1.2.5 vs lib/appsignal/transaction.rb in appsignal-1.3.0.beta.1
- old
+ new
@@ -179,19 +179,36 @@
def start_event
@ext.start_event
end
- def finish_event(name, title, body, body_format)
+ def finish_event(name, title, body, body_format=Appsignal::EventFormatter::DEFAULT)
@ext.finish_event(
name,
title || BLANK,
body || BLANK,
- body_format || 0
+ body_format || Appsignal::EventFormatter::DEFAULT
)
end
+ def record_event(name, title, body, duration, body_format=Appsignal::EventFormatter::DEFAULT)
+ @ext.record_event(
+ name,
+ title || BLANK,
+ body || BLANK,
+ duration,
+ body_format || Appsignal::EventFormatter::DEFAULT
+ )
+ end
+
+ def instrument(name, title=nil, body=nil, body_format=Appsignal::EventFormatter::DEFAULT)
+ start_event
+ r = yield
+ finish_event(name, title, body, body_format)
+ r
+ end
+
class GenericRequest
attr_reader :env
def initialize(env)
@env = env
@@ -229,22 +246,26 @@
end
def sanitized_params
return unless Appsignal.config[:send_params]
return unless request.respond_to?(options[:params_method])
- begin
- return unless params = request.send(options[:params_method])
- rescue Exception => ex
- # Getting params from the request has been know to fail.
- Appsignal.logger.debug "Exception while getting params: #{ex}"
- return
+
+ params =
+ begin
+ request.send options[:params_method]
+ rescue Exception => ex
+ # Getting params from the request has been know to fail.
+ Appsignal.logger.debug "Exception while getting params: #{ex}"
+ nil
+ end
+ return unless params
+
+ options = {}
+ if Appsignal.config[:filter_parameters]
+ options[:filter_parameters] = Appsignal.config[:filter_parameters]
end
- if params.is_a?(Hash)
- Appsignal::ParamsSanitizer.sanitize(params)
- elsif params.is_a?(Array)
- params
- end
+ Appsignal::Utils::ParamsSanitizer.sanitize params, options
end
def sanitized_environment
return unless request.env
{}.tap do |out|
@@ -255,11 +276,11 @@
end
def sanitized_session_data
return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session)
return unless session = request.session
- Appsignal::ParamsSanitizer.sanitize(session.to_hash)
+ Appsignal::Utils::ParamsSanitizer.sanitize(session.to_hash)
end
def metadata
return unless request.env
request.env[:metadata]
@@ -270,11 +291,11 @@
# * Value is a symbol or string with less then 100 chars
# * Value is an integer
def sanitized_tags
@tags.select do |k, v|
(k.is_a?(Symbol) || k.is_a?(String) && k.length <= 100) &&
- (((v.is_a?(Symbol) || v.is_a?(String)) && v.length <= 100) || (v.is_a?(Integer)))
+ (((v.is_a?(Symbol) || v.is_a?(String)) && v.length <= 100) || (v.is_a?(Integer)))
end
end
def cleaned_backtrace(backtrace)
if defined?(::Rails) && backtrace
@@ -286,9 +307,14 @@
# Stub that is returned by `Transaction.current` if there is no current transaction, so
# that it's still safe to call methods on it if there is none.
class NilTransaction
def method_missing(m, *args, &block)
+ end
+
+ # Instrument should still yield
+ def instrument(*args)
+ yield
end
def nil_transaction?
true
end