Class: Ci::RegisterJobService::Logger
- Inherits:
 - 
      Object
      
        
- Object
 - Ci::RegisterJobService::Logger
 
 
- Includes:
 - Gitlab::Utils::StrongMemoize
 
- Defined in:
 - app/services/ci/register_job_service/logger.rb
 
Constant Summary collapse
- MAX_DURATION =
 5.seconds
Class Method Summary collapse
Instance Method Summary collapse
- #commit ⇒ Object
 - 
  
    
      #initialize(runner:, destination: ::Gitlab::AppJsonLogger) {|_self| ... } ⇒ Logger 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Logger.
 - #instrument(operation, once: false) ⇒ Object
 
Constructor Details
#initialize(runner:, destination: ::Gitlab::AppJsonLogger) {|_self| ... } ⇒ Logger
Returns a new instance of Logger.
      14 15 16 17 18 19 20  | 
    
      # File 'app/services/ci/register_job_service/logger.rb', line 14 def initialize(runner:, destination: ::Gitlab::AppJsonLogger) @started_at = current_monotonic_time @runner = runner @destination = destination yield(self) if block_given? end  | 
  
Class Method Details
Instance Method Details
#commit ⇒ Object
      36 37 38 39 40 41 42 43 44 45 46 47 48  | 
    
      # File 'app/services/ci/register_job_service/logger.rb', line 36 def commit return unless log? attributes = { class: self.class.name.to_s, message: 'RegisterJobService exceeded maximum duration', total_duration_s: age, runner_id: runner.id, runner_type: runner.runner_type }.merge(observations_hash) destination.info(attributes) end  | 
  
#instrument(operation, once: false) ⇒ Object
      22 23 24 25 26 27 28 29 30 31 32 33 34  | 
    
      # File 'app/services/ci/register_job_service/logger.rb', line 22 def instrument(operation, once: false) return yield unless enabled? raise ArgumentError, 'block not given' unless block_given? op_started_at = current_monotonic_time result = yield observe(:"#{operation}_duration_s", current_monotonic_time - op_started_at, once: once) result end  |