Class: Sleuth::Transaction

Inherits:
Struct
  • Object
show all
Defined in:
lib/sleuth/transaction.rb

Constant Summary collapse

@@running =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



12
13
14
# File 'lib/sleuth/transaction.rb', line 12

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



12
13
14
# File 'lib/sleuth/transaction.rb', line 12

def name
  @name
end

#parentObject

Returns the value of attribute parent

Returns:

  • (Object)

    the current value of parent



12
13
14
# File 'lib/sleuth/transaction.rb', line 12

def parent
  @parent
end

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



12
13
14
# File 'lib/sleuth/transaction.rb', line 12

def pid
  @pid
end

#stampObject

Returns the value of attribute stamp

Returns:

  • (Object)

    the current value of stamp



12
13
14
# File 'lib/sleuth/transaction.rb', line 12

def stamp
  @stamp
end

Class Method Details

.create(name, id, parent) ⇒ Object



16
17
18
# File 'lib/sleuth/transaction.rb', line 16

def self.create(name, id, parent)
  running[id] = new(name, id, Time.now.to_i, Process.pid, parent)
end

.message_for(*args) ⇒ Object



20
21
22
23
24
# File 'lib/sleuth/transaction.rb', line 20

def self.message_for(*args)
  event = Event.new(*args)
  transaction = running[event.transaction_id]
  transaction.message_for(event)
end

Instance Method Details

#full_nameObject



32
33
34
# File 'lib/sleuth/transaction.rb', line 32

def full_name
  "#{name}-#{id}-#{stamp}-#{pid}"
end

#message_for(event) ⇒ Object



26
27
28
29
30
# File 'lib/sleuth/transaction.rb', line 26

def message_for(event)
  parts = [event.formatted_time, event.formatted_end,
           full_name, parent || '-', event.duration, event.payload.inspect]
  "%s %s %s %s %0.4f -- %s" % parts
end