Class: Rack::MiniProfiler::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_profiler/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assets_urlObject

Returns the value of attribute assets_url.



96
97
98
# File 'lib/mini_profiler/config.rb', line 96

def assets_url
  @assets_url
end

#authorization_modeObject

Returns the value of attribute authorization_mode.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def authorization_mode
  @authorization_mode
end

#auto_injectObject

Returns the value of attribute auto_inject.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def auto_inject
  @auto_inject
end

#backtrace_ignoresObject

Returns the value of attribute backtrace_ignores.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def backtrace_ignores
  @backtrace_ignores
end

#backtrace_includesObject

Returns the value of attribute backtrace_includes.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def backtrace_includes
  @backtrace_includes
end

#backtrace_removeObject

Returns the value of attribute backtrace_remove.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def backtrace_remove
  @backtrace_remove
end

#backtrace_threshold_msObject

Returns the value of attribute backtrace_threshold_ms.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def backtrace_threshold_ms
  @backtrace_threshold_ms
end

#base_url_pathObject

Returns the value of attribute base_url_path.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def base_url_path
  @base_url_path
end

#collapse_resultsObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def collapse_results
  @collapse_results
end

#content_security_policy_nonceObject

Returns the value of attribute content_security_policy_nonce.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def content_security_policy_nonce
  @content_security_policy_nonce
end

Returns the value of attribute cookie_path.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def cookie_path
  @cookie_path
end

#disable_cachingObject

Returns the value of attribute disable_caching.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def disable_caching
  @disable_caching
end

#enable_advanced_debugging_toolsObject

Returns the value of attribute enable_advanced_debugging_tools.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def enable_advanced_debugging_tools
  @enable_advanced_debugging_tools
end

#enable_hotwire_turbo_drive_supportObject

Returns the value of attribute enable_hotwire_turbo_drive_support.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def enable_hotwire_turbo_drive_support
  @enable_hotwire_turbo_drive_support
end

#enabledObject

Returns the value of attribute enabled.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def enabled
  @enabled
end

#flamegraph_ignore_gcObject

Returns the value of attribute flamegraph_ignore_gc.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def flamegraph_ignore_gc
  @flamegraph_ignore_gc
end

#flamegraph_modeObject

Returns the value of attribute flamegraph_mode.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def flamegraph_mode
  @flamegraph_mode
end

#flamegraph_sample_rateObject

Returns the value of attribute flamegraph_sample_rate.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def flamegraph_sample_rate
  @flamegraph_sample_rate
end

#html_containerObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def html_container
  @html_container
end

#loggerObject

Returns the value of attribute logger.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def logger
  @logger
end

#max_snapshot_groupsObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def max_snapshot_groups
  @max_snapshot_groups
end

#max_snapshots_per_groupObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def max_snapshots_per_group
  @max_snapshots_per_group
end

#max_sql_param_lengthObject

Returns the value of attribute max_sql_param_length.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def max_sql_param_length
  @max_sql_param_length
end

#max_traces_to_showObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def max_traces_to_show
  @max_traces_to_show
end

#positionObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def position
  @position
end

#pre_authorize_cbObject

Returns the value of attribute pre_authorize_cb.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def pre_authorize_cb
  @pre_authorize_cb
end

#profile_parameterObject

Returns the value of attribute profile_parameter.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def profile_parameter
  @profile_parameter
end

#show_childrenObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def show_children
  @show_children
end

#show_controlsObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def show_controls
  @show_controls
end

#show_total_sql_countObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def show_total_sql_count
  @show_total_sql_count
end

#show_trivialObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def show_trivial
  @show_trivial
end

#skip_pathsObject

Returns the value of attribute skip_paths.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def skip_paths
  @skip_paths
end

#skip_schema_queriesObject

Returns the value of attribute skip_schema_queries.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def skip_schema_queries
  @skip_schema_queries
end

#skip_sql_param_namesObject

Returns the value of attribute skip_sql_param_names.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def skip_sql_param_names
  @skip_sql_param_names
end

#snapshot_every_n_requestsObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshot_every_n_requests
  @snapshot_every_n_requests
end

#snapshot_hidden_custom_fieldsObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshot_hidden_custom_fields
  @snapshot_hidden_custom_fields
end

#snapshots_redact_sql_queriesObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshots_redact_sql_queries
  @snapshots_redact_sql_queries
end

#snapshots_transport_auth_keyObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshots_transport_auth_key
  @snapshots_transport_auth_key
end

#snapshots_transport_destination_urlObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshots_transport_destination_url
  @snapshots_transport_destination_url
end

#snapshots_transport_gzip_requestsObject

snapshot related config



88
89
90
# File 'lib/mini_profiler/config.rb', line 88

def snapshots_transport_gzip_requests
  @snapshots_transport_gzip_requests
end

#start_hiddenObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def start_hidden
  @start_hidden
end

#storageObject

Returns the value of attribute storage.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def storage
  @storage
end

#storage_failureObject

Returns the value of attribute storage_failure.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def storage_failure
  @storage_failure
end

#storage_instanceObject

Returns the value of attribute storage_instance.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def storage_instance
  @storage_instance
end

#storage_optionsObject

Returns the value of attribute storage_options.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def storage_options
  @storage_options
end

#suppress_encodingObject

Returns the value of attribute suppress_encoding.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def suppress_encoding
  @suppress_encoding
end

#toggle_shortcutObject

ui accessors



83
84
85
# File 'lib/mini_profiler/config.rb', line 83

def toggle_shortcut
  @toggle_shortcut
end

#use_existing_jqueryObject

Deprecated options



94
95
96
# File 'lib/mini_profiler/config.rb', line 94

def use_existing_jquery
  @use_existing_jquery
end

#user_providerObject

Returns the value of attribute user_provider.



72
73
74
# File 'lib/mini_profiler/config.rb', line 72

def user_provider
  @user_provider
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



6
7
8
9
10
# File 'lib/mini_profiler/config.rb', line 6

def self.attr_accessor(*vars)
  @attributes ||= []
  @attributes.concat vars
  super(*vars)
end

.attributesObject



12
13
14
# File 'lib/mini_profiler/config.rb', line 12

def self.attributes
  @attributes
end

.defaultObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/mini_profiler/config.rb', line 16

def self.default
  new.instance_eval {
    @auto_inject      = true # automatically inject on every html page
    @base_url_path    = "/mini-profiler-resources/".dup
    @cookie_path      = "/".dup
    @disable_caching  = true
    # called prior to rack chain, to ensure we are allowed to profile
    @pre_authorize_cb = lambda { |env| true }

    # called after rack chain, to ensure we are REALLY allowed to profile
    @skip_schema_queries    = false
    @storage                = MiniProfiler::MemoryStore
    @user_provider          = Proc.new { |env| Rack::Request.new(env).ip }
    @authorization_mode     = :allow_all
    @backtrace_threshold_ms = 0
    @flamegraph_sample_rate = 0.5
    @flamegraph_mode = :wall
    @flamegraph_ignore_gc = false
    @storage_failure = Proc.new do |exception|
      if @logger
        @logger.warn("MiniProfiler storage failure: #{exception.message}")
      end
    end
    @enabled = true
    @max_sql_param_length = 0 # disable sql parameter collection by default
    @skip_sql_param_names = /password/ # skips parameters with the name password by default
    @enable_advanced_debugging_tools = false
    @snapshot_every_n_requests = -1
    @max_snapshot_groups = 50
    @max_snapshots_per_group = 15

    # ui parameters
    @autorized            = true
    @collapse_results     = true
    @max_traces_to_show   = 20
    @show_children        = false
    @show_controls        = false
    @show_trivial         = false
    @show_total_sql_count = false
    @start_hidden         = false
    @toggle_shortcut      = 'alt+p'
    @html_container       = 'body'
    @position             = "top-left"
    @snapshot_hidden_custom_fields = []
    @snapshots_transport_destination_url = nil
    @snapshots_transport_auth_key = nil
    @snapshots_redact_sql_queries = true
    @snapshots_transport_gzip_requests = false
    @enable_hotwire_turbo_drive_support = false

    @profile_parameter = "pp"

    self
  }
end

Instance Method Details

#horizontal_positionObject



127
128
129
# File 'lib/mini_profiler/config.rb', line 127

def horizontal_position
  position.include?('right') ? 'right' : 'left'
end

#merge!(config) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/mini_profiler/config.rb', line 131

def merge!(config)
  if config
    if Hash === config
      config.each { |k, v| instance_variable_set "@#{k}", v }
    else
      self.class.attributes.each { |k|
        v = config.send k
        instance_variable_set "@#{k}", v if v
      }
    end
  end
end

#vertical_positionObject



123
124
125
# File 'lib/mini_profiler/config.rb', line 123

def vertical_position
  position.include?('bottom') ? 'bottom' : 'top'
end