Module: AppProfiler

Defined in:
lib/app_profiler/server.rb,
lib/app_profiler.rb,
lib/app_profiler/profile.rb,
lib/app_profiler/railtie.rb,
lib/app_profiler/version.rb,
lib/app_profiler/profiler.rb,
lib/app_profiler/middleware.rb,
lib/app_profiler/parameters.rb,
lib/app_profiler/yarn/command.rb,
lib/app_profiler/request_parameters.rb,
lib/app_profiler/viewer/base_viewer.rb,
lib/app_profiler/storage/base_storage.rb,
lib/app_profiler/storage/file_storage.rb,
lib/app_profiler/yarn/with_speedscope.rb,
lib/app_profiler/middleware/base_action.rb,
lib/app_profiler/middleware/view_action.rb,
lib/app_profiler/middleware/upload_action.rb,
lib/app_profiler/viewer/speedscope_viewer.rb,
lib/app_profiler/storage/google_cloud_storage.rb,
lib/app_profiler/viewer/speedscope_remote_viewer.rb,
lib/app_profiler/viewer/speedscope_remote_viewer/middleware.rb,
lib/app_profiler/viewer/speedscope_remote_viewer/base_middleware.rb

Overview

This module provides a means to start a golang-inspired profile server it is implemented using stdlib and Rack to avoid additional dependencies

Defined Under Namespace

Modules: Server, Storage, Viewer, Yarn Classes: ConfigurationError, Middleware, Parameters, Profile, Railtie, RequestParameters

Constant Summary collapse

DefaultProfileFormatter =
proc do |upload|
  "#{AppProfiler.speedscope_host}#profileURL=#{upload.url}"
end
DefaultProfilePrefix =
proc do
  Time.zone.now.strftime("%Y%m%d-%H%M%S")
end
VERSION =
"0.1.8"

Class Method Summary collapse

Class Method Details

.after_process_queue=(handler) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/app_profiler.rb', line 110

def after_process_queue=(handler)
  if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 2))
    raise ArgumentError, "after_process_queue must be a proc or a lambda that accepts two arguments"
  end

  @@after_process_queue = handler # rubocop:disable Style/ClassVars
end

.profile_data_headerObject



86
87
88
# File 'lib/app_profiler.rb', line 86

def profile_data_header
  @@profile_data_header ||= profile_header.dup << "-Data" # rubocop:disable Style/ClassVars
end

.profile_enqueue_failure=(handler) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/app_profiler.rb', line 102

def profile_enqueue_failure=(handler)
  if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 1))
    raise ArgumentError, "profile_enqueue_failure must be a proc or a lambda that accepts one argument"
  end

  @@profile_enqueue_failure = handler # rubocop:disable Style/ClassVars
end

.profile_enqueue_success=(handler) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/app_profiler.rb', line 94

def profile_enqueue_success=(handler)
  if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 0))
    raise ArgumentError, "profile_enqueue_success must be proc or a lambda that accepts no argument"
  end

  @@profile_enqueue_success = handler # rubocop:disable Style/ClassVars
end

.profile_header=(profile_header) ⇒ Object



76
77
78
79
80
# File 'lib/app_profiler.rb', line 76

def profile_header=(profile_header)
  @@profile_header = profile_header # rubocop:disable Style/ClassVars
  @@request_profile_header = nil    # rubocop:disable Style/ClassVars
  @@profile_data_header = nil       # rubocop:disable Style/ClassVars
end

.profile_url(upload) ⇒ Object



118
119
120
121
122
# File 'lib/app_profiler.rb', line 118

def profile_url(upload)
  return unless AppProfiler.profile_url_formatter

  AppProfiler.profile_url_formatter.call(upload)
end

.profile_url_formatter=(block) ⇒ Object



90
91
92
# File 'lib/app_profiler.rb', line 90

def profile_url_formatter=(block)
  @@profile_url_formatter = block # rubocop:disable Style/ClassVars
end

.request_profile_headerObject



82
83
84
# File 'lib/app_profiler.rb', line 82

def request_profile_header
  @@request_profile_header ||= profile_header.upcase.tr("-", "_").prepend("HTTP_") # rubocop:disable Style/ClassVars
end

.run(*args, &block) ⇒ Object



63
64
65
# File 'lib/app_profiler.rb', line 63

def run(*args, &block)
  Profiler.run(*args, &block)
end

.start(*args) ⇒ Object



67
68
69
# File 'lib/app_profiler.rb', line 67

def start(*args)
  Profiler.start(*args)
end

.stopObject



71
72
73
74
# File 'lib/app_profiler.rb', line 71

def stop
  Profiler.stop
  Profiler.results
end