Class: Mnemosyne::Trace
Defined Under Namespace
Classes: Error
Constant Summary collapse
- BT_REGEXP =
/^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#span ⇒ Object
readonly
Returns the value of attribute span.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Attributes inherited from Span
#finish, #meta, #name, #start, #type
Instance Method Summary collapse
- #<<(span) ⇒ Object
- #attach_error(error) ⇒ Object
-
#initialize(instrumenter, name, transaction: nil, origin: nil, **kwargs) ⇒ Trace
constructor
A new instance of Trace.
- #release ⇒ Object
- #serialize ⇒ Object
- #submit ⇒ Object
Methods inherited from Span
Constructor Details
#initialize(instrumenter, name, transaction: nil, origin: nil, **kwargs) ⇒ Trace
Returns a new instance of Trace.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mnemosyne/trace.rb', line 9 def initialize(instrumenter, name, transaction: nil, origin: nil, **kwargs) super(name, **kwargs) @uuid = ::SecureRandom.uuid @span = [] @errors = [] @origin = origin @transaction = transaction @instrumenter = instrumenter end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/mnemosyne/trace.rb', line 7 def errors @errors end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
7 8 9 |
# File 'lib/mnemosyne/trace.rb', line 7 def origin @origin end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
7 8 9 |
# File 'lib/mnemosyne/trace.rb', line 7 def span @span end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
7 8 9 |
# File 'lib/mnemosyne/trace.rb', line 7 def transaction @transaction end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
7 8 9 |
# File 'lib/mnemosyne/trace.rb', line 7 def uuid @uuid end |
Instance Method Details
#<<(span) ⇒ Object
22 23 24 |
# File 'lib/mnemosyne/trace.rb', line 22 def <<(span) @span << span end |
#attach_error(error) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mnemosyne/trace.rb', line 26 def attach_error(error) case error when Exception @errors << Error.new(error) when String @errors << Error.new(RuntimeError.new(error)) else raise ArgumentError.new "Invalid error type: #{error.inspect}" end end |
#release ⇒ Object
43 44 45 |
# File 'lib/mnemosyne/trace.rb', line 43 def release @instrumenter.release self end |
#serialize ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mnemosyne/trace.rb', line 47 def serialize { uuid:, origin:, transaction:, name:, start:, stop: finish, meta:, span: @span.map(&:serialize), errors: @errors.map(&:serialize) } end |
#submit ⇒ Object
37 38 39 40 41 |
# File 'lib/mnemosyne/trace.rb', line 37 def submit finish! unless finish @instrumenter.submit self end |