Class: Appsignal::Span Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object private
- #add_error(error) ⇒ Object private
- #child ⇒ Object private
- #close ⇒ Object private
- #closed? ⇒ Boolean private
-
#initialize(namespace = nil, ext = nil) ⇒ Span
constructor
private
A new instance of Span.
- #instrument ⇒ Object private
- #name=(value) ⇒ Object private
- #set_sample_data(key, data) ⇒ Object private
- #to_h ⇒ Object private
Constructor Details
#initialize(namespace = nil, ext = nil) ⇒ Span
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Span.
6 7 8 |
# File 'lib/appsignal/span.rb', line 6 def initialize(namespace = nil, ext = nil) @ext = ext || Appsignal::Extension::Span.root(namespace || "") end |
Instance Method Details
#[]=(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/appsignal/span.rb', line 43 def []=(key, value) case value when String @ext.set_attribute_string(key.to_s, value) when Integer begin @ext.set_attribute_int(key.to_s, value) rescue RangeError @ext.set_attribute_string(key.to_s, "bigint:#{value}") end when TrueClass, FalseClass @ext.set_attribute_bool(key.to_s, value) when Float @ext.set_attribute_double(key.to_s, value) else raise TypeError, "value needs to be a string, int, bool or float" end end |
#add_error(error) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/appsignal/span.rb', line 18 def add_error(error) unless error.is_a?(Exception) Appsignal.internal_logger.error "Appsignal::Span#add_error: Cannot " \ "add error. The given value is not an exception: #{error.inspect}" return end return unless error backtrace = cleaned_backtrace(error.backtrace) @ext.add_error( error.class.name, error..to_s, backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new ) end |
#child ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/appsignal/span.rb', line 10 def child Span.new(nil, @ext.child) end |
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 |
# File 'lib/appsignal/span.rb', line 75 def close @ext.close end |
#closed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/appsignal/span.rb', line 79 def closed? to_h.nil? end |
#instrument ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 73 |
# File 'lib/appsignal/span.rb', line 69 def instrument yield self ensure close end |
#name=(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/appsignal/span.rb', line 14 def name=(value) @ext.set_name(value) end |
#set_sample_data(key, data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 41 |
# File 'lib/appsignal/span.rb', line 34 def set_sample_data(key, data) return unless key && data && (data.is_a?(Array) || data.is_a?(Hash)) @ext.set_sample_data( key.to_s, Appsignal::Utils::Data.generate(data) ) end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 65 66 67 |
# File 'lib/appsignal/span.rb', line 62 def to_h json = @ext.to_json return unless json JSON.parse(json) end |