Commit 45183ce3 authored by Evan Read's avatar Evan Read

Merge branch '210077-follow-up-from-update-doc-development-query_recorder-md' into 'master'

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

Closes #210077

See merge request gitlab-org/gitlab!29532
parents 13071961 9e3c9e9a
......@@ -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.
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:
- `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.
`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
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:
......@@ -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:
```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
--> /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'
......
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