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

Eronarn’s picture

The 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.

Eronarn’s picture

We 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.

pdrake’s picture

Status: Needs review » Needs work

Generally, 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.

Eronarn’s picture

Hmm, 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?

pdrake’s picture

I'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.

pdrake’s picture

Status: Needs work » Fixed

I 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

Eronarn’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

Awesome! In line with your last post, setting this issue to 6.x-1.x and changing status...

pdrake’s picture

Status: Patch (to be ported) » Closed (won't fix)

Please submit this as a feature request on the new TraceView project if it is still relevant.