Apache License, Version 2.0 (the "License"); you may not use this code except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Lawyercat says:
do |name, st, fin, id, data| Rails.logger.info \ "cache #{data[:hit] ? 'HIT' : 'MISS'}" end ActiveSupport::Notifications. instrument "cache_read.active_support" \ do actually_read_the_cache end # Log cache HIT cache MISS cache HIT cache HIT ...
cache MISS (172 ms) cache HIT (132 ms) cache MISS (168 ms) cache MISS (180 ms) cache MISS (173 ms) cache MISS (178 ms) cache MISS (171 ms) cache MISS (186 ms) cache HIT (129 ms) cache MISS (176 ms) cache MISS (171 ms) ...
cache MISS (172 ms) cache HIT (132 ms) cache MISS (168 ms) cache MISS (180 ms) cache MISS (173 ms) cache MISS (178 ms) cache MISS (171 ms) cache MISS (186 ms) cache HIT (129 ms) cache MISS (176 ms) cache MISS (171 ms) ...
cache MISS (172 ms) cache HIT (132 ms) cache MISS (168 ms) cache MISS (180 ms) cache MISS (173 ms) cache MISS (178 ms) cache MISS (171 ms) cache MISS (186 ms) cache HIT (129 ms) cache MISS (176 ms) cache MISS (171 ms) ... “Actionable” Data
ensure secs = Time.now - start logger.info "It took #{secs} seconds" end end ActionController filters Use it when: You just have to measure something simple about the request as a whole
end def call env start = Time.now @app.call env ensure secs = Time.now - start puts "It took #{secs} seconds" end end Use it when: You’re using something besides Rails, or want to measure middleware
Rails.logger.info "my_method called" end end trace.enable do do_stuff end TracePoint Use it when: You want to measure something at the language level (like method calls)