Class: Fiveruns::Dash::Session
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Instance Method Summary collapse
- #add_exception(exception, sample = nil) ⇒ Object
- #data ⇒ Object
- #exception_data ⇒ Object
- #exception_recorder ⇒ Object
- #exceptions ⇒ Object
- #info ⇒ Object
-
#initialize(configuration) ⇒ Session
constructor
A new instance of Session.
- #metric_metadata ⇒ Object
- #recipe_metadata ⇒ Object
- #reset ⇒ Object
- #start(background = true, &block) ⇒ Object
-
#trace(name) ⇒ Object
Trace and send metric collection.
Constructor Details
#initialize(configuration) ⇒ Session
Returns a new instance of Session.
6 7 8 9 10 11 |
# File 'lib/fiveruns/dash/session.rb', line 6 def initialize(configuration) @configuration = configuration # eager create the host data in the main thread # as it is dangerous to load in the reporter thread Fiveruns::Dash.host end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/fiveruns/dash/session.rb', line 5 def configuration @configuration end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
5 6 7 |
# File 'lib/fiveruns/dash/session.rb', line 5 def reporter @reporter end |
Instance Method Details
#add_exception(exception, sample = nil) ⇒ Object
31 32 33 |
# File 'lib/fiveruns/dash/session.rb', line 31 def add_exception(exception, sample=nil) exception_recorder.record(exception, sample) end |
#data ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/fiveruns/dash/session.rb', line 59 def data real_data = configuration.metrics.map { |metric| metric.data }.compact virtual_data = configuration.metrics.map { |metric| metric.calculate(real_data) }.compact # Return any metrics which are not abstract and should be sent to the server metric_payload = (real_data + virtual_data).find_all { |data| !data[:abstract] } #puts "Sending #{metric_payload.map { |met| [met[:name], met[:values].size] }.inspect} metrics" metric_payload end |
#exception_data ⇒ Object
68 69 70 |
# File 'lib/fiveruns/dash/session.rb', line 68 def exception_data exception_recorder.data end |
#exception_recorder ⇒ Object
72 73 74 |
# File 'lib/fiveruns/dash/session.rb', line 72 def exception_recorder @exception_recorder ||= ExceptionRecorder.new(self) end |
#exceptions ⇒ Object
18 19 20 |
# File 'lib/fiveruns/dash/session.rb', line 18 def exceptions @exceptions ||= [] end |
#info ⇒ Object
35 36 37 38 39 40 |
# File 'lib/fiveruns/dash/session.rb', line 35 def info { :recipes => , :metric_infos => } end |
#metric_metadata ⇒ Object
48 49 50 51 52 |
# File 'lib/fiveruns/dash/session.rb', line 48 def configuration.metrics.inject([]) do |metrics, metric| metrics << metric.info end end |
#recipe_metadata ⇒ Object
42 43 44 45 46 |
# File 'lib/fiveruns/dash/session.rb', line 42 def configuration.recipes.inject([]) do |recipes, recipe| recipes << recipe.info end end |
#reset ⇒ Object
54 55 56 57 |
# File 'lib/fiveruns/dash/session.rb', line 54 def reset exception_recorder.reset configuration.metrics.each { |m| m.reset } end |