You are here

public function MongodbXHProfRuns::save_run in XHProf 6

Same name and namespace in other branches
  1. 8 modules/xhprof_mongodb/MongodbXHProfRuns.inc \MongodbXHProfRuns::save_run()
  2. 7 modules/xhprof_mongodb/MongodbXHProfRuns.inc \MongodbXHProfRuns::save_run()

File

modules/xhprof_mongodb/MongodbXHProfRuns.inc, line 77
Definition of MongodbXHProfRuns.

Class

MongodbXHProfRuns
Defines a MongoDB storage backend for XHProf.

Code

public function save_run($xhprof_data, $type, $run_id = NULL) {
  if ($run_id === NULL) {
    $run_id = $this
      ->gen_run_id($type);
  }
  $mongo_id = $run_id;
  module_load_include('module', 'mongodb');
  $collection = mongodb_collection('xhprof');
  $entry = array();
  $entry['_id'] = (string) $mongo_id;
  $entry['run_data'] = $xhprof_data;
  $entry['get'] = serialize($_GET);
  $entry['cookie'] = serialize($_COOKIE);
  $entry['date'] = $_SERVER['REQUEST_TIME'];
  $entry['pmu'] = isset($xhprof_data['main()']['pmu']) ? $xhprof_data['main()']['pmu'] : '';
  $entry['wt'] = isset($xhprof_data['main()']['wt']) ? $xhprof_data['main()']['wt'] : '';
  $entry['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';
  $entry['path'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
  $entry['servername'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
  $collection
    ->save($entry);
  return $run_id;
}