Class: ManageEngine::Tracker::DefaultTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/agent/trackers/default_tracker.rb

Direct Known Subclasses

DatabaseTracker, RootTracker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "unknown", time = ManageEngine::APMObjectHolder.instance.util.currenttimemillis) ⇒ DefaultTracker

Returns a new instance of DefaultTracker.



8
9
10
11
12
13
14
# File 'lib/agent/trackers/default_tracker.rb', line 8

def initialize(name = "unknown", time = ManageEngine::APMObjectHolder.instance.util.currenttimemillis)
  @starttime = time.to_i
  @name = name
  @component = "APP CODE"
  @children = Array.new
  @logger = ManageEngine::APMObjectHolder.instance.log
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def children
  @children
end

#componentObject

Returns the value of attribute component.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def component
  @component
end

#endtimeObject

Returns the value of attribute endtime.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def endtime
  @endtime
end

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def error
  @error
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def name
  @name
end

#parentObject

Returns the value of attribute parent.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def parent
  @parent
end

#starttimeObject

Returns the value of attribute starttime.



6
7
8
# File 'lib/agent/trackers/default_tracker.rb', line 6

def starttime
  @starttime
end

Instance Method Details

#==(obj) ⇒ Object



52
53
54
# File 'lib/agent/trackers/default_tracker.rb', line 52

def ==(obj)
  return obj != nil && @name == obj.name
end

#durationObject



43
44
45
46
47
48
49
50
# File 'lib/agent/trackers/default_tracker.rb', line 43

def duration
  begin
    (@endtime - @starttime).to_i
  rescue Exception=>e
    @logger.warn "Name: #{name} Starttime: #{starttime} Endtime: #{endtime}"
    raise e
  end
end

#error?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/agent/trackers/default_tracker.rb', line 31

def error?
  @error != nil
end

#finish(time = ManageEngine::APMObjectHolder.instance.util.currenttimemillis) ⇒ Object



16
17
18
# File 'lib/agent/trackers/default_tracker.rb', line 16

def finish(time = ManageEngine::APMObjectHolder.instance.util.currenttimemillis)
  @endtime = time.to_i
end

#getAdditionalInfoObject



64
65
66
67
68
69
70
# File 'lib/agent/trackers/default_tracker.rb', line 64

def getAdditionalInfo
  if error?
    {ManageEngine::APMObjectHolder.instance.constants.mf_exception_st => ManageEngine::APMObjectHolder.instance.util.formatStacktrace(@error.backtrace)}
  else
    nil
  end
end

#getTraceObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/agent/trackers/default_tracker.rb', line 72

def getTrace
  trace = Array.new(7)
  trace[0] = @starttime
  trace[1] = @name
  trace[2] = @component
  trace[3] = duration()
  trace[4] = trace[3] #exclusive time
  trace[5] = getAdditionalInfo()
  if (children.length > 0)
    trace[6] = Array.new
    children.each do |child|
      trace[4] -= child.duration() #computing exclusive time of parent
      trace[6].push(child.getTrace())
    end
  end # children exists check
  trace
end

#hashObject



56
57
58
# File 'lib/agent/trackers/default_tracker.rb', line 56

def hash
  return @name.hash
end

#setError(exception) ⇒ Object



35
36
37
# File 'lib/agent/trackers/default_tracker.rb', line 35

def setError(exception)
  @error = exception
end

#setName(context) ⇒ Object



39
40
41
# File 'lib/agent/trackers/default_tracker.rb', line 39

def setName(context)
  @name = context
end

#setParent(parentTracker) ⇒ Object



20
21
22
23
24
25
# File 'lib/agent/trackers/default_tracker.rb', line 20

def setParent(parentTracker)
  @parent = parentTracker
  if parentTracker != nil
    parentTracker.children[parentTracker.children.length]=self
  end
end

#to_sObject



60
61
62
# File 'lib/agent/trackers/default_tracker.rb', line 60

def to_s
  @name
end