Class: Profiler::ProfilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/profiler/profiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#cacheObject



51
52
53
54
# File 'app/controllers/profiler/profiles_controller.rb', line 51

def cache
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("cache")
end

#databaseObject



41
42
43
44
# File 'app/controllers/profiler/profiles_controller.rb', line 41

def database
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("database")
end

#flamegraphObject



61
62
63
64
# File 'app/controllers/profiler/profiles_controller.rb', line 61

def flamegraph
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("flamegraph")
end

#indexObject



7
8
9
10
11
12
13
# File 'app/controllers/profiler/profiles_controller.rb', line 7

def index
  limit = params[:limit]&.to_i || 50
  offset = params[:offset]&.to_i || 0

  @profiles = Profiler.storage.list(limit: limit, offset: offset)
  @profiles = filter_profiles(@profiles) if params[:filter].present?
end

#performanceObject



56
57
58
59
# File 'app/controllers/profiler/profiles_controller.rb', line 56

def performance
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("performance")
end

#showObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/profiler/profiles_controller.rb', line 15

def show
  @profile = Profiler.storage.load(params[:id])

  unless @profile
    render plain: "Profile not found", status: :not_found
    return
  end

  # Recalculate AJAX collector data (since AJAX requests happen after page load)
  recalculate_ajax_data(@profile)

  @profile_data = @profile.to_h.merge(
    child_jobs: build_child_jobs(@profile),
    parent_profile: build_parent_summary(@profile)
  )

  @embedded = params[:embed] == "true"

  render layout: @embedded ? "profiler/embedded" : "profiler/application"
end

#timelineObject



36
37
38
39
# File 'app/controllers/profiler/profiles_controller.rb', line 36

def timeline
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("performance")
end

#viewsObject



46
47
48
49
# File 'app/controllers/profiler/profiles_controller.rb', line 46

def views
  @profile = Profiler.storage.load(params[:id])
  render json: @profile.collector_data("view")
end