diff --git a/config-dist.php b/config-dist.php index afb9c1c57e3..fa43382a2ca 100644 --- a/config-dist.php +++ b/config-dist.php @@ -380,6 +380,12 @@ $CFG->admin = 'admin'; // profilingallowme, profilingallowall, profilinglifetime // $CFG->earlyprofilingenabled = true; // +// Disable database storage for profile data. +// When using an exernal plugin to store profiling data it is often +// desirable to not store the data in the database. +// +// $CFG->disableprofilingtodatabase = true; +// // Force displayed usernames // A little hack to anonymise user names for all students. If you set these // then all non-teachers will always see these for every person. diff --git a/lib/xhprof/xhprof_moodle.php b/lib/xhprof/xhprof_moodle.php index c0d82a8987c..82a1d1a1af7 100644 --- a/lib/xhprof/xhprof_moodle.php +++ b/lib/xhprof/xhprof_moodle.php @@ -882,14 +882,29 @@ class moodle_xhprofrun implements iXHProfRuns { $rec = new stdClass(); $rec->runid = $this->runid; $rec->url = $this->url; - $rec->data = base64_encode(gzcompress(serialize($xhprof_data), 9)); $rec->totalexecutiontime = $this->totalexecutiontime; $rec->totalcputime = $this->totalcputime; $rec->totalcalls = $this->totalcalls; $rec->totalmemory = $this->totalmemory; $rec->timecreated = $this->timecreated; - $DB->insert_record('profiling', $rec); + // Send to database with compressed and endoded data. + if (empty($CFG->disableprofilingtodatabase)) { + $rec->data = base64_encode(gzcompress(serialize($xhprof_data), 9)); + $DB->insert_record('profiling', $rec); + } + + // Send raw data to plugins. + $rec->data = $xhprof_data; + + // Allow a plugin to take the trace data and process it. + if ($pluginsfunction = get_plugins_with_function('store_profiling_data')) { + foreach ($pluginsfunction as $plugintype => $plugins) { + foreach ($plugins as $pluginfunction) { + $pluginfunction($rec); + } + } + } if (PHPUNIT_TEST) { // Calculate export variables.