Class: Profiler::ProfilesController

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

Instance Method Summary collapse

Instance Method Details

#cacheObject



57
58
59
60
61
62
# File 'app/controllers/profiler/profiles_controller.rb', line 57

def cache
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  render json: @profile.collector_data("cache")
end

#databaseObject



43
44
45
46
47
48
# File 'app/controllers/profiler/profiles_controller.rb', line 43

def database
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  render json: @profile.collector_data("database")
end

#flamegraphObject



71
72
73
74
75
76
# File 'app/controllers/profiler/profiles_controller.rb', line 71

def flamegraph
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  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



64
65
66
67
68
69
# File 'app/controllers/profiler/profiles_controller.rb', line 64

def performance
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  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 = resolve_profile(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
40
41
# File 'app/controllers/profiler/profiles_controller.rb', line 36

def timeline
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  render json: @profile.collector_data("performance")
end

#viewsObject



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

def views
  @profile = resolve_profile(params[:id])
  return render plain: "Profile not found", status: :not_found unless @profile

  render json: @profile.collector_data("view")
end