class Mnemosyne::Trace

Constants

BT_REGEXP
Error

Attributes

errors[R]
origin[R]
span[R]
transaction[R]
uuid[R]

Public Class Methods

new(instrumenter, name, transaction: nil, origin: nil, **kwargs) click to toggle source
Calls superclass method Mnemosyne::Span::new
# 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

Public Instance Methods

<<(span) click to toggle source
# File lib/mnemosyne/trace.rb, line 22
def <<(span)
  @span << span
end
attach_error(error) click to toggle source
# 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() click to toggle source
# File lib/mnemosyne/trace.rb, line 43
def release
  @instrumenter.release self
end
serialize() click to toggle source
# File lib/mnemosyne/trace.rb, line 47
def serialize
  {
    uuid: uuid,
    origin: origin,
    transaction: transaction,
    name: name,
    start: start,
    stop: finish,
    meta: meta,
    span: @span.map(&:serialize),
    errors: @errors.map(&:serialize)
  }
end
submit() click to toggle source
# File lib/mnemosyne/trace.rb, line 37
def submit
  finish! unless finish

  @instrumenter.submit self
end