code • Hooks can be subscribed to • Bunch of hooks in Rails, e.g. • processing of an action of a controller • rendering a partial 2 Check out the rails docs on Active Support Instrumentation
know • when new queries were introduced • which specific queries were slow • the relative differences in volume of the queries running on each table • which parts of our app were running certain queries
{} end def record_metrics(event) options = extract_options_from_event(event) send_metrics_to_statsd(options) SqlFingerprintWorker.perform_async(options) if should_record_fingerprint?(event, options) @known_md5_signatures[options[:md5_signature]] = true end def should_record_fingerprint?(event, options) @known_md5_signatures[options[:md5_signature]].nil? end end
query volume (~20 queries over 25M QPD) • Most of those queries were for records that changed rarely • Mostly run by high volume API endpoints, which were sensitive to latency increases