Commit 732463d
committed
Include more DB stats in logs
[Reducing the number of DB queries has made page response times
faster](#2274)
[In Rails 7.2, the default logger started including the number of
database queries in the log](rails/rails#51457).
We already have DB time in the logs. I think it's useful to include the
number of queries as another simple metric.
This is useful for checking performance in local development and I think
probably for production as well. It would enable us to see if the number
of queries is increasing or decreasing over time for specific pages.
Example log entry:
{
"method": "GET",
"path": "/forms/1",
"format": "html",
"controller": "FormsController",
"action": "show",
"status": 200,
"allocations": 67752,
"duration": 238.2,
"view": 23.53,
"db": 156.87,
"request_host": "localhost",
"request_id": "01d5ce3c-7a6c-4d32-9288-cf4350850af3",
"trace_id": null,
"form_id": "1",
"user_ip": null,
"params": {
"form_id": "1"
},
"queries_count": 26,
"cached_queries_count": 15
}1 parent 8cc614c commit 732463d
2 files changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
0 commit comments