Module: AndOne
- Defined in:
- lib/and_one.rb,
lib/and_one/dev_ui.rb,
lib/and_one/console.rb,
lib/and_one/railtie.rb,
lib/and_one/version.rb,
lib/and_one/detector.rb,
lib/and_one/matchers.rb,
lib/and_one/aggregate.rb,
lib/and_one/detection.rb,
lib/and_one/dev_toast.rb,
lib/and_one/formatter.rb,
lib/and_one/middleware.rb,
lib/and_one/fingerprint.rb,
lib/and_one/ignore_file.rb,
lib/and_one/scan_helper.rb,
lib/and_one/json_formatter.rb,
lib/and_one/active_job_hook.rb,
lib/and_one/sidekiq_middleware.rb,
lib/and_one/association_resolver.rb
Defined Under Namespace
Modules: ActiveJobHook, AssociationResolver, Console, DevToast, Fingerprint, MinitestHelper, RSpecHelper, ScanHelper Classes: Aggregate, Detection, Detector, DevUI, Formatter, IgnoreFile, JsonFormatter, Middleware, NPlus1Error, Railtie, SidekiqMiddleware, Suggestion
Constant Summary collapse
- VERSION =
"0.3.1"
Class Attribute Summary collapse
-
.allow_stack_paths ⇒ Object
Returns the value of attribute allow_stack_paths.
-
.backtrace_cleaner ⇒ Object
Returns the value of attribute backtrace_cleaner.
-
.dev_toast ⇒ Object
Returns the value of attribute dev_toast.
-
.dev_toast_position ⇒ Object
Returns the value of attribute dev_toast_position.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.env_thresholds ⇒ Object
Returns the value of attribute env_thresholds.
-
.ignore_callers ⇒ Object
Returns the value of attribute ignore_callers.
-
.ignore_file_path ⇒ Object
Returns the value of attribute ignore_file_path.
-
.ignore_queries ⇒ Object
Returns the value of attribute ignore_queries.
-
.json_logging ⇒ Object
Returns the value of attribute json_logging.
-
.min_n_queries ⇒ Object
Returns the value of attribute min_n_queries.
-
.notifications_callback ⇒ Object
Returns the value of attribute notifications_callback.
-
.raise_on_detect ⇒ Object
Returns the value of attribute raise_on_detect.
Class Method Summary collapse
- .aggregate ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .enabled? ⇒ Boolean
- .finish ⇒ Object
- .ignore_list ⇒ Object
- .pause ⇒ Object
- .paused? ⇒ Boolean
-
.reload_ignore_file! ⇒ Object
Reset cached ignore file (useful after config change).
- .resume ⇒ Object
-
.scan ⇒ Object
Start scanning for N+1 queries on the current thread.
- .scanning? ⇒ Boolean
Class Attribute Details
.allow_stack_paths ⇒ Object
Returns the value of attribute allow_stack_paths.
15 16 17 |
# File 'lib/and_one.rb', line 15 def allow_stack_paths @allow_stack_paths end |
.backtrace_cleaner ⇒ Object
Returns the value of attribute backtrace_cleaner.
15 16 17 |
# File 'lib/and_one.rb', line 15 def backtrace_cleaner @backtrace_cleaner end |
.dev_toast ⇒ Object
Returns the value of attribute dev_toast.
15 16 17 |
# File 'lib/and_one.rb', line 15 def dev_toast @dev_toast end |
.dev_toast_position ⇒ Object
Returns the value of attribute dev_toast_position.
15 16 17 |
# File 'lib/and_one.rb', line 15 def dev_toast_position @dev_toast_position end |
.enabled ⇒ Object
Returns the value of attribute enabled.
15 16 17 |
# File 'lib/and_one.rb', line 15 def enabled @enabled end |
.env_thresholds ⇒ Object
Returns the value of attribute env_thresholds.
15 16 17 |
# File 'lib/and_one.rb', line 15 def env_thresholds @env_thresholds end |
.ignore_callers ⇒ Object
Returns the value of attribute ignore_callers.
15 16 17 |
# File 'lib/and_one.rb', line 15 def ignore_callers @ignore_callers end |
.ignore_file_path ⇒ Object
Returns the value of attribute ignore_file_path.
15 16 17 |
# File 'lib/and_one.rb', line 15 def ignore_file_path @ignore_file_path end |
.ignore_queries ⇒ Object
Returns the value of attribute ignore_queries.
15 16 17 |
# File 'lib/and_one.rb', line 15 def ignore_queries @ignore_queries end |
.json_logging ⇒ Object
Returns the value of attribute json_logging.
15 16 17 |
# File 'lib/and_one.rb', line 15 def json_logging @json_logging end |
.min_n_queries ⇒ Object
Returns the value of attribute min_n_queries.
15 16 17 |
# File 'lib/and_one.rb', line 15 def min_n_queries @min_n_queries end |
.notifications_callback ⇒ Object
Returns the value of attribute notifications_callback.
15 16 17 |
# File 'lib/and_one.rb', line 15 def notifications_callback @notifications_callback end |
.raise_on_detect ⇒ Object
Returns the value of attribute raise_on_detect.
15 16 17 |
# File 'lib/and_one.rb', line 15 def raise_on_detect @raise_on_detect end |
Class Method Details
.aggregate ⇒ Object
88 89 90 91 92 |
# File 'lib/and_one.rb', line 88 def aggregate @singleton_mutex.synchronize do @aggregate ||= Aggregate.new end end |
.configure {|_self| ... } ⇒ Object
21 22 23 |
# File 'lib/and_one.rb', line 21 def configure yield self end |
.enabled? ⇒ Boolean
25 26 27 |
# File 'lib/and_one.rb', line 25 def enabled? @enabled != false end |
.finish ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/and_one.rb', line 53 def finish return [] unless scanning? detections = detector.finish stop_scan report(detections) if detections.any? detections end |
.ignore_list ⇒ Object
94 95 96 97 98 |
# File 'lib/and_one.rb', line 94 def ignore_list @singleton_mutex.synchronize do @ignore_list ||= IgnoreFile.new(resolve_ignore_file_path) end end |
.pause ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/and_one.rb', line 66 def pause if block_given? was_scanning = scanning? thread_state[:and_one_paused] = true begin yield ensure thread_state[:and_one_paused] = false if was_scanning end else thread_state[:and_one_paused] = true end end |
.paused? ⇒ Boolean
84 85 86 |
# File 'lib/and_one.rb', line 84 def paused? !!thread_state[:and_one_paused] end |
.reload_ignore_file! ⇒ Object
Reset cached ignore file (useful after config change)
101 102 103 104 105 |
# File 'lib/and_one.rb', line 101 def reload_ignore_file! @singleton_mutex.synchronize do @ignore_list = nil end end |
.resume ⇒ Object
80 81 82 |
# File 'lib/and_one.rb', line 80 def resume thread_state[:and_one_paused] = false end |
.scan ⇒ Object
Start scanning for N+1 queries on the current thread. Can be used with a block or as start/finish pair.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/and_one.rb', line 31 def scan return block_given? ? yield : nil unless enabled? return block_given? ? yield : nil if scanning? start_scan return unless block_given? begin yield detections = detector.finish stop_scan report(detections) if detections.any? detections rescue Exception # rubocop:disable Lint/RescueException # On error, clean up without reporting — don't add noise to real errors detector&.send(:unsubscribe) stop_scan raise end end |
.scanning? ⇒ Boolean
62 63 64 |
# File 'lib/and_one.rb', line 62 def scanning? !!thread_state[:and_one_detector] end |