lib/appsignal/transaction.rb in appsignal-1.1.9 vs lib/appsignal/transaction.rb in appsignal-1.2.0.alpha.1
- old
+ new
@@ -1,7 +1,5 @@
-require 'json'
-
module Appsignal
class Transaction
HTTP_REQUEST = 'http_request'.freeze
BACKGROUND_JOB = 'background_job'.freeze
FRONTEND = 'frontend'.freeze
@@ -13,20 +11,12 @@
HTTP_X_REQUEST_START HTTP_X_MIDDLEWARE_START HTTP_X_QUEUE_START
HTTP_X_QUEUE_TIME HTTP_X_HEROKU_QUEUE_WAIT_TIME HTTP_X_APPLICATION_START
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE
HTTP_CACHE_CONTROL HTTP_CONNECTION HTTP_USER_AGENT HTTP_FROM HTTP_NEGOTIATE
- HTTP_PRAGMA HTTP_REFERER HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP HTTP_RANGE
- HTTP_X_AUTH_TOKEN)
+ HTTP_PRAGMA HTTP_REFERER HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP HTTP_RANGE)
- JSON_EXCEPTIONS = [
- IOError,
- NotImplementedError,
- JSON::GeneratorError,
- Encoding::UndefinedConversionError
- ].freeze
-
class << self
def create(id, namespace, request, options={})
# Check if we already have a running transaction
if Thread.current[:appsignal_transaction] != nil
# Log the issue and return the current transaction
@@ -136,12 +126,12 @@
Appsignal::Extension.set_transaction_sample_data(
transaction_index,
key.to_s,
Appsignal::Utils.json_generate(data)
)
- rescue *JSON_EXCEPTIONS => e
- Appsignal.logger.error("Error generating JSON (#{e.class}: #{e.message}) for '#{data.inspect}'")
+ rescue JSON::GeneratorError=>e
+ Appsignal.logger.error("JSON generate error (#{e.message}) for '#{data.inspect}'")
end
def sample_data
{
:params => sanitized_params,
@@ -164,11 +154,11 @@
transaction_index,
error.class.name,
error.message.to_s,
backtrace ? Appsignal::Utils.json_generate(backtrace) : ''
)
- rescue *JSON_EXCEPTIONS => e
- Appsignal.logger.error("Error generating JSON (#{e.class}: #{e.message}) for '#{backtrace.inspect}'")
+ rescue JSON::GeneratorError=>e
+ Appsignal.logger.error("JSON generate error (#{e.message}) for '#{backtrace.inspect}'")
end
alias_method :add_exception, :set_error
class GenericRequest
attr_reader :env