https://signalvnoise.com/posts/3130-tech-note-mysql-query-comments-in-rails
From https://github.com/basecamp/marginalia:
From https://github.com/basecamp/marginalia:
Attach comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a comment at the end of each query.
This helps when searching log files for queries, and seeing where slow queries came from.
For example, once enabled, your logs will look like:
Account Load (0.3ms) SELECT `accounts`.* FROM `accounts` WHERE `accounts`.`queenbee_id` = 1234567890 LIMIT 1 /*application:BCX,controller:project_imports,action:show*/
You can also use these query comments along with a tool like pt-query-digest to automate identification of controllers and actions that are hotspots for slow queries.
......
.......
Marginalia ships with:application
,:controller
, and:action
enabled by default. In addition, implementation is provided for:
:line
(for file and line number calling query). :line supports a configuration by setting a regexp inMarginalia::Comment.lines_to_ignore
to exclude parts of the stacktrace from inclusion in the line comment.:controller_with_namespace
to include the full classname (including namespace) of the controller.:job
to include the classname of the ActiveJob being performed.:hostname
to includeSocket.gethostname
.:pid
to include current process id.
No comments:
Post a Comment