Class: Profiler::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/profiler/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/profiler/configuration.rb', line 16

def initialize
  @enabled = false
  @storage = :memory
  @storage_options = {}
  @collectors = []
  @skip_paths = [%r{^/_profiler}, /\.well-known/, /favicon\.ico/, /manifest\.json/]
  @slow_query_threshold = 100 # milliseconds
  @max_queries_warning = 50
  @track_memory = true
  @memory_warning_threshold = 100 * 1024 * 1024 # 100 MB
  @mcp_enabled = false
  @mcp_transport = :stdio
  @mcp_port = 3001
  @authorization_mode = :allow_all
  @authorize_block = nil
  @max_profiles = 100
  @extension_cors_enabled = true
  @track_ajax = true
  @ajax_skip_paths = [/^\/_profiler/]
  @track_http = true
  @slow_http_threshold = 500 # milliseconds
  @http_skip_hosts = []
  @track_jobs = true
end

Instance Attribute Details

#ajax_skip_pathsObject

Returns the value of attribute ajax_skip_paths.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def ajax_skip_paths
  @ajax_skip_paths
end

#authorization_modeObject

Returns the value of attribute authorization_mode.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def authorization_mode
  @authorization_mode
end

#authorize_blockObject (readonly)

Returns the value of attribute authorize_block.



14
15
16
# File 'lib/profiler/configuration.rb', line 14

def authorize_block
  @authorize_block
end

#collectorsObject

Returns the value of attribute collectors.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def collectors
  @collectors
end

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def enabled
  @enabled
end

#extension_cors_enabledObject

Returns the value of attribute extension_cors_enabled.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def extension_cors_enabled
  @extension_cors_enabled
end

#http_skip_hostsObject

Returns the value of attribute http_skip_hosts.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def http_skip_hosts
  @http_skip_hosts
end

#max_profilesObject

Returns the value of attribute max_profiles.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def max_profiles
  @max_profiles
end

#max_queries_warningObject

Returns the value of attribute max_queries_warning.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def max_queries_warning
  @max_queries_warning
end

#mcp_enabledObject

Returns the value of attribute mcp_enabled.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def mcp_enabled
  @mcp_enabled
end

#mcp_portObject

Returns the value of attribute mcp_port.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def mcp_port
  @mcp_port
end

#mcp_transportObject

Returns the value of attribute mcp_transport.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def mcp_transport
  @mcp_transport
end

#memory_warning_thresholdObject

Returns the value of attribute memory_warning_threshold.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def memory_warning_threshold
  @memory_warning_threshold
end

#skip_pathsObject

Returns the value of attribute skip_paths.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def skip_paths
  @skip_paths
end

#slow_http_thresholdObject

Returns the value of attribute slow_http_threshold.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def slow_http_threshold
  @slow_http_threshold
end

#slow_query_thresholdObject

Returns the value of attribute slow_query_threshold.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def slow_query_threshold
  @slow_query_threshold
end

#storageObject

Returns the value of attribute storage.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def storage
  @storage
end

#storage_optionsObject

Returns the value of attribute storage_options.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def storage_options
  @storage_options
end

#track_ajaxObject

Returns the value of attribute track_ajax.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def track_ajax
  @track_ajax
end

#track_httpObject

Returns the value of attribute track_http.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def track_http
  @track_http
end

#track_jobsObject

Returns the value of attribute track_jobs.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def track_jobs
  @track_jobs
end

#track_memoryObject

Returns the value of attribute track_memory.



5
6
7
# File 'lib/profiler/configuration.rb', line 5

def track_memory
  @track_memory
end

Instance Method Details

#authorize_with(&block) ⇒ Object



41
42
43
# File 'lib/profiler/configuration.rb', line 41

def authorize_with(&block)
  @authorize_block = block
end

#authorized?(request) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
# File 'lib/profiler/configuration.rb', line 45

def authorized?(request)
  case @authorization_mode
  when :allow_all
    true
  when :allow_authorized
    @authorize_block ? @authorize_block.call(request) : false
  else
    false
  end
end

#storage_backendObject



56
57
58
# File 'lib/profiler/configuration.rb', line 56

def storage_backend
  @storage_backend ||= build_storage_backend
end