Class: Findbug::PerformanceController

Inherits:
ApplicationController show all
Defined in:
app/controllers/findbug/performance_controller.rb

Overview

PerformanceController handles performance metrics views.

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /findbug/performance

Performance overview with slowest endpoints.



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/findbug/performance_controller.rb', line 11

def index
  @since = parse_since(params[:since] || "24h")

  @slowest = Findbug::PerformanceEvent.slowest_transactions(since: @since, limit: 20)
  @n_plus_one = Findbug::PerformanceEvent.n_plus_one_hotspots(since: @since, limit: 10)
  @throughput = Findbug::PerformanceEvent.throughput_over_time(since: @since)
  @stats = calculate_stats(@since)

  render template: "findbug/performance/index", layout: "findbug/application"
end

#showObject

GET /findbug/performance/:id

Show details for a specific transaction type.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/findbug/performance_controller.rb', line 26

def show
  @transaction_name = params[:id]
  @since = parse_since(params[:since] || "24h")

  # Get events for this transaction
  @events = Findbug::PerformanceEvent.where(transaction_name: @transaction_name)
                            .where("captured_at >= ?", @since)
                            .recent
                            .limit(100)

  # Calculate aggregates
  @stats = Findbug::PerformanceEvent.aggregate_for(@transaction_name, since: @since)

  # Get slowest individual requests
  @slowest_requests = @events.order(duration_ms: :desc).limit(10)

  # Get requests with N+1 issues
  @n_plus_one_requests = @events.where(has_n_plus_one: true).limit(10)

  render template: "findbug/performance/show", layout: "findbug/application"
end