Class: RailsPulse::SummaryService

Inherits:
Object
  • Object
show all
Defined in:
app/services/rails_pulse/summary_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(period_type, start_time) ⇒ SummaryService

Returns a new instance of SummaryService.



6
7
8
9
10
# File 'app/services/rails_pulse/summary_service.rb', line 6

def initialize(period_type, start_time)
  @period_type = period_type
  @start_time = Summary.normalize_period_start(period_type, start_time)
  @end_time = Summary.calculate_period_end(period_type, @start_time)
end

Instance Attribute Details

#end_timeObject (readonly)

Returns the value of attribute end_time.



4
5
6
# File 'app/services/rails_pulse/summary_service.rb', line 4

def end_time
  @end_time
end

#period_typeObject (readonly)

Returns the value of attribute period_type.



4
5
6
# File 'app/services/rails_pulse/summary_service.rb', line 4

def period_type
  @period_type
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



4
5
6
# File 'app/services/rails_pulse/summary_service.rb', line 4

def start_time
  @start_time
end

Instance Method Details

#performObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/rails_pulse/summary_service.rb', line 12

def perform
  Rails.logger.info "[RailsPulse] Starting #{period_type} summary for #{start_time}"

  ActiveRecord::Base.transaction do
    aggregate_requests  # Overall system metrics
    aggregate_routes    # Per-route metrics
    aggregate_queries   # Per-query metrics
  end

  Rails.logger.info "[RailsPulse] Completed #{period_type} summary"
rescue => e
  Rails.logger.error "[RailsPulse] Summary failed: #{e.message}"
  raise
end