Commit 9e3c9e9a authored by Brett Walker's avatar Brett Walker Committed by Evan Read

Follow-up from "Update doc/development/query_recorder.md"

parent ea0fa636
...@@ -47,7 +47,7 @@ This could lead to false successes where subsequent "requests" could have querie ...@@ -47,7 +47,7 @@ This could lead to false successes where subsequent "requests" could have querie
There are multiple ways to find the source of queries. There are multiple ways to find the source of queries.
1. The `QueryRecorder` `data` attribute stores queries by `file_name:line_number:method_name`. - Inspect the `QueryRecorder` `data` attribute. It stores queries by `file_name:line_number:method_name`.
Each entry is a `hash` with the following fields: Each entry is a `hash` with the following fields:
- `count`: the number of times a query from this `file_name:line_number:method_name` was called - `count`: the number of times a query from this `file_name:line_number:method_name` was called
...@@ -64,11 +64,11 @@ There are multiple ways to find the source of queries. ...@@ -64,11 +64,11 @@ There are multiple ways to find the source of queries.
`QueryRecorder#occurrences_by_line_method` returns a sorted array based on `data`, sorted by `count`. `QueryRecorder#occurrences_by_line_method` returns a sorted array based on `data`, sorted by `count`.
1. You can output the call backtrace for the specific `QueryRecorder` instance you want - View the call backtrace for the specific `QueryRecorder` instance you want
by using `ActiveRecord::QueryRecorder.new(query_recorder_debug: true)`. The output by using `ActiveRecord::QueryRecorder.new(query_recorder_debug: true)`. The output
will be in `test.log` will be in `test.log`
1. Using the environment variable `QUERY_RECORDER_DEBUG`, the call backtrace will be output for all tests. - Enable the call backtrace for all tests using the `QUERY_RECORDER_DEBUG` environment variable.
To enable this, run the specs with the `QUERY_RECORDER_DEBUG` environment variable set. For example: To enable this, run the specs with the `QUERY_RECORDER_DEBUG` environment variable set. For example:
...@@ -78,7 +78,7 @@ There are multiple ways to find the source of queries. ...@@ -78,7 +78,7 @@ There are multiple ways to find the source of queries.
This will log calls to QueryRecorder into the `test.log` file. For example: This will log calls to QueryRecorder into the `test.log` file. For example:
```plaintext ```sql
QueryRecorder SQL: SELECT COUNT(*) FROM "issues" WHERE "issues"."deleted_at" IS NULL AND "issues"."project_id" = $1 AND ("issues"."state" IN ('opened')) AND "issues"."confidential" = $2 QueryRecorder SQL: SELECT COUNT(*) FROM "issues" WHERE "issues"."deleted_at" IS NULL AND "issues"."project_id" = $1 AND ("issues"."state" IN ('opened')) AND "issues"."confidential" = $2
--> /home/user/gitlab/gdk/gitlab/spec/support/query_recorder.rb:19:in `callback' --> /home/user/gitlab/gdk/gitlab/spec/support/query_recorder.rb:19:in `callback'
--> /home/user/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/fanout.rb:127:in `finish' --> /home/user/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/fanout.rb:127:in `finish'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment