It would be valuable to automatically annotate on hook_cron, hook_update, and possibly cache_clear_all (though this does get called an awful lot - it'd only really be good for smaller sites). The best way to accomplish this might be Rules integration (annotation event and some default rules using it), but it could be good to provide a checkbox-based fallback because not every site runs Rules.
Comments
Comment #1
Eronarn commentedThe first patch adds support for storing your API information and adding annotations using `tracelytics_add_annotation`. The second patch adds a checkbox for automatically annotating on hook_flush_caches.
Comment #2
Eronarn commentedWe modified the API endpoint. The old one in the first pair of patches works, but it'd be better to go with the new endpoint just so it doesn't break in the future. New patches attached.
Comment #3
pdrake commentedGenerally, I support the idea of beginning to add support for annotations and offering various useful annotations as options within the module, however, hook_flush_caches will be called not only when all caches are flushed (via drupal_flush_all_caches()) but also every time cron runs (within system_cron()). I don't believe this will provide meaningful data.
Comment #4
Eronarn commentedHmm, good point. The cache clear is issued from system_cron, and I don't like the idea of changing the module weight just to run before that. However, we can't just check for the presence of a cron lock in semaphore because we could be a non-cron request that is clearing cache while cron is also running.
What if we take advantage of hook_cron_queue_info - only called on drupal_cron_run, before hook_cron - and set a 'this_is_a_cron_request' global that is checked against in hook_flush_caches?
Comment #5
pdrake commentedI'm against setting a global just for this, but it would be possible to do it with a function and a static variable. It is also possible that a queue action or a cron function will actually flush all caches, and we would miss these in that case.
Comment #6
pdrake commentedI have committed the annotation helper function to 7.x-1.x. I am marking this issue as needing backport. Please open a separate issue for adding annotation of any specific events. Also, I have opened an issue regarding rules integration: http://drupal.org/node/1998132
Comment #7
Eronarn commentedAwesome! In line with your last post, setting this issue to 6.x-1.x and changing status...
Comment #8
pdrake commentedPlease submit this as a feature request on the new TraceView project if it is still relevant.