module GoodData::ContextManager
Public Instance Methods
Source
# File lib/gooddata/bricks/middleware/context_manager.rb, line 34 def context(now = Time.now) time_specific_context = action ? { :time => time_from_action_start(now) } : {} @context.merge(time_specific_context) end
Return current brick context extended with time specific information
@param [Time] now, allows to specify exact time, when outer call was performed @return [Hash] Brick context
Source
# File lib/gooddata/bricks/middleware/context_manager.rb, line 61 def end_action(logger = nil) GoodData::LCM2::Helpers.fail_if_development 'No matching action to start found' unless action logger.info '' if logger self.status = :not_in_action self.action = nil end
Ends currently opened lcm action
@param [Logger] logger, logger that should log current context info
Source
# File lib/gooddata/bricks/middleware/context_manager.rb, line 18 def initialize_context @action_start = Time.now # :log_v is used to differentiate new versions of logs in splunk @context = { :api_version => GoodData.version, :log_v => 0, :component => 'lcm.ruby', :status => :not_in_action } end
Source
# File lib/gooddata/bricks/middleware/context_manager.rb, line 49 def start_action(next_action, logger = nil, now = Time.now) GoodData::LCM2::Helpers.fail_if_development 'An action is already being profiled' if action self.action = next_action @action_start = now logger.info '' if logger self.status = :action_in_progress end
Starts lcm action
@param [String] action, name of the action @param [Logger] logger, logger that should log current context info @param [Time] now, allows to specify exact time, when outer call was performed
Source
# File lib/gooddata/bricks/middleware/context_manager.rb, line 39 def time_from_action_start(now = Time.now) GoodData::LCM2::Helpers.fail_if_development 'No action is being profiled' unless action (now - @action_start) * 1000 end