From 3a75a13d3f57d1019db59f5154e912266f1f4fe8 Mon Sep 17 00:00:00 2001
From: James Sansbury <james.sansbury@lullabot.com>
Date: Tue, 15 May 2012 11:09:32 -0400
Subject: [PATCH] Issue #1580018: Add a variable for the performance key.

---
 README.txt         |    8 ++++++++
 performance.module |    8 ++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/README.txt b/README.txt
index f42bad2..e42ed26 100644
--- a/README.txt
+++ b/README.txt
@@ -62,6 +62,14 @@ will be less concurrency and we can cause a site to slow down.
 
 Configuration:
 --------------
+To configure the Performance Logging and Monitoring module, navigate to
+/admin/config/development/performance-logging. By default, this module creates a
+key for each entry based off of the hostname of the site being accessed. If you
+have a site with multiple domains, it is recommended to specify a shared key
+between all sites in your settings.php file:
+
+  $conf['performance_key'] = 'example_key';
+
 If you are using memcache, then you need to configure an extra bin for
 performance. If you have multiple web server boxes, then it is best to
 centralize this bin for all the boxes, so you get combined statistics.
diff --git a/performance.module b/performance.module
index 360a95b..fd28695 100644
--- a/performance.module
+++ b/performance.module
@@ -36,9 +36,7 @@
  * Zend Datacache reference: http://files.zend.com/help/Zend-Server-IBMi/zend_data_cache_-_php_api.htm
  */
 
-define('PERFORMANCE_KEY',            'dru-perf:'. $_SERVER['HTTP_HOST'] .':');
 define('PERFORMANCE_MEMCACHE_BIN',   'cache_performance');
-
 define('PERFORMANCE_ZEND_NAMESPACE', 'dru-perf-'. $_SERVER['HTTP_HOST']);
 define('PERFORMANCE_ZEND_KEYS',      PERFORMANCE_ZEND_NAMESPACE . '::all-of-the-keys');
 
@@ -291,6 +289,12 @@ function performance_caching_message() {
  * Implementation of hook_boot().
  */
 function performance_boot() {
+  // Check for a variable for the performance key. This allows you to set a
+  // unique key in the case that you have multiple domains accessing the same
+  // site. If this is not set, fall back to the hostname.
+  $key = variable_get('performance_key') ? variable_get('performance_key') : $_SERVER['HTTP_HOST'];
+  define('PERFORMANCE_KEY', "dru-perf:{$key}:");
+
   register_shutdown_function('performance_shutdown');
   if (variable_get('performance_query', 0)) {
     //TODO: See if devel.module has changed this ...
-- 
1.7.10

