Module: PartnerService::Reservations::Exports::ProgressTracker::PerformanceMonitor

Defined in:
app/services/partner_service/reservations/exports/progress_tracker.rb

Overview

Performance monitoring for export operations

Instance Method Summary collapse

Instance Method Details

#track_phase_performance(phase, start_time, end_time, additional_metrics = {}) ⇒ Object

Track performance metrics for export phases

Parameters:

  • phase (Symbol)

    Export phase

  • start_time (Time)

    Phase start time

  • end_time (Time)

    Phase end time

  • additional_metrics (Hash) (defaults to: {})

    Additional metrics to track



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 107

def track_phase_performance(phase, start_time, end_time, additional_metrics = {})
  duration = end_time - start_time

  metrics = {
    phase: phase.to_s,
    duration_seconds: duration.round(3),
    start_time: start_time.iso8601,
    end_time: end_time.iso8601,
  }.merge(additional_metrics)

  # Log performance metrics
  BUSINESS_LOGGER.info('Export phase performance', {
    attachment_id: @export_tracker&.attachment&.id,
    restaurant_id: @export_tracker&.attachment&.restaurant_id,
    report_type: @export_tracker&.attachment&.report_type,
  }.merge(metrics))

  # Store metrics for analysis
  store_performance_metrics(metrics)
end

#track_throughput(items_processed, duration_seconds, item_type = 'items') ⇒ Object

Calculate and log throughput metrics

Parameters:

  • items_processed (Integer)

    Number of items processed

  • duration_seconds (Float)

    Time taken in seconds

  • item_type (String) (defaults to: 'items')

    Type of items (e.g., 'reservations', 'rows')



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'app/services/partner_service/reservations/exports/progress_tracker.rb', line 133

def track_throughput(items_processed, duration_seconds, item_type = 'items')
  return if duration_seconds <= 0

  throughput = items_processed / duration_seconds

  BUSINESS_LOGGER.info('Export throughput', {
                         attachment_id: @export_tracker&.attachment&.id,
                         items_processed: items_processed,
                         duration_seconds: duration_seconds.round(3),
                         throughput_per_second: throughput.round(2),
                         item_type: item_type,
                       })
end