Class: Appsignal::JSExceptionTransaction
- Inherits:
-
Object
- Object
- Appsignal::JSExceptionTransaction
- Defined in:
- lib/appsignal/js_exception_transaction.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #complete! ⇒ Object
-
#initialize(data) ⇒ JSExceptionTransaction
constructor
A new instance of JSExceptionTransaction.
- #set_action ⇒ Object
- #set_error ⇒ Object
- #set_metadata ⇒ Object
- #set_sample_data ⇒ Object
Constructor Details
#initialize(data) ⇒ JSExceptionTransaction
Returns a new instance of JSExceptionTransaction.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/appsignal/js_exception_transaction.rb', line 5 def initialize(data) @data = data @uuid = SecureRandom.uuid @ext = Appsignal::Extension.start_transaction(@uuid, Appsignal::Transaction::FRONTEND) set_action set_error set_sample_data end |
Instance Attribute Details
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
3 4 5 |
# File 'lib/appsignal/js_exception_transaction.rb', line 3 def ext @ext end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
3 4 5 |
# File 'lib/appsignal/js_exception_transaction.rb', line 3 def uuid @uuid end |
Instance Method Details
#complete! ⇒ Object
52 53 54 55 |
# File 'lib/appsignal/js_exception_transaction.rb', line 52 def complete! @ext.finish @ext.complete end |
#set_action ⇒ Object
16 17 18 |
# File 'lib/appsignal/js_exception_transaction.rb', line 16 def set_action @ext.set_action(@data['action']) end |
#set_error ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/appsignal/js_exception_transaction.rb', line 26 def set_error @ext.set_error( @data['name'], @data['message'], Appsignal::Utils.json_generate(@data['backtrace']) ) end |
#set_metadata ⇒ Object
20 21 22 23 24 |
# File 'lib/appsignal/js_exception_transaction.rb', line 20 def @ext.( 'path', @data['path'] ) if @data['path'] end |
#set_sample_data ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/appsignal/js_exception_transaction.rb', line 34 def set_sample_data { :params => @data['params'], :environment => @data['environment'], :tags => @data['tags'] }.each do |key, data| next unless data.is_a?(Array) || data.is_a?(Hash) begin @ext.set_sample_data( key.to_s, Appsignal::Utils.json_generate(data) ) rescue *Appsignal::Transaction::JSON_EXCEPTIONS => e Appsignal.logger.error("Error generating JSON (#{e.class}: #{e.}) for '#{backtrace.inspect}'") end end end |