### Install Prosopite Gem Source: https://context7.com/charkost/prosopite/llms.txt Add Prosopite to your Gemfile. Include `pg_query` if you are not using MySQL/MariaDB/Trilogy. ```ruby # Gemfile gem 'prosopite' gem 'pg_query' # only if NOT using MySQL/MariaDB/Trilogy ``` ```bash bundle install ``` -------------------------------- ### Add Prosopite Gem to Gemfile (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Standard Ruby gem installation instruction. Add this line to your application's Gemfile and run `bundle install`. ```ruby gem 'prosopite' ``` -------------------------------- ### Minitest Integration for N+1 Detection Source: https://context7.com/charkost/prosopite/llms.txt Sets up `setup` and `teardown` methods in Minitest::Test to scan before each test and finish after, raising errors on N+1 detection. ```ruby class Minitest::Test def setup Prosopite.scan end def teardown Prosopite.finish # raises NPlusOneQueriesError if N+1 detected end end ``` -------------------------------- ### Example Failing Test for N+1 Detection Source: https://context7.com/charkost/prosopite/llms.txt Demonstrates a test case that is expected to fail due to N+1 queries, triggering `Prosopite::NPlusOneQueriesError`. ```ruby def test_detects_n_plus_one_in_loop chairs = create_list(:chair, 20) chairs.each { |c| create_list(:leg, 4, chair: c) } # Prosopite.scan already called in setup assert_raises(Prosopite::NPlusOneQueriesError) do Chair.last(20).each { |c| c.legs.first } Prosopite.finish end end ``` -------------------------------- ### Scan Each Test with Prosopite (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Ensures that each individual test case is scanned for N+1 queries by wrapping tests with `Prosopite.scan` and `Prosopite.finish`. This setup should be in `spec/spec_helper.rb`. ```ruby # spec/spec_helper.rb config.before(:each) do Prosopite.scan end config.after(:each) do Prosopite.finish end ``` -------------------------------- ### Start N+1 Detection with Prosopite.scan Source: https://context7.com/charkost/prosopite/llms.txt Activates SQL monitoring for the current thread. Use the imperative form with `Prosopite.finish` or the block form for automatic finalization. Nested scans are safe and ignored if an outer scan is already active. ```ruby # Imperative form — must pair with Prosopite.finish Prosopite.scan User.last(10).each { |u| u.posts.count } Prosopite.finish ``` ```ruby # Block form — finish is called automatically; return value is preserved result = Prosopite.scan do Order.last(20).map { |o| o.line_items.sum(:price) } end # => result is the array of sums ``` ```ruby # Nested scans are safe — inner scan is a no-op if outer is already active Prosopite.scan do Prosopite.scan do # silently ignored; outer scan remains active Chair.last(5).each { |c| c.legs.first } end end ``` -------------------------------- ### Controller Action for Selective N+1 Raising Source: https://github.com/charkost/prosopite/blob/main/README.md Example of a Rails controller setup to selectively raise N+1 errors on specific actions using `raise_on_n_plus_ones!`. ```ruby # app/controllers/application_controller.rb class ApplicationController < ActionController::Base def raise_on_n_plus_ones!(**options) return if Rails.env.production? prepend_around_action(:_raise_on_n_plus_ones, **options) end unless Rails.env.production? around_action :n_plus_one_detection def n_plus_one_detection ... end def _raise_on_n_plus_ones Proposite.start_raise yield ensure Prosopite.stop_raise end end end ``` ```ruby # app/controllers/books_controller.rb class BooksController < ApplicationController raise_on_n_plus_ones!(only: [:index]) def index @books = Book.all.map(&:author) # This will raise N+1 errors end def show @book = Book.find(params[:id]) @book.reviews.map(&:author) # This will not raise N+1 errors end end ``` -------------------------------- ### Example N+1 Query Detection Output Source: https://github.com/charkost/prosopite/blob/main/README.md This output shows detected N+1 queries, including the SQL statements and the call stack where they occurred. This is the primary output format when Prosopite identifies an issue. ```text N+1 queries detected: SELECT `users`.* FROM `users` WHERE `users`.`id` = 20 LIMIT 1 SELECT `users`.* FROM `users` WHERE `users`.`id` = 21 LIMIT 1 SELECT `users`.* FROM `users` WHERE `users`.`id` = 22 LIMIT 1 SELECT `users`.* FROM `users` WHERE `users`.`id` = 23 LIMIT 1 SELECT `users`.* FROM `users` WHERE `users`.`id` = 24 LIMIT 1 Call stack: app/controllers/thank_you_controller.rb:4:in `block in index' app/controllers/thank_you_controller.rb:3:in `each' app/controllers/thank_you_controller.rb:3:in `index': app/controllers/application_controller.rb:8:in `block in ' ``` -------------------------------- ### Changing ActiveRecord Class with #becomes (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Example of N+1 query detection when using `#becomes` to change the ActiveRecord class of an instance, followed by collection association access. ```ruby Chair.last(20).map{ |c| c.becomes(ArmChair) }.each do |ac| ac.legs.map(&:id) end ``` -------------------------------- ### N+1 Queries After Record Creations (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Demonstrates N+1 query detection in scenarios involving record creations, often seen in test environments. Ensure FactoryBot and relevant models are set up. ```ruby FactoryBot.create_list(:leg, 10) Leg.last(10).each do |l| l.chair end ``` -------------------------------- ### Configure Rack Middleware for Prosopite Source: https://github.com/charkost/prosopite/blob/main/README.md Add this to your `config/initializers/prosopite.rb` to enable Rack middleware for auto-detection in controllers. Excludes production environment. ```ruby unless Rails.env.production? require 'prosopite/middleware/rack' Rails.configuration.middleware.use(Prosopite::Middleware::Rack) end ``` -------------------------------- ### Configure Prosopite for Test Environment (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Configures Prosopite to log warnings and raise exceptions for N+1 queries in the test environment. Place this in `config/environments/test.rb`. ```ruby # config/environments/test.rb config.after_initialize do Prosopite.rails_logger = true Prosopite.raise = true end ``` -------------------------------- ### Configure Sidekiq Server Middleware Source: https://context7.com/charkost/prosopite/llms.txt Adds Prosopite's Sidekiq middleware to the server chain for N+1 query detection. Ensure Sidekiq version is compatible. ```ruby Sidekiq.configure_server do |config| if Sidekiq::VERSION >= '6.5.0' && !Rails.env.production? config.server_middleware do |chain| require 'prosopite/middleware/sidekiq' chain.add(Prosopite::Middleware::Sidekiq) end end end ``` -------------------------------- ### Enable N+1 Detection in Development Controllers Source: https://context7.com/charkost/prosopite/llms.txt Sets up an `around_action` in the base controller to scan for N+1 queries during development. This logs detected queries. ```ruby config.after_initialize do Prosopite.rails_logger = true end ``` ```ruby class ApplicationController < ActionController::Base unless Rails.env.production? around_action :n_plus_one_detection def n_plus_one_detection Prosopite.scan yield ensure Prosopite.finish end end end ``` -------------------------------- ### Integrate Prosopite with Rack Middleware Source: https://context7.com/charkost/prosopite/llms.txt Wrap every HTTP request in a scan/finish cycle using Rack middleware. This automatically integrates Prosopite without requiring `around_action` hooks in controllers. Excludes production environment. ```ruby # config/initializers/prosopite.rb unless Rails.env.production? require 'prosopite/middleware/rack' Rails.configuration.middleware.use(Prosopite::Middleware::Rack) end # The middleware implementation: # module Prosopite # module Middleware # class Rack # def call(env) # Prosopite.scan # @app.call(env) # ensure # Prosopite.finish # end # end # end # end ``` -------------------------------- ### Configure Sidekiq Middleware for Prosopite Source: https://github.com/charkost/prosopite/blob/main/README.md Integrate Prosopite's Sidekiq middleware for detecting N+1 queries in background jobs. Requires Sidekiq 6.5.0+. ```ruby Sidekiq.configure_server do |config| unless Rails.env.production? config.server_middleware do |chain| require 'prosopite/middleware/sidekiq' chain.add(Prosopite::Middleware::Sidekiq) end end end ``` -------------------------------- ### Configure Prosopite for Test Environment Source: https://context7.com/charkost/prosopite/llms.txt Enables logging and raises errors on N+1 detection in the test environment. This turns N+1 queries into test failures. ```ruby config.after_initialize do Prosopite.rails_logger = true Prosopite.raise = true end ``` -------------------------------- ### Set Minimum Query Threshold with Prosopite.min_n_queries Source: https://context7.com/charkost/prosopite/llms.txt Configure the minimum number of repeated queries required to trigger an N+1 notification. Defaults to 2. Increasing this value can reduce noise in environments with small datasets. ```ruby # Only report N+1s with 5 or more repeated queries Prosopite.min_n_queries = 5 Prosopite.scan Chair.last(4).each { |c| c.legs.last } # 4 queries < 5 threshold → no notification Prosopite.finish # Reset to default Prosopite.min_n_queries = 2 ``` -------------------------------- ### Scan Code Blocks with Prosopite Source: https://github.com/charkost/prosopite/blob/main/README.md Manually wrap code blocks with `Prosopite.scan` and `Prosopite.finish` to detect N+1 queries within specific sections of your application. ```ruby Prosopite.scan Prosopite.finish ``` -------------------------------- ### Configure Prosopite Allow List for Stack Paths Source: https://github.com/charkost/prosopite/blob/main/README.md Specify substrings or regex patterns to ignore notifications for call stacks containing them. ```ruby Prosopite.allow_stack_paths = ['substring_in_call_stack', /regex/] ``` -------------------------------- ### Enable Prosopite Auto-detection in Development (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Integrates Prosopite's N+1 detection into all controllers for development environments. This code should be placed in `ApplicationController`. ```ruby class ApplicationController < ActionController::Base unless Rails.env.production? around_action :n_plus_one_detection def n_plus_one_detection Prosopite.scan yield ensure Prosopite.finish end end end ``` -------------------------------- ### First/Last/Pluck of Collection Associations (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Shows N+1 query detection with collection associations using methods like `first`, `last`, and `pluck`. ```ruby Chair.last(20).each do |c| c.legs.first c.legs.last c.legs.pluck(:id) end ``` -------------------------------- ### Prosopite.start_raise / Prosopite.stop_raise / Prosopite.local_raise? Source: https://context7.com/charkost/prosopite/llms.txt Controls whether N+1 queries should raise an exception on a per-thread basis, without altering the global `Prosopite.raise` setting. This is beneficial for selectively enforcing strict N+1 detection on specific controller actions or code paths. ```APIDOC ## Prosopite.start_raise / Prosopite.stop_raise / Prosopite.local_raise? — Per-request raise control Enables raising on a per-thread basis without changing the global `Prosopite.raise` setting. Useful for selectively enforcing strict N+1 detection on specific controller actions or code paths. ### Configuration Example ```ruby # config/initializers/prosopite.rb Prosopite.raise = false # globally off # app/controllers/application_controller.rb class ApplicationController < ActionController::Base def raise_on_n_plus_ones!(**options) return if Rails.env.production? prepend_around_action(:_enforce_n_plus_one, **options) end def _enforce_n_plus_one Prosopite.start_raise yield ensure Prosopite.stop_raise end end # app/controllers/books_controller.rb class BooksController < ApplicationController raise_on_n_plus_ones!(only: [:index]) def index @books = Book.all.map(&:author) # raises NPlusOneQueriesError end def show @book = Book.find(params[:id]) @book.reviews.map(&:author) # only logs, does not raise end end # Check current thread's raise state Prosopite.local_raise? # => true inside _enforce_n_plus_one, false otherwise ``` ``` -------------------------------- ### Prosopite.scan Source: https://context7.com/charkost/prosopite/llms.txt Activates SQL monitoring for the current thread. It can be used imperatively or with a block. When used with a block, Prosopite.finish is invoked automatically, and the block's return value is preserved. ```APIDOC ## Prosopite.scan — Start N+1 detection Activates SQL monitoring for the current thread. Can be called with or without a block. When called with a block, `finish` is invoked automatically and the block's return value is passed through. ### Usage ```ruby # Imperative form — must pair with Prosopite.finish Prosopite.scan User.last(10).each { |u| u.posts.count } Prosopite.finish # Block form — finish is called automatically; return value is preserved result = Prosopite.scan do Order.last(20).map { |o| o.line_items.sum(:price) } end # => result is the array of sums # Nested scans are safe — inner scan is a no-op if outer is already active Prosopite.scan do Prosopite.scan do # silently ignored; outer scan remains active Chair.last(5).each { |c| c.legs.first } end end ``` ``` -------------------------------- ### Configure Prosopite Rails Logger in Development (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Sets Prosopite to send warnings to the Rails log during development. This configuration should be placed in `config/environments/development.rb`. ```ruby # config/environments/development.rb config.after_initialize do Prosopite.rails_logger = true end ``` -------------------------------- ### Per-Request Raise Control with Prosopite.start_raise/stop_raise Source: https://context7.com/charkost/prosopite/llms.txt Enables raising N+1 query errors on a per-thread basis without altering the global `Prosopite.raise` setting. This is useful for selectively enforcing strict N+1 detection on specific controller actions or code paths. `Prosopite.local_raise?` checks the current thread's raise state. ```ruby # config/initializers/prosopite.rb Prosopite.raise = false # globally off # app/controllers/application_controller.rb class ApplicationController < ActionController::Base def raise_on_n_plus_ones!(**options) return if Rails.env.production? prepend_around_action(:_enforce_n_plus_one, **options) end def _enforce_n_plus_one Prosopite.start_raise yield ensure Prosopite.stop_raise end end # app/controllers/books_controller.rb class BooksController < ApplicationController raise_on_n_plus_ones!(only: [:index]) def index @books = Book.all.map(&:author) # raises NPlusOneQueriesError end def show @book = Book.find(params[:id]) @book.reviews.map(&:author) # only logs, does not raise end end # Check current thread's raise state Prosopite.local_raise? # => true inside _enforce_n_plus_one, false otherwise ``` -------------------------------- ### Add pg_query Gem for Non-MySQL/MariaDB (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md If not using MySQL or MariaDB, you need to add the `pg_query` gem for Prosopite to function correctly. Add this to your Gemfile. ```ruby gem 'pg_query' ``` -------------------------------- ### Configure Prosopite to Ignore Specific Queries Source: https://github.com/charkost/prosopite/blob/main/README.md Define regex patterns or exact string matches to ignore notifications for specific SQL queries. ```ruby Prosopite.ignore_queries = [/regex_match/, "SELECT * from EXACT_STRING_MATCH"] ``` -------------------------------- ### Allow-list by SQL Pattern with Prosopite.ignore_queries Source: https://context7.com/charkost/prosopite/llms.txt Ignore N+1 notifications for queries that match a given regex or exact SQL string. Useful for intentionally repeated SQL patterns like audit logging or caching misses. ```ruby # Ignore by regex Prosopite.ignore_queries = [/audit_logs/] # Ignore by exact SQL string Prosopite.ignore_queries = [ %(SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" DESC LIMIT ?) ] # Multiple patterns Prosopite.ignore_queries = [/audit_logs/, /sessions/, "SELECT 1"] Prosopite.scan Chair.last(20).each { |c| c.legs.last } # ignored if matches pattern Prosopite.finish ``` -------------------------------- ### Enable or Disable Prosopite Globally with Prosopite.enabled Source: https://context7.com/charkost/prosopite/llms.txt Use this as a master switch to turn Prosopite monitoring on or off. When disabled, `Prosopite.scan` becomes a no-op. Useful for conditionally disabling in CI or specific test configurations. ```ruby Prosopite.enabled = false Prosopite.scan do Chair.last(20).each { |c| c.legs.last } end # => no notifications, no exceptions Prosopite.enabled = true # re-enable ``` -------------------------------- ### Allow-list by Call Stack with Prosopite.allow_stack_paths Source: https://context7.com/charkost/prosopite/llms.txt Suppress N+1 notifications by providing substrings or regular expressions that must be present in the call stack. Useful for known safe library code or deprecated paths. ```ruby # Ignore N+1s originating from a specific file Prosopite.allow_stack_paths = ['app/jobs/legacy_import_job.rb'] # Ignore using a regex pattern Prosopite.allow_stack_paths = [/legacy_import_job.*perform/] # Multiple patterns Prosopite.allow_stack_paths = [ 'vendor/gems/old_library', /serializers\/v1\// ] Prosopite.scan LegacyImportJob.perform_now # N+1 here will be silently ignored Prosopite.finish ``` -------------------------------- ### Configure Notification Channels for Prosopite Source: https://context7.com/charkost/prosopite/llms.txt Enable multiple independent notification channels for Prosopite. All default to false. Options include Rails logger, STDERR logger, a dedicated prosopite log file, and the ability to fail tests. ```ruby # config/environments/development.rb config.after_initialize do Prosopite.rails_logger = true # highlights in red in Rails log Prosopite.stderr_logger = true # also print to STDERR Prosopite.prosopite_logger = true # write to log/prosopite.log end # config/environments/test.rb config.after_initialize do Prosopite.rails_logger = true Prosopite.raise = true # fail tests on N+1 end # Custom logger — disables red ANSI escape codes (useful for JSON log pipelines) Prosopite.custom_logger = Rails.logger # plain Rails logger, no color Prosopite.custom_logger = MyJsonLogger.new # fully custom logger instance Prosopite.custom_logger = Logger.new($stdout) # standard Ruby logger # Custom backtrace cleaner Prosopite.backtrace_cleaner = ActiveSupport::BacktraceCleaner.new.tap do |bc| bc.add_silencer { |line| line.include?('gems/') } end ``` -------------------------------- ### Finalize Scan and Emit Notifications with Prosopite.finish Source: https://context7.com/charkost/prosopite/llms.txt Stops monitoring, evaluates collected queries, and dispatches notifications for detected N+1 patterns. Clears all thread-local state and is safe to call even if no scan is active. Setting `Prosopite.raise = true` will raise a `Prosopite::NPlusOneQueriesError` if N+1 queries are detected. ```ruby Prosopite.raise = true Prosopite.scan Chair.last(20).each { |c| c.legs.last } begin Prosopite.finish # => raises Prosopite::NPlusOneQueriesError if N+1 detected rescue Prosopite::NPlusOneQueriesError => e puts e.message # N+1 queries detected (12.3ms): # SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" DESC LIMIT ? # SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" DESC LIMIT ? # ... # Call stack: # app/controllers/chairs_controller.rb:8:in `block in index' # app/controllers/chairs_controller.rb:7:in `each' end ``` -------------------------------- ### Scan Code Blocks Automatically with Prosopite Source: https://github.com/charkost/prosopite/blob/main/README.md Use the block form of `Prosopite.scan` for automatic detection and completion of scans. `Prosopite.finish` is called implicitly. ```ruby Prosopite.scan do end ``` -------------------------------- ### Mongoid Models Calling ActiveRecord (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Demonstrates N+1 query detection when a Mongoid model (`Leg::Design`) calls an ActiveRecord model (`Chair`). Ensure both Mongoid and ActiveRecord are configured. ```ruby class Leg::Design include Mongoid::Document ... field :cid, as: :chair_id, type: Integer ... def chair @chair ||= Chair.where(id: chair_id).first! end end Leg::Design.last(20) do |l| l.chair end ``` -------------------------------- ### Configure Custom Logger for Prosopite Source: https://github.com/charkost/prosopite/blob/main/README.md Set a custom logger for Prosopite to control log output, such as disabling red highlights or directing logs to a specific location. ```ruby # Turns off logging with red highlights, but still sends them to the Rails logger Prosopite.custom_logger = Rails.logger ``` ```ruby # Use a completely custom logging instance Prosopite.custom_logger = MyLoggerClass.new ``` -------------------------------- ### Prosopite.finish Source: https://context7.com/charkost/prosopite/llms.txt Stops monitoring, evaluates collected queries, and dispatches notifications for any detected N+1 patterns. It clears all thread-local state and is safe to call even if no scan is active. ```APIDOC ## Prosopite.finish — Finalize scan and emit notifications Stops monitoring, evaluates collected queries, and dispatches notifications (log, raise, etc.) for any detected N+1 patterns. Clears all thread-local state. Safe to call even if no scan is active. ### Usage ```ruby Prosopite.raise = true Prosopite.scan Chair.last(20).each { |c| c.legs.last } begin Prosopite.finish # => raises Prosopite::NPlusOneQueriesError if N+1 detected rescue Prosopite::NPlusOneQueriesError => e puts e.message # N+1 queries detected (12.3ms): # SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" DESC LIMIT ? # SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" DESC LIMIT ? # ... # Call stack: # app/controllers/chairs_controller.rb:8:in `block in index' # app/controllers/chairs_controller.rb:7:in `each' end ``` ``` -------------------------------- ### Capture Scan Results with Prosopite Block Source: https://github.com/charkost/prosopite/blob/main/README.md The result of a `Prosopite.scan` block is returned, allowing you to wrap factory calls or other object creation methods. ```ruby my_object = Prosopite.scan do MyObjectFactory.create(params) end ``` -------------------------------- ### Pause and Resume Prosopite Scans Source: https://github.com/charkost/prosopite/blob/main/README.md Manually pause and resume Prosopite scans to selectively detect N+1 queries in different code sections. Useful for isolating issues. ```ruby Prosopite.scan # Prosopite.pause # Prosopite.resume # Prosopite.finish ``` -------------------------------- ### Conditional Sidekiq Middleware for Older Versions Source: https://github.com/charkost/prosopite/blob/main/README.md Use this snippet to guard the Sidekiq middleware for versions older than 6.5.0. Remove once Sidekiq is upgraded. ```ruby if Sidekiq::VERSION >= '6.5.0' && (Rails.env.development? || Rails.env.test?) ..... end ``` -------------------------------- ### RSpec Integration for N+1 Detection Source: https://context7.com/charkost/prosopite/llms.txt Configures RSpec to scan before each test and finish after, ensuring N+1 queries cause test failures. ```ruby RSpec.configure do |config| config.before(:each) { Prosopite.scan } config.after(:each) { Prosopite.finish } end ``` -------------------------------- ### N+1 Queries Not Triggered by Associations (Ruby) Source: https://github.com/charkost/prosopite/blob/main/README.md Illustrates N+1 query detection when ActiveRecord associations are not directly involved, requiring explicit queries like `Chair.find`. ```ruby Leg.last(4).each do |l| Chair.find(l.chair_id) end ``` -------------------------------- ### Temporarily Suspend Detection with Prosopite.pause/resume Source: https://context7.com/charkost/prosopite/llms.txt Pauses monitoring for sections of code where N+1 patterns are acceptable, such as background jobs during tests. The block form automatically restores the previous scan state, even on exceptions. ```ruby Prosopite.scan # Non-block form Prosopite.pause LegacyReportJob.perform_now # known N+1s we don't care about Prosopite.resume # Block form — automatically resumes; returns block value report = Prosopite.pause do LegacyReportJob.generate_report # N+1s ignored here end Prosopite.finish # only checks queries outside the paused sections ``` -------------------------------- ### Prosopite.pause / Prosopite.resume Source: https://context7.com/charkost/prosopite/llms.txt Temporarily suspends N+1 detection. This is useful for sections of code known to have acceptable N+1 patterns, such as background jobs called inline during tests. The block form automatically restores the previous scan state, even on exceptions. ```APIDOC ## Prosopite.pause / Prosopite.resume — Temporarily suspend detection Pauses monitoring for a section of code known to have acceptable N+1 patterns (e.g., background jobs called inline during tests). Block form restores the previous scan state automatically, even on exceptions. ### Usage ```ruby Prosopite.scan # Non-block form Prosopite.pause LegacyReportJob.perform_now # known N+1s we don't care about Prosopite.resume # Block form — automatically resumes; returns block value report = Prosopite.pause do LegacyReportJob.generate_report # N+1s ignored here end Prosopite.finish # only checks queries outside the paused sections ``` ``` -------------------------------- ### Override Pauses with Prosopite.ignore_pauses Source: https://context7.com/charkost/prosopite/llms.txt When set to true, `Prosopite.pause` calls become no-ops, and all queries are monitored, even within paused blocks. Useful for debugging N+1s hidden in paused sections. ```ruby Prosopite.ignore_pauses = true Prosopite.scan Prosopite.pause # no effect when ignore_pauses is true Chair.last(20).each { |c| c.legs.last } # still monitored Prosopite.resume Prosopite.finish # will report N+1s from the "paused" section Prosopite.ignore_pauses = false # reset ``` -------------------------------- ### Pause Scans within a Prosopite Block Source: https://github.com/charkost/prosopite/blob/main/README.md Pause scans within a `Prosopite.pause` block, which automatically resumes scanning upon completion. The result of the paused block is returned. ```ruby Prosopite.scan # result = Prosopite.pause do # end Prosopite.finish ``` -------------------------------- ### Disable Prosopite Raising by Default Source: https://github.com/charkost/prosopite/blob/main/README.md Configure Prosopite to not raise exceptions by default. This allows for selective raising in specific scenarios. ```ruby Proposite.raise = false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.