Class: InsightAgent
- Inherits:
-
Object
- Object
- InsightAgent
- Defined in:
- lib/agent/insight_agent.rb
Overview
Rails entry point for the insight-agent
Constant Summary collapse
- @@dispatcher =
nil- @@events =
Hash of eventId => EventTree
{}
Instance Method Summary collapse
-
#initialize(app, url, user, pass) ⇒ InsightAgent
constructor
A new instance of InsightAgent.
- #initialize_active_support ⇒ Object
- #initialize_plugins ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(app, url, user, pass) ⇒ InsightAgent
Returns a new instance of InsightAgent.
7 8 9 10 11 12 13 |
# File 'lib/agent/insight_agent.rb', line 7 def initialize(app, url, user, pass) @@dispatcher = TraceDispatcher.new(url, user, pass) TraceBuilder.instance.setApplication(app) @@dispatcher.start puts "dispatcher started" initialize_active_support() end |
Instance Method Details
#initialize_active_support ⇒ Object
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 |
# File 'lib/agent/insight_agent.rb', line 20 def initialize_active_support() # Subscribe to every event in the system ActiveSupport::Notifications.subscribe do |name, start, finish, id, payload| #puts id + " " + name + " " + start.to_f.to_s + "->" + finish.to_f.to_s eventTree = @@events[id] if eventTree == nil eventTree = EventTree.new @@events[id] = eventTree end # All properties should be simple strings properties = {} payload.each { |key, value| properties[key] = value.to_s } # Effectively endpoint analyzers; events are collected by id # until the event with the name, "process_action.action_controller" # at that point the events are dumped into a trace/frame stack and # stored on the TraceQueue. # TODO: # - Deletes on the model do not seem to be picked up here # - If a series of events are collected which do not end # with this named event, a dud EventTree could be sitting # around in the hash if name == "process_action.action_controller" label = payload[:path] eventTree.addEvent(name, label, start, finish, properties) trace = eventTree.dumpFrames TraceQueue.instance.addTrace(trace) @@events[id] = nil else eventTree.addEvent(name, name, start, finish, properties) end end end |
#initialize_plugins ⇒ Object
15 16 17 18 |
# File 'lib/agent/insight_agent.rb', line 15 def initialize_plugins() # load a series of plugins from a known location end |
#stop ⇒ Object
56 57 58 |
# File 'lib/agent/insight_agent.rb', line 56 def stop @@dispatcher.stop end |