Class: APMInsight::Agent::SequenceBook
- Inherits:
-
Object
- Object
- APMInsight::Agent::SequenceBook
- Defined in:
- lib/agent/handler/sequence_book.rb
Instance Attribute Summary collapse
-
#exceptionBag ⇒ Object
readonly
Returns the value of attribute exceptionBag.
-
#listenFlag ⇒ Object
readonly
Returns the value of attribute listenFlag.
-
#openTracker ⇒ Object
readonly
Returns the value of attribute openTracker.
-
#rootTracker ⇒ Object
readonly
Returns the value of attribute rootTracker.
-
#trackerCount ⇒ Object
readonly
Returns the value of attribute trackerCount.
Instance Method Summary collapse
- #addExceptionInfo(exception) ⇒ Object
- #attachTracker(tracker) ⇒ Object
- #checkAndArrestSequence ⇒ Object
- #closeSequence ⇒ Object
- #closeTracker(tracker) ⇒ Object
- #createDummyTracker ⇒ Object
-
#initialize ⇒ SequenceBook
constructor
A new instance of SequenceBook.
- #updateListenFlag ⇒ Object
Constructor Details
#initialize ⇒ SequenceBook
Returns a new instance of SequenceBook.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/agent/handler/sequence_book.rb', line 8 def initialize @rootTracker = nil #@closedTracker = @rootTracker @openTracker = nil @trackerCount = 0 @closedTrackerCount = 0 @listenFlag = -1 # @exceptionBag = Array.new end |
Instance Attribute Details
#exceptionBag ⇒ Object (readonly)
Returns the value of attribute exceptionBag.
6 7 8 |
# File 'lib/agent/handler/sequence_book.rb', line 6 def exceptionBag @exceptionBag end |
#listenFlag ⇒ Object (readonly)
Returns the value of attribute listenFlag.
6 7 8 |
# File 'lib/agent/handler/sequence_book.rb', line 6 def listenFlag @listenFlag end |
#openTracker ⇒ Object (readonly)
Returns the value of attribute openTracker.
6 7 8 |
# File 'lib/agent/handler/sequence_book.rb', line 6 def openTracker @openTracker end |
#rootTracker ⇒ Object (readonly)
Returns the value of attribute rootTracker.
6 7 8 |
# File 'lib/agent/handler/sequence_book.rb', line 6 def rootTracker @rootTracker end |
#trackerCount ⇒ Object (readonly)
Returns the value of attribute trackerCount.
6 7 8 |
# File 'lib/agent/handler/sequence_book.rb', line 6 def trackerCount @trackerCount end |
Instance Method Details
#addExceptionInfo(exception) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/agent/handler/sequence_book.rb', line 93 def addExceptionInfo(exception) begin if @exceptionBag == nil @exceptionBag = Set.new end if (@exceptionBag.size() < 10) exceptionRecord = ::APMInsight::Errors::ExceptionRecord.new(exception) @exceptionBag.add(exceptionRecord) end rescue Exception=>e end end |
#attachTracker(tracker) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/agent/handler/sequence_book.rb', line 19 def attachTracker tracker if tracker == nil return nil end # If RootTracker is not set, check type and set if @rootTracker == nil if !tracker.is_a?(ManageEngine::Tracker::RootTracker) closeSequence() return nil end @rootTracker = tracker updateListenFlag() end tracker.setParent(openTracker) @openTracker = tracker # Attach tracker as Sibling or Child and set nominee # if @closedTracker != nil # tracker.sibling = @closedTracker # @closedTracker.sibling = tracker # Nominee - if dropped/corrupted, defaults to this tracker # @openTracker = tracker # @closedTracker = nil # else # if tracker.equal?(@openTracker) # return nil # end # # @openTracker.child = tracker # tracker.sibling = @openTracker # @openTracker = tracker # end checkAndArrestSequence() return tracker end |
#checkAndArrestSequence ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/agent/handler/sequence_book.rb', line 114 def checkAndArrestSequence @trackerCount += 1 if @trackerCount == 1000 @listenFlag = 1 end ## Can check for timeout end |
#closeSequence ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/agent/handler/sequence_book.rb', line 85 def closeSequence @rootTracker = nil @openTracker = @closedTracker = nil @trackerCount = 0 @closedTrackerCount = 0 Thread.current[:apminsight] = nil end |
#closeTracker(tracker) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/agent/handler/sequence_book.rb', line 59 def closeTracker tracker # @closedTrackerCount += 1 # @closedTracker = tracker # tracker.sibling = nil # @openTracker = nil @openTracker = tracker.parent; # Marks end of transaction # if @rootTracker == tracker if @openTracker == nil if @listenFlag < 1 || (@listenFlag >= 1 && @trackerCount > 0) # if some trackers are not closed, while processing the metrics, it may go into infinite loop # if (@closedTrackerCount - @trackerCount) == 0 sequenceBag = Hash.new sequenceBag["roottracker"] = @rootTracker sequenceBag["exceptions"] = @exceptionBag ManageEngine::APMObjectHolder.instance.collector.updateTransaction(@rootTracker.url, sequenceBag) # else # ManageEngine::APMObjectHolder.instance.log.warn "Some trackers are not closed, dropping the metrics for #{@rootTracker.url}" # end end closeSequence() end end |
#createDummyTracker ⇒ Object
123 124 125 |
# File 'lib/agent/handler/sequence_book.rb', line 123 def createDummyTracker return ManageEngine::Tracker::DefaultTracker.new("dummy") end |
#updateListenFlag ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/agent/handler/sequence_book.rb', line 106 def updateListenFlag if !ManageEngine::APMObjectHolder.instance.txn_util.listen?(@rootTracker.url()) @listenFlag = 1 end ## Check for sampling factor & for bg txn chk if enabled end |