proxiblue-newrelic - Version 1.0.0

Version Notes

Download this release

Release Info

Developer Lucas van Staden
Extension proxiblue-newrelic
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (34) hide show
  1. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/Dashboard/Diagrams.php +46 -0
  2. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/Dashboard/Tab/Newrelic.php +51 -0
  3. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Button/Accountdetails.php +55 -0
  4. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Button/Appnames.php +55 -0
  5. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Graphurl.php +43 -0
  6. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Ignoremessage.php +43 -0
  7. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Ignoremodule.php +43 -0
  8. app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Tracers.php +43 -0
  9. app/code/community/ProxiBlue/NewRelic/Exception.php +30 -0
  10. app/code/community/ProxiBlue/NewRelic/Helper/Data.php +140 -0
  11. app/code/community/ProxiBlue/NewRelic/Model/Abstract.php +141 -0
  12. app/code/community/ProxiBlue/NewRelic/Model/Adminhtml/System/Config/Source/Select/Appnames.php +78 -0
  13. app/code/community/ProxiBlue/NewRelic/Model/Api.php +119 -0
  14. app/code/community/ProxiBlue/NewRelic/Model/Cache.php +34 -0
  15. app/code/community/ProxiBlue/NewRelic/Model/Index.php +34 -0
  16. app/code/community/ProxiBlue/NewRelic/Model/Log/Exception.php +62 -0
  17. app/code/community/ProxiBlue/NewRelic/Model/Log/System.php +51 -0
  18. app/code/community/ProxiBlue/NewRelic/Model/Log/Writer/Stream.php +61 -0
  19. app/code/community/ProxiBlue/NewRelic/Model/Metrics.php +43 -0
  20. app/code/community/ProxiBlue/NewRelic/Model/Observer.php +170 -0
  21. app/code/community/ProxiBlue/NewRelic/Model/Predispatch/Observer.php +99 -0
  22. app/code/community/ProxiBlue/NewRelic/controllers/ApiController.php +52 -0
  23. app/code/community/ProxiBlue/NewRelic/controllers/TestController.php +52 -0
  24. app/code/community/ProxiBlue/NewRelic/etc/adminhtml.xml +22 -0
  25. app/code/community/ProxiBlue/NewRelic/etc/changelog.txt +36 -0
  26. app/code/community/ProxiBlue/NewRelic/etc/config.xml +148 -0
  27. app/code/community/ProxiBlue/NewRelic/etc/file-list.txt +6 -0
  28. app/code/community/ProxiBlue/NewRelic/etc/system.xml +276 -0
  29. app/code/community/ProxiBlue/NewRelic/sql/proxiblue_newrelic_setup/mysql4-install-0.0.1.php +23 -0
  30. app/code/local/Mage/Core/Exception.php +105 -0
  31. app/design/adminhtml/default/default/template/dashboard/newrelic.phtml +8 -0
  32. app/etc/modules/ProxiBlue_NewRelic.xml +9 -0
  33. js/newrelic.js +56 -0
  34. package.xml +2 -0
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/Dashboard/Diagrams.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+
23
+ /**
24
+ * Admin DashBoard Graphs
25
+ *
26
+ * @category ProxiBlue
27
+ * @package ProxiBlue_NewRelic
28
+ * @author Lucas van Staden (support@proxiblue.com.au)
29
+ **/
30
+
31
+
32
+ class ProxiBlue_NewRelic_Block_Adminhtml_Dashboard_Diagrams extends Mage_Adminhtml_Block_Dashboard_Diagrams
33
+ {
34
+ protected function _prepareLayout()
35
+ {
36
+ parent::_prepareLayout();
37
+ if (Mage::getStoreConfig('newrelic/embeded/enabled')) {
38
+ $this->addTab('newrelic', array(
39
+ 'label' => $this->__('NewRelic'),
40
+ 'content' => $this->getLayout()->createBlock('proxiblue_newrelic/adminhtml_dashboard_tab_newrelic')->toHtml(),
41
+ ));
42
+ }
43
+ return $this;
44
+
45
+ }
46
+ }
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/Dashboard/Tab/Newrelic.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Admin DashBoard Graphs
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_Dashboard_Tab_Newrelic extends Mage_Adminhtml_Block_Dashboard_Abstract
31
+ {
32
+ /**
33
+ * Initialize object
34
+ *
35
+ * @return void
36
+ */
37
+ public function __construct()
38
+ {
39
+ $this->setHtmlId('newrelic');
40
+ parent::__construct();
41
+ $this->setTemplate('dashboard/proxiblue_newrelic.phtml');
42
+ }
43
+
44
+ public function getEmbededGraphs(){
45
+ $embeddedGraphs = unserialize(Mage::getStoreConfig('proxiblue_newrelic/embeded/graph'));
46
+ if (!is_array($embeddedGraphs)) {
47
+ $embeddedGraphs = array();
48
+ }
49
+ return $embeddedGraphs;
50
+ }
51
+ }
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Button/Accountdetails.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Button for account details screen
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Button_AccountDetails extends Mage_Adminhtml_Block_System_Config_Form_Field
31
+ {
32
+
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ $this->setElement($element);
36
+
37
+
38
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
39
+ ->setType('button')
40
+ ->setClass('scalable')
41
+ ->setLabel('Fetch Account Details')
42
+ ->setOnClick("fetchAccountDetails()")
43
+ ->toHtml();
44
+
45
+ $html .= $this->addActionJs();
46
+ return $html;
47
+ }
48
+
49
+ private function addActionJs(){
50
+ $script = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS) . 'newrelic.js';
51
+ $js = '<script type="text/javascript" src="'.$script.'"></script>';
52
+ return $js;
53
+ }
54
+ }
55
+ ?>
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Button/Appnames.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Button for Appnames
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Button_Appnames extends Mage_Adminhtml_Block_System_Config_Form_Field
31
+ {
32
+
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ $this->setElement($element);
36
+
37
+
38
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
39
+ ->setType('button')
40
+ ->setClass('scalable')
41
+ ->setLabel('Fetch Application Names')
42
+ ->setOnClick("fetchApplicationNames()")
43
+ ->toHtml();
44
+
45
+ $html .= $this->addActionJs();
46
+ return $html;
47
+ }
48
+
49
+ private function addActionJs(){
50
+ $script = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS) . 'newrelic.js';
51
+ $js = '<script type="text/javascript" src="'.$script.'"></script>';
52
+ return $js;
53
+ }
54
+ }
55
+ ?>
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Graphurl.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Form Field Graph Url
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Graphurl
31
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
32
+ {
33
+ public function __construct()
34
+ {
35
+ $this->addColumn('string', array(
36
+ 'label' => Mage::helper('proxiblue_newrelic')->__('String'),
37
+ 'style' => 'width:300px',
38
+ ));
39
+ $this->_addAfter = false;
40
+ $this->_addButtonLabel = Mage::helper('proxiblue_newrelic')->__('Add New Graph');
41
+ parent::__construct();
42
+ }
43
+ }
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Ignoremessage.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Admin form field Ignore Message
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Ignoremessage
31
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
32
+ {
33
+ public function __construct()
34
+ {
35
+ $this->addColumn('string', array(
36
+ 'label' => Mage::helper('proxiblue_newrelic')->__('String'),
37
+ 'style' => 'width:200px',
38
+ ));
39
+ $this->_addAfter = false;
40
+ $this->_addButtonLabel = Mage::helper('proxiblue_newrelic')->__('Add New Ignore');
41
+ parent::__construct();
42
+ }
43
+ }
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Ignoremodule.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Admin form field Ignore Message
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Ignoremodule
31
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
32
+ {
33
+ public function __construct()
34
+ {
35
+ $this->addColumn('string', array(
36
+ 'label' => Mage::helper('proxiblue_newrelic')->__('Module Name'),
37
+ 'style' => 'width:200px',
38
+ ));
39
+ $this->_addAfter = false;
40
+ $this->_addButtonLabel = Mage::helper('proxiblue_newrelic')->__('Add New Ignore');
41
+ parent::__construct();
42
+ }
43
+ }
app/code/community/ProxiBlue/NewRelic/Block/Adminhtml/System/Config/Form/Field/Tracers.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Admin form field Ignore Message
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Tracers
31
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
32
+ {
33
+ public function __construct()
34
+ {
35
+ $this->addColumn('string', array(
36
+ 'label' => Mage::helper('proxiblue_newrelic')->__('class::method'),
37
+ 'style' => 'width:400px',
38
+ ));
39
+ $this->_addAfter = false;
40
+ $this->_addButtonLabel = Mage::helper('proxiblue_newrelic')->__('New Tracer');
41
+ parent::__construct();
42
+ }
43
+ }
app/code/community/ProxiBlue/NewRelic/Exception.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * NewRelic module exception
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ */
28
+ class ProxiBlue_NewRelic_Exception extends Mage_Core_Exception
29
+ {
30
+ }
app/code/community/ProxiBlue/NewRelic/Helper/Data.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ *
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ * */
29
+ class ProxiBlue_NewRelic_Helper_Data extends Mage_Core_Helper_Abstract {
30
+
31
+ /**
32
+ * Test if a message should be ignored
33
+ *
34
+ * @param string $message
35
+ * @param string $type
36
+ * @return boolean
37
+ */
38
+ public function ignoreMessage($message, $type) {
39
+ try {
40
+ $ignoreList = unserialize(Mage::getStoreConfig('newrelic/settings/'.$type.'_ignore_message'));
41
+ if (is_array($ignoreList) && count($ignoreList) > 0) {
42
+ array_walk($ignoreList, array($this, 'cleanIgnoreList'));
43
+ //$ignoreList = array_filter($ignoreList, 'strlen');
44
+ return $this->ignoreInString($message, $ignoreList);
45
+ }
46
+ } catch (Exception $e) {
47
+ return true;
48
+ }
49
+ return false; // default - ignore none
50
+ }
51
+
52
+ /**
53
+ * Reformat the config array
54
+ *
55
+ * @param array $item
56
+ * @param string $key
57
+ */
58
+ public function cleanIgnoreList(&$item, $key) {
59
+ $item = $item['string'];
60
+ }
61
+
62
+ /**
63
+ * Check if any of the strings are in the message
64
+ *
65
+ * @param string $message
66
+ * @param array $ignores
67
+ * @return bool
68
+ */
69
+ private function ignoreInString($message, $ignores) {
70
+ $regexp = '/(' . implode('|', array_values($ignores)) . ')/i';
71
+ return (bool) preg_match($regexp, $message);
72
+ }
73
+
74
+ /**
75
+ * Test the given API key is correct
76
+ *
77
+ * @param string $apiKey
78
+ * @return boolean
79
+ */
80
+
81
+ public function testApiKey($apiKey){
82
+ if($apiKey != Mage::getStoreConfig('newrelic/api/api_key')){
83
+ return false;
84
+ }
85
+ return true;
86
+ }
87
+
88
+ public function customMetric($name,$value){
89
+
90
+ if (extension_loaded('newrelic')) {
91
+ try {
92
+ if(!is_numeric($value)){
93
+ throw new Exception('Metric value must be numeric value');
94
+ }
95
+ $this->setAppName();
96
+ return newrelic_custom_metric('Custom/'.$name, $value);
97
+ } catch (Exception $e) {
98
+ Mage::logException($e);
99
+ }
100
+ }
101
+ return false;
102
+ }
103
+
104
+ /**
105
+ * Test if a message should be ignored
106
+ *
107
+ * @param string $message
108
+ * @param string $type
109
+ * @return boolean
110
+ */
111
+ public function ignoreModule($module) {
112
+ try {
113
+ $ignoreList = unserialize(Mage::getStoreConfig('newrelic/settings/ignore_modules'));
114
+ if (is_array($ignoreList) && count($ignoreList) > 0) {
115
+ array_walk($ignoreList, array($this, 'cleanIgnoreList'));
116
+ //$ignoreList = array_filter($ignoreList, 'strlen');
117
+ return $this->ignoreInString($module, $ignoreList);
118
+ }
119
+ } catch (Exception $e) {
120
+ return true;
121
+ }
122
+ return false; // default - ignore none
123
+ }
124
+
125
+ /**
126
+ * Helper function to set the application name used to report
127
+ */
128
+ public function setAppName($xmit = true){
129
+ if (extension_loaded('newrelic')) {
130
+ $application_name = Mage::getStoreConfig('newrelic/api/application_name');
131
+ $license_key = Mage::getStoreConfig('newrelic/api/license_key');
132
+ return newrelic_set_appname($application_name,$license_key,$xmit);
133
+ }
134
+ }
135
+
136
+ public function is_enabled(){
137
+ return Mage::getStoreConfig('newrelic/api/is_enabled');
138
+ }
139
+
140
+ }
app/code/community/ProxiBlue/NewRelic/Model/Abstract.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
5
+ *
6
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with ProxiBlue NewRelic Module.
18
+ * If not, see <http://www.gnu.org/licenses/>.
19
+ * */
20
+ ?>
21
+ <?php
22
+
23
+ /**
24
+ * Base functions to communicate with new relic
25
+ *
26
+ * @category ProxiBlue
27
+ * @package ProxiBlue_NewRelic
28
+ * @author Lucas van Staden (support@proxiblue.com.au)
29
+ * */
30
+ class ProxiBlue_NewRelic_Model_Abstract {
31
+
32
+ protected $_eventType = 'Unknown';
33
+ protected $_headers;
34
+ protected $_account_Id;
35
+ protected $_api_key;
36
+ protected $_data_key;
37
+ protected $_enabled = true;
38
+ protected $_userAgentString = 'ProxiBlue NewRelic for Magento';
39
+
40
+ public function __construct() {
41
+ $this->_userAgentString .= '/' . $this->getExtensionVersion();
42
+ $this->_userAgentString .= ' (https://github.com/ProxiBlue/NewRelic)';
43
+ try {
44
+ $this->setDefaults();
45
+ } catch (Mage_Core_Model_Store_Exception $e) {
46
+ // cannot determine default store id (??)
47
+ // try and load by default store id
48
+ $this->setDefaults(0);
49
+ } catch (Exception $e) {
50
+ $this->_enabled = false;
51
+ mage::logException($e);
52
+ }
53
+ if (empty($this->_account_Id) || empty($this->_api_key) || empty($this->_data_key)) {
54
+ $this->_enabled = false;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Try and load the newrelic configuration for store
60
+ * @param type $store
61
+ */
62
+ private function setDefaults($store = null) {
63
+ $this->_account_Id = Mage::getStoreConfig('newrelic/api/account_id', $store);
64
+ $this->_api_key = Mage::getStoreConfig('newrelic/api/api_key', $store);
65
+ $this->_data_key = Mage::getStoreConfig('newrelic/api/data_access_key', $store);
66
+ }
67
+
68
+ /**
69
+ * If configuration is not set, this will result in false
70
+ * @return type
71
+ */
72
+ public function getEnabled() {
73
+ return $this->_enabled;
74
+ }
75
+
76
+ /**
77
+ * Record index events via curl
78
+ * @param string $type
79
+ * @return \ProxiBlue_NewRelic_Model_Observer
80
+ */
81
+ public function recordEvent($message) {
82
+ $type = $this->_eventType . ": " . $message;
83
+ $application_name = Mage::getStoreConfig('newrelic/api/application_name');
84
+ $user = $this->getCurrentUser();
85
+ $data = "deployment[app_name]={$application_name}&";
86
+ $data .= "deployment[description]={$type}&";
87
+ $data .= "deployment[revision]={$type}&";
88
+ $data .= "deployment[user]={$user}";
89
+ try {
90
+ $response = $this->talkToNewRelic($data);
91
+ if (Mage::app()->getStore()->isAdmin() && !empty($response)) {
92
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__("Event recorded in NewRelic : " . $type));
93
+ }
94
+ } catch (Exception $e) {
95
+ throw ProxiBlue_NewRelic_Exception($e);
96
+ }
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * Get the current user, be it admin or frontend
102
+ */
103
+ public function getCurrentUser() {
104
+ if (Mage::app()->getStore()->isAdmin()) {
105
+ if (is_object(Mage::getSingleton('admin/session')->getUser())) {
106
+ return Mage::getSingleton('admin/session')->getUser()->getEmail();
107
+ } else {
108
+ return 'Shell Script';
109
+ }
110
+ } else if (Mage::getSingleton('customer/session')->isLoggedIn()) {
111
+ return Mage::getSingleton('customer/session')->getCustomer()->getId() . ' / ' . Mage::getSingleton('customer/session')->getCustomer()->getEmail();
112
+ } else {
113
+ return 'Guest User - not Logged in';
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Talk to NewRelic API
119
+ *
120
+ * @param array $data
121
+ * @return string
122
+ */
123
+ public function talkToNewRelic($data) {
124
+ $headers = array(
125
+ 'x-api-key:' . $this->_api_key,
126
+ 'User-Agent:' . $this->_userAgentString
127
+ );
128
+ $http = new Varien_Http_Adapter_Curl();
129
+ $http->write('POST', 'https://rpm.newrelic.com/deployments.xml', '1.1', $headers, $data);
130
+ $response = $http->read();
131
+ $response = Zend_Http_Response::extractBody($response);
132
+ return $response;
133
+ }
134
+
135
+ public function getExtensionVersion()
136
+ {
137
+ return (string) Mage::getConfig()->getNode()->modules->ProxiBlue_NewRelic->version;
138
+ }
139
+
140
+
141
+ }
app/code/community/ProxiBlue/NewRelic/Model/Adminhtml/System/Config/Source/Select/Appnames.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Options for admin select for AppNAmes
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Adminhtml_System_Config_Source_Select_Appnames
31
+ {
32
+
33
+ /**
34
+ * Holds app names
35
+ * @var array
36
+ */
37
+ protected $_appnames = array();
38
+
39
+ /**
40
+ * Constructor
41
+ */
42
+ public function __construct() {
43
+ $appnames = Mage::getStoreConfig('newrelic/appnames/lookup');
44
+ if(!is_string($appnames)){
45
+ $appnames = '';
46
+ }
47
+ $this->_appnames = unserialize($appnames);
48
+ }
49
+
50
+ /**
51
+ * Options getter
52
+ *
53
+ * @return array
54
+ */
55
+ public function toOptionArray()
56
+ {
57
+ $optionArray = array();
58
+ try {
59
+ foreach ($this->_appnames as $appname){
60
+ $optionArray[] = array('value' => $appname, 'label'=>$appname);
61
+ }
62
+ } catch (Exception $e){
63
+ Mage::logException($e);
64
+ }
65
+ return $optionArray;
66
+ }
67
+
68
+ /**
69
+ * Get options in "key-value" format
70
+ *
71
+ * @return array
72
+ */
73
+ public function toArray()
74
+ {
75
+ return $this->_appnames;
76
+ }
77
+
78
+ }
app/code/community/ProxiBlue/NewRelic/Model/Api.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * New Relic General API model
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+ class ProxiBlue_NewRelic_Model_Api extends ProxiBlue_NewRelic_Model_Abstract
30
+ {
31
+
32
+ protected $_eventType = 'Api';
33
+
34
+ /**
35
+ * Get the application names
36
+ *
37
+ * @return array
38
+ */
39
+ public function getApplications()
40
+ {
41
+ $result = $this->talkToNewRelic('applications');
42
+ // parse the xml
43
+ try {
44
+ $xmlObj = simplexml_load_string($result);
45
+ $applications = array();
46
+ foreach ($xmlObj->application as $key => $app) {
47
+ $applications[] = (string)$app->name;
48
+ }
49
+ //save the applications to the system for list lookup in admin
50
+ $config = new Mage_Core_Model_Config();
51
+ $config->saveConfig('newrelic/appnames/lookup/', serialize($applications), 'default', 0);
52
+
53
+ return $applications;
54
+ } catch (Exception $e) {
55
+ return array('error' => $result);
56
+ }
57
+
58
+ }
59
+
60
+ /**
61
+ * Get the New Relic Account Details
62
+ *
63
+ * @return array
64
+ */
65
+ public function getAccountDetails()
66
+ {
67
+ $headers = array(
68
+ 'x-api-key:' . $this->_api_key
69
+ );
70
+ $http = new Varien_Http_Adapter_Curl();
71
+
72
+ $http->write('GET', 'https://api.newrelic.com/api/v1/accounts.xml', '1.1', $headers);
73
+ $read = $http->read();
74
+ $response = Zend_Http_Response::extractBody($read);
75
+ try {
76
+ // parse the xml
77
+ $xmlObj = simplexml_load_string($response);
78
+ $accountDetails = array('accountid' => (string)$xmlObj->account->id,
79
+ 'accesskey' => (string)$xmlObj->account->{"data-access-key"},
80
+ 'licensekey' => (string)$xmlObj->account->{"license-key"}
81
+ );
82
+ $config = new Mage_Core_Model_Config();
83
+ $config->saveConfig('newrelic/api/account_id', $accountDetails['accountid'], 'default', 0);
84
+ $config->saveConfig('newrelic/api/data_access_key', $accountDetails['accesskey'], 'default', 0);
85
+ $config->saveConfig('newrelic/api/license_key', $accountDetails['licensekey'], 'default', 0);
86
+
87
+ return $accountDetails;
88
+ } catch (Exception $e) {
89
+ return array('error' => $read);
90
+ }
91
+
92
+ }
93
+
94
+ /**
95
+ * Talk to new relic
96
+ *
97
+ * @param string $restPoint
98
+ *
99
+ * @return string
100
+ */
101
+ public function talkToNewRelic($restPoint)
102
+ {
103
+ $headers = array(
104
+ 'x-api-key:' . $this->_api_key,
105
+ 'User-Agent:' . $this->_userAgentString
106
+ );
107
+ $http = new Varien_Http_Adapter_Curl();
108
+
109
+ $http->write(
110
+ 'GET', 'https://api.newrelic.com/api/v1/accounts/' . $this->_account_Id . '/' . $restPoint . '.xml', '1.1',
111
+ $headers
112
+ );
113
+ $response = $http->read();
114
+ $response = Zend_Http_Response::extractBody($response);
115
+
116
+ return $response;
117
+ }
118
+
119
+ }
app/code/community/ProxiBlue/NewRelic/Model/Cache.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Cache Log Model
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Cache extends ProxiBlue_NewRelic_Model_Abstract {
31
+
32
+ protected $_eventType = 'Cache';
33
+
34
+ }
app/code/community/ProxiBlue/NewRelic/Model/Index.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Indexer log model
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Index extends ProxiBlue_NewRelic_Model_Abstract {
31
+
32
+ protected $_eventType = 'Index';
33
+
34
+ }
app/code/community/ProxiBlue/NewRelic/Model/Log/Exception.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * LOgs logging model
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Log_Exception extends ProxiBlue_NewRelic_Model_Abstract {
31
+
32
+ protected $_eventType = 'Exception';
33
+
34
+ /**
35
+ * Record an exception event
36
+ *
37
+ * @param Object $e
38
+ */
39
+ public function recordEvent($e) {
40
+ if(Mage::getStoreConfig('newrelic/settings/record_exception') && !Mage::helper('proxiblue_newrelic')->ignoreMessage($e->getMessage(), 'exception')){
41
+ self::pushEvent($e);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Static since a store config exception (caused by a module config error) cannot call magento's model objects.
47
+ * If a store config exception occurs, the exception class logs it drect.
48
+ *
49
+ * @param type $e
50
+ */
51
+ static public function pushEvent($e,$setAppName=true){
52
+ if (extension_loaded('newrelic')) {
53
+ $message = $e->getMessage();
54
+ $message = (empty($message))?get_class($e):$message;
55
+ if($setAppName) {
56
+ Mage::helper('proxiblue_newrelic')->setAppName();
57
+ }
58
+ newrelic_notice_error ($message, $e);
59
+ }
60
+ }
61
+
62
+ }
app/code/community/ProxiBlue/NewRelic/Model/Log/System.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * LOgs logging model
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ * */
29
+ class ProxiBlue_NewRelic_Model_Log_System extends ProxiBlue_NewRelic_Model_Abstract {
30
+
31
+ protected $_eventType = 'System Log Entry';
32
+
33
+ /**
34
+ * Record a log event to new relic
35
+ *
36
+ * @param type $event
37
+ * @return type
38
+ */
39
+ public function recordEvent($event) {
40
+ if (extension_loaded('newrelic')) {
41
+ if (Mage::getStoreConfig('newrelic/settings/record_system_log') && !Mage::helper('proxiblue_newrelic')->ignoreMessage($event['message'], 'system_log')) {
42
+ if ($event['priorityName'] == 'DEBUG' && Mage::getStoreConfig('newrelic/settings/system_log_ignore_debug')) {
43
+ return;
44
+ }
45
+ Mage::helper('proxiblue_newrelic')->setAppName();
46
+ newrelic_notice_error($this->_eventType . ': [' . $event['priorityName'] . '] '. $event['message']);
47
+ }
48
+ }
49
+ }
50
+
51
+ }
app/code/community/ProxiBlue/NewRelic/Model/Log/Writer/Stream.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Intercept logs to new relic
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_Newrelic_Model_Log_Writer_Stream extends Zend_Log_Writer_Stream {
31
+
32
+ /**
33
+ * Write a message to the log.
34
+ *
35
+ * @param array $event event data
36
+ * @return void
37
+ */
38
+ protected function _write($event) {
39
+ parent::_write($event);
40
+ // Log to NewRelic
41
+ self::_log_to_newrelic($event);
42
+ }
43
+
44
+ /**
45
+ * Record the event in New Relic
46
+ *
47
+ * @param array $event event data
48
+ * @return void
49
+ */
50
+ public static function _log_to_newrelic($event) {
51
+ // Log the event to New Relic
52
+ try {
53
+ if (array_key_exists('priorityName', $event) && $event['priorityName'] != 'ERR') {
54
+ $newRelic = Mage::getModel('proxiblue_newrelic/log_system');
55
+ $newRelic->recordEvent($event);
56
+ }
57
+ } catch (Exception $e) {
58
+ // cannot log it else we end up in a loop.
59
+ }
60
+ }
61
+ }
app/code/community/ProxiBlue/NewRelic/Model/Metrics.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Observers for custom metrics
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Metrics {
31
+
32
+ /**
33
+ * Hook to record customer account create metrics
34
+ * @param Varien_Event_Observer $observer
35
+ */
36
+
37
+ public function customer_register_success(Varien_Event_Observer $observer) {
38
+ if (Mage::getStoreConfig('newrelic/metrics/signup_success')) {
39
+ Mage::helper('proxiblue_newrelic')->customMetric('Registration/Success',1);
40
+ return $this;
41
+ }
42
+ }
43
+ }
app/code/community/ProxiBlue/NewRelic/Model/Observer.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Observers for cache and index events
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ **/
29
+
30
+ class ProxiBlue_NewRelic_Model_Observer {
31
+
32
+ /**
33
+ * Hook to record cache events
34
+ *
35
+ * @param Varien_Event_Observer $observer
36
+ *
37
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
38
+ */
39
+
40
+ public function adminhtml_cache_refresh_type(Varien_Event_Observer $observer) {
41
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
42
+ $event = $observer->getEvent();
43
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
44
+ $newRelic->recordEvent($event->getType());
45
+ return $this;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Hook to record cache full flush
51
+ * @param Varien_Event_Observer $observer
52
+ *
53
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
54
+ */
55
+
56
+ public function adminhtml_cache_flush_all(Varien_Event_Observer $observer) {
57
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
58
+ $event = $observer->getEvent();
59
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
60
+ $newRelic->recordEvent('Storage');
61
+ return $this;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Hook to record cache storage
67
+ *
68
+ * @param Varien_Event_Observer $observer
69
+ *
70
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
71
+ */
72
+
73
+ public function adminhtml_cache_flush_system(Varien_Event_Observer $observer) {
74
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
75
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
76
+ $newRelic->recordEvent('Full Flush');
77
+ return $this;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Hook to record cache storage
83
+ *
84
+ * @param Varien_Event_Observer $observer
85
+ *
86
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
87
+ */
88
+
89
+ public function clean_media_cache_after(Varien_Event_Observer $observer) {
90
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
91
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
92
+ $newRelic->recordEvent('CSS/JS');
93
+ return $this;
94
+ }
95
+ }
96
+
97
+
98
+ /**
99
+ * Hook to record cache storage
100
+ *
101
+ * @param Varien_Event_Observer $observer
102
+ *
103
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
104
+ */
105
+
106
+ public function clean_catalog_images_cache_after(Varien_Event_Observer $observer) {
107
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
108
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
109
+ $newRelic->recordEvent('media');
110
+ return $this;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Hook to record swatch image cache
116
+ *
117
+ * @param Varien_Event_Observer $observer
118
+ *
119
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
120
+ */
121
+
122
+ public function clean_configurable_swatches_cache_after(Varien_Event_Observer $observer) {
123
+ if (Mage::getStoreConfig('newrelic/settings/record_cache')) {
124
+ $newRelic = Mage::getModel('proxiblue_newrelic/cache');
125
+ $newRelic->recordEvent('swatch');
126
+ return $this;
127
+ }
128
+ }
129
+
130
+
131
+
132
+ /**
133
+ * Hook to record index events
134
+ *
135
+ * @param Varien_Event_Observer $observer
136
+ *
137
+ * @return $this \ProxiBlue_NewRelic_Model_Observer
138
+ */
139
+ public function controller_action_postdispatch_adminhtml_process_massReindex(Varien_Event_Observer $observer) {
140
+ if (Mage::getStoreConfig('newrelic/settings/record_index')) {
141
+ $vProcessIds = Mage::app()->getRequest()->getParam('process');
142
+ $aProcessIds = (array) $vProcessIds;
143
+ if (empty($aProcessIds) || !is_array($aProcessIds)) {
144
+ return $this;
145
+ } else {
146
+ $newRelic = Mage::getModel('proxiblue_newrelic/index');
147
+ try {
148
+ $indexer = Mage::getSingleton('index/indexer');
149
+ foreach ($aProcessIds as $processId) {
150
+ /* @var $process Mage_Index_Model_Process */
151
+ $process = $indexer->getProcessById($processId);
152
+ $newRelic->recordEvent($process->getIndexerCode());
153
+ }
154
+ } catch (Exception $e) {
155
+ Mage::logException($e);
156
+ return $this;
157
+ }
158
+ }
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Hook to record index events
164
+ * @param Varien_Event_Observer $observer
165
+ */
166
+ public function controller_action_postdispatch_adminhtml_process_reindexProcess(Varien_Event_Observer $observer) {
167
+ $this->controller_action_postdispatch_adminhtml_process_massReindex($observer);
168
+ }
169
+
170
+ }
app/code/community/ProxiBlue/NewRelic/Model/Predispatch/Observer.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ /**
23
+ * Observers for cache and index events
24
+ *
25
+ * @category ProxiBlue
26
+ * @package ProxiBlue_NewRelic
27
+ * @author Lucas van Staden (support@proxiblue.com.au)
28
+ * */
29
+ class ProxiBlue_NewRelic_Model_PreDispatch_Observer
30
+ {
31
+
32
+ /**
33
+ * Hook to record all fron controller events
34
+ *
35
+ * @param Varien_Event_Observer $observer
36
+ */
37
+ public function controller_action_predispatch(Varien_Event_Observer $observer)
38
+ {
39
+ try {
40
+ if (extension_loaded('newrelic')) {
41
+
42
+ $controllerAction = $observer->getControllerAction();
43
+ $request = $controllerAction->getRequest();
44
+ $controllerName = explode("_", $request->getControllerName());
45
+ if (Mage::getStoreConfig('newrelic/settings/ignore_admin_routes')
46
+ && $request->getRouteName() == 'adminhtml'
47
+ || $request->getModuleName() == 'admin'
48
+ || in_array('adminhtml', $controllerName)
49
+ ) {
50
+ Mage::helper('proxiblue_newrelic')->setAppName(false);
51
+ newrelic_ignore_transaction();
52
+ newrelic_ignore_apdex();
53
+
54
+ return $this;
55
+ }
56
+ if (mage::helper('proxiblue_newrelic')->ignoreModule($request->getModuleName()) === true) {
57
+ Mage::helper('proxiblue_newrelic')->setAppName(false);
58
+ newrelic_ignore_transaction();
59
+ newrelic_ignore_apdex();
60
+
61
+ return $this;
62
+ }
63
+ if (Mage::getStoreConfig('newrelic/settings/named_transactions')) {
64
+ $route
65
+ =
66
+ $request->getRouteName() . '/' . $request->getControllerName() . '/' . $request->getActionName(
67
+ );
68
+ if (Mage::getStoreConfig('newrelic/settings/add_module_to_named_transactions')) {
69
+ $route .= ' (module: ' . $request->getModuleName() . ')';
70
+ }
71
+ newrelic_name_transaction($route);
72
+ Mage::helper('proxiblue_newrelic')->setAppName(true);
73
+
74
+ return $this;
75
+ }
76
+ // tracers
77
+ $tracerList = unserialize(Mage::getStoreConfig('newrelic/settings/custom_tracers'));
78
+ if (is_array($tracerList) && count($tracerList) > 0) {
79
+ foreach ($tracerList as $tracer) {
80
+ newrelic_add_custom_tracer($tracer['string']);
81
+ }
82
+ }
83
+ }
84
+ } catch (Exception $e) {
85
+ mage::logException($e);
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Reformat the config array
91
+ *
92
+ * @param array $item
93
+ * @param string $key
94
+ */
95
+ public function cleanTacerList(&$item, $key)
96
+ {
97
+ $item = $item['string'];
98
+ }
99
+ }
app/code/community/ProxiBlue/NewRelic/controllers/ApiController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ class ProxiBlue_NewRelic_ApiController extends Mage_Core_Controller_Front_Action {
23
+
24
+
25
+ public function namesAction() {
26
+ if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
27
+ $newRelicApi = Mage::getModel('proxiblue_newrelic/api');
28
+ $applications = $newRelicApi->getApplications();
29
+ $this->getResponse()->setHeader('Content-type', 'application/json');
30
+ $this->getResponse()->setBody(json_encode(array('result'=>$applications)));
31
+ } else {
32
+ $this->getResponse()->setHeader('Content-type', 'application/json');
33
+ $this->getResponse()->setBody(json_encode(array('error'=>'Invalid API key given')));
34
+ }
35
+ return $this;
36
+ }
37
+
38
+ public function accountDetailsAction() {
39
+ if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
40
+ $newRelicApi = Mage::getModel('proxiblue_newrelic/api');
41
+ $accountDetails = $newRelicApi->getAccountDetails();
42
+ $this->getResponse()->setHeader('Content-type', 'application/json');
43
+ $this->getResponse()->setBody(json_encode($accountDetails));
44
+ } else {
45
+ $this->getResponse()->setHeader('Content-type', 'application/json');
46
+ $this->getResponse()->setBody(json_encode(array('error'=>'Invalid API key given')));
47
+ }
48
+ return $this;
49
+
50
+ }
51
+
52
+ }
app/code/community/ProxiBlue/NewRelic/controllers/TestController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+
22
+ class ProxiBlue_NewRelic_TestController extends Mage_Core_Controller_Front_Action {
23
+
24
+ public function systemLogAction() {
25
+ if (Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
26
+ Mage::log('This is a newrelic test system log entry');
27
+ die('Test log Entry done. Wait a moment and check newrelic errors.');
28
+ } else {
29
+ $this->getResponse()->setHeader('Content-type', 'application/json');
30
+ $this->getResponse()->setBody(json_encode(array('error' => 'Invalid API key given')));
31
+ }
32
+ }
33
+
34
+ public function exceptionLogAction() {
35
+ if (Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
36
+ try {
37
+ Mage::throwException('Test exception thrown');
38
+ } catch (Exception $e) {
39
+ Mage::logException($e);
40
+ }
41
+ die('Test Exception thrown. Wait a moment and check newrelic errors.');
42
+ } else {
43
+ $this->getResponse()->setHeader('Content-type', 'application/json');
44
+ $this->getResponse()->setBody(json_encode(array('error' => 'Invalid API key given')));
45
+ }
46
+ }
47
+
48
+ public function exceptionAction(){
49
+ $this->_forward('exceptionLog');
50
+ }
51
+
52
+ }
app/code/community/ProxiBlue/NewRelic/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <newrelic translate="title" module="proxiblue_newrelic">
12
+ <title>NewRelic</title>
13
+ </newrelic>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/ProxiBlue/NewRelic/etc/changelog.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0.0.2 - Initial Public release.
2
+ 0.0.3 - Bug fix release
3
+ - If 'Do Not record these log entries' was blank, then all system.log messages were ignored.
4
+ - Fix typo in documentation.
5
+ 0.0.4 - Bug fix release
6
+ - Endless loop if error in config files.
7
+ - Endless loop of module dependency fails
8
+ 0.0.5 - change _writer method to public
9
+ 0.1.0 - Add ability to ignore admin
10
+ - Add ability to ignore modules
11
+ - Add ability to name transactions
12
+ - Add ability to add module name to named transactions
13
+ - Move config menu option to proxiblue tab
14
+ 0.1.1 - Bug Fix: #14 - Notice: undefined index 'class'
15
+ 0.1.3 - Add appname to agent commands
16
+ 0.1.4 - Further adjustments to set correct appname when using the newrelic php agent commands
17
+ - Add license key field in admin, and adjust to populate correctly
18
+ 0.1.5 - Adjust Exception push to not set appName if error is pushed direct from exceptions.
19
+ 0.1.6 - Fix incorrect php closing tag - https://github.com/ProxiBlue/NewRelic/pull/10
20
+ 0.1.7 - Change way that charts are embeded into dashboard
21
+ 0.1.8 - Fix double >> in config.xml for closing tag
22
+ 0.1.9 - Fixed ajax requests for cases when store is installed into a subfolder
23
+ 0.1.10 - Deal better with store id not found when logging. Highlighted when commercebug module is also in use.
24
+ 0.1.11 - Modman and composer files missed
25
+ 0.1.12 - Remove activation of wishlist in setup. Not sure why it was there
26
+ 0.1.13 - Fix issue where admin pages are still sent to newrelic, even when admin is set to not log admin pages
27
+ 0.1.14 - Move namespace to proxiblue_newrelic
28
+ 0.1.15 - Add ability to trace methods. some error trapping in account details fetching
29
+ - Record swatch cache clean
30
+ 0.1.16 - Fix some missed namespace changes
31
+ 1.0.0 - Make a full release version, its about time.
32
+ - Ads in useragent string as per newrelic requirements
33
+
34
+ Reproducing error for 0.0.4 bug release.
35
+ In any app/etc/module/ config xml file place a depends to a non-existing module.
36
+
app/code/community/ProxiBlue/NewRelic/etc/config.xml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <ProxiBlue_NewRelic>
5
+ <version>1.0.0</version>
6
+ </ProxiBlue_NewRelic>
7
+ </modules>
8
+ <global>
9
+ <request>
10
+ <direct_front_name>
11
+ <proxiblue_newrelic/>
12
+ </direct_front_name>
13
+ </request>
14
+ <models>
15
+ <proxiblue_newrelic>
16
+ <class>ProxiBlue_NewRelic_Model</class>
17
+ </proxiblue_newrelic>
18
+ </models>
19
+ <blocks>
20
+ <proxiblue_newrelic>
21
+ <class>ProxiBlue_NewRelic_Block</class>
22
+ </proxiblue_newrelic>
23
+ <adminhtml>
24
+ <rewrite>
25
+ <dashboard_diagrams>ProxiBlue_NewRelic_Block_Adminhtml_Dashboard_Diagrams</dashboard_diagrams>
26
+ </rewrite>
27
+ </adminhtml>
28
+ </blocks>
29
+ <helpers>
30
+ <proxiblue_newrelic>
31
+ <class>ProxiBlue_NewRelic_Helper</class>
32
+ </proxiblue_newrelic>
33
+ </helpers>
34
+ <events>
35
+ <adminhtml_cache_refresh_type>
36
+ <observers>
37
+ <proxiblue_newrelic_adminhtml_cache_refresh_type>
38
+ <type>singleton</type>
39
+ <class>proxiblue_newrelic/observer</class>
40
+ <method>adminhtml_cache_refresh_type</method>
41
+ </proxiblue_newrelic_adminhtml_cache_refresh_type>
42
+ </observers>
43
+ </adminhtml_cache_refresh_type>
44
+ <controller_action_postdispatch_adminhtml_process_massReindex>
45
+ <observers>
46
+ <proxiblue_newrelic_controller_action_postdispatch_adminhtml_process_massReindex>
47
+ <class>proxiblue_newrelic/observer</class>
48
+ <method>controller_action_postdispatch_adminhtml_process_massReindex</method>
49
+ </proxiblue_newrelic_controller_action_postdispatch_adminhtml_process_massReindex>
50
+ </observers>
51
+ </controller_action_postdispatch_adminhtml_process_massReindex>
52
+ <controller_action_postdispatch_adminhtml_process_reindexProcess>
53
+ <observers>
54
+ <proxiblue_newrelic_controller_action_postdispatch_adminhtml_process_reindexProcess>
55
+ <class>proxiblue_newrelic/observer</class>
56
+ <method>controller_action_postdispatch_adminhtml_process_reindexProcess</method>
57
+ </proxiblue_newrelic_controller_action_postdispatch_adminhtml_process_reindexProcess>
58
+ </observers>
59
+ </controller_action_postdispatch_adminhtml_process_reindexProcess>
60
+ <adminhtml_cache_flush_all>
61
+ <observers>
62
+ <proxiblue_newrelic_adminhtml_cache_flush_all>
63
+ <class>proxiblue_newrelic/observer</class>
64
+ <method>adminhtml_cache_flush_all</method>
65
+ </proxiblue_newrelic_adminhtml_cache_flush_all>
66
+ </observers>
67
+ </adminhtml_cache_flush_all>
68
+ <adminhtml_cache_flush_system>
69
+ <observers>
70
+ <proxiblue_newrelic_adminhtml_cache_flush_system>
71
+ <class>proxiblue_newrelic/observer</class>
72
+ <method>adminhtml_cache_flush_system</method>
73
+ </proxiblue_newrelic_adminhtml_cache_flush_system>
74
+ </observers>
75
+ </adminhtml_cache_flush_system>
76
+ <clean_media_cache_after>
77
+ <observers>
78
+ <proxiblue_newrelic_clean_media_cache_after>
79
+ <class>proxiblue_newrelic/observer</class>
80
+ <method>clean_media_cache_after</method>
81
+ </proxiblue_newrelic_clean_media_cache_after>
82
+ </observers>
83
+ </clean_media_cache_after>
84
+ <clean_catalog_images_cache_after>
85
+ <observers>
86
+ <proxiblue_newrelic_clean_catalog_images_cache_after>
87
+ <class>proxiblue_newrelic/observer</class>
88
+ <method>clean_catalog_images_cache_after</method>
89
+ </proxiblue_newrelic_clean_catalog_images_cache_after>
90
+ </observers>
91
+ </clean_catalog_images_cache_after>
92
+ <controller_action_predispatch>
93
+ <observers>
94
+ <proxiblue_newrelic_controller_action_predispatch>
95
+ <class>proxiblue_newrelic/predispatch_observer</class>
96
+ <method>controller_action_predispatch</method>
97
+ </proxiblue_newrelic_controller_action_predispatch>
98
+ </observers>
99
+ </controller_action_predispatch>
100
+ </events>
101
+ <resources>
102
+ <proxiblue_proxiblue_newrelic_setup>
103
+ <setup>
104
+ <module>ProxiBlue_NewRelic</module>
105
+ </setup>
106
+ <connection>
107
+ <use>core_setup</use>
108
+ </connection>
109
+ </proxiblue_proxiblue_newrelic_setup>
110
+ </resources>
111
+ <log>
112
+ <core>
113
+ <writer_model>ProxiBlue_NewRelic_Model_Log_Writer_Stream</writer_model>
114
+ </core>
115
+ </log>
116
+ </global>
117
+ <frontend>
118
+ <events>
119
+ <!-- custom metrics -->
120
+ <customer_register_success>
121
+ <observers>
122
+ <proxiblue_newrelic_customer_register_success>
123
+ <class>proxiblue_newrelic/metrics</class>
124
+ <method>customer_register_success</method>
125
+ </proxiblue_newrelic_customer_register_success>
126
+ </observers>
127
+ </customer_register_success>
128
+ </events>
129
+ <routers>
130
+ <proxiblue_newrelic>
131
+ <use>standard</use>
132
+ <args>
133
+ <module>ProxiBlue_NewRelic</module>
134
+ <frontName>proxiblue_newrelic</frontName>
135
+ </args>
136
+ </proxiblue_newrelic>
137
+ </routers>
138
+ </frontend>
139
+ <adminhtml>
140
+ <layout>
141
+ <updates>
142
+ <proxiblue_newrelic>
143
+ <file>proxiblue_newrelic.xml</file>
144
+ </proxiblue_newrelic>
145
+ </updates>
146
+ </layout>
147
+ </adminhtml>
148
+ </config>
app/code/community/ProxiBlue/NewRelic/etc/file-list.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /app/code/community/ProxiBlue/NewRelic
2
+ /app/etc/modules/ProxiBlue_NewRelic.xml
3
+ /app/design/adminhtml/default/default/template/dashboard/newrelic.phtml
4
+ /app/code/local/Mage/Core/Exception.php
5
+ /js/newrelic.js
6
+
app/code/community/ProxiBlue/NewRelic/etc/system.xml ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <proxiblue translate="label" module="proxiblue_newrelic">
5
+ <label><![CDATA[<div style="background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAQCAYAAADdw7vlAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAB3RJTUUH3QYVDxgK42HBJgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAGYktHRAD/AP8A/6C9p5MAAAZ8SURBVFjDzZlrbBVFFMf3ttjSllBEogaDFB9oQHwFVKJQoEAQ0kaEWIwPRAWNoF+KEk1BYtHoB9FE5eEj0aCoMVExWlF6725BExVI0EJFkUjQgKASNCKI7Iz/M3uWu92d2d3bWxM2+eXe3Xnu+c+ZMzNrWfmrClSHoGcZy3xRWt9QGbqvsAq/KrlsH1ASk4/STktda5sssXIimj/nVoFKK+tGy9iiAmnVCkdUW7bbF88qT6Y70rI2aMpROznZz8qKTGK/HPSL6s655TF5StEu5SnR9LEX6Kf6aAdQ91RGRt55JdgGOviX2ASeA8MNXRhIJgTfBNgKPgVLwRkpJLgQtICNgfIrwCRD/mfAsmQDCt8Qt4EVGgOtAcshSrkm7XHwLfgabANbQbtly6Uw3PleHt3AkJPBLghcnULgoZbjfglB5sXkuRLt7kQfa6JtuaPAD0jfDnaE2I5+TouMdfArGA9GgmtAPWgHR8EVmi5Qw7+Dj7jMaDAWzAa7wc8J3ngDOEavAm4BU8B08C6Am1gPaWaQSZzWZDaM64tcDyNIvPBcjYhfIf19GLFCk/YW6EDaGBh3JIx1Ne4bwF6wG6JcrhGD2mtEurSyMnlgUx22OIr6l8QM0loMGIn2L9L0cbxqy0abOTENTM0j6XdguAh53Y+aZspAJwthEvh5TVodl3nZ0P2hLNSLhjDQzOkTNWnTOG1K6KWD/+s8A8gFnkFl2Nu+gAHfMwj8JtLakEeXBoOLZgycTHECi8uQ92/0a3GMB4/12tMI7Ehf4HPNbchUAtP1FPgXXGIQ+AVDOfLgg4bYfQBsiTFBb5AFewzpN7PID2qMN0u9vOM+bKw9WeAs8lSGnpcqz7bFs+p/0QJLCCyKFXhw2uVInMB3AZr3JhQo8D5DnRN5wMxP6NMSFvEcQ7rvyY+pUNAmSYSpaloLTsv6hRQElvECOwGB8zH9OGiyPhRWD3lw86kg8JPgOLi4AIHnALLCQk3aoyzMoIQ+Xc8DYUFMnlpwb2DxMQLGm8xeanXbg20InBN9QKnCew7Pld9jIJ1dfAyWvsCLuiUwxWCHZik5xJtZsOJWq26ZKVRgWhH+witcXQz+Daxjr5wKGngBdJhew9DWahY46RoB/gDLUw3RnJt+UxYv8OvsqZ3I18kr00PsMU0weO+eEVh2X2BHjPPCkNwBOpjv1CCMEXg/GMWGvQrcyQssej7YIPABHgCf8VZnH4vXErNfXZVS4EvBn1zX/yCwcYpe622R5CwY8kbkmY7/MwFtn46BN9BWry6LGOcECdKowkNWpF1FUwx+JF5gaZ6iHUkC34M+zmBuQt7RpurWs9GDCPa2KkMZf4peETiEyPAeegsfWsTF1poEMzRwH+p7fooW7MGuRmCXpui2LjFYxXJMfxTjHVeqGBrxYDe9B9tiONr/C/U8ETMIx0Ewasu8Tcq5Ucf7XBg9eC8YAM4E/VP4gSkGU2w9YYi/Fk/lcen+1cIDIZN+kYU9oDeVplhkkcDCHIPDAntpF8Dg+9VhSDFTtC0GoMwh1NWq3cZ5As9DniOgJmYf3COLrEIFpusVXphZhr31Yfb0UkOeCo77rYVvk9wU26RuCuyIYTxN31GUwF5deyDiQWt9KKb7ocaWO1Hfx5Ht2ikisH/QsdJQdgwL9JpBZDpZ+wecl/qgIyeC/+u8UyzXcNARN0ULf4rWpT2gVq+27B85Gs3H4NO1b7xBePn8fuZErVeX26IZpE3czjzDAGWB3UFpxaJDhZ8KFHgIe6JJRIrDRwwLNLruZi/fDOayV97Pizo66rxWUyb5qNL3AEfWR6brvIE2w4DrDB5MR5W7wEyk0756CpiB+6d50bMQ4pRoPHgWtzcf+W7PI2ZDiPGR/J6XrkK66y3s3Dn4pfyvoq4TaOftmBloArd1H+qY3bU9ukdfQh8yaK+7pkCBzwLvxOxT6fz6E3BrTB3DOIa28pn0WhavuqiPDXbixwY6jVoMo5Zp0hYBW+FIOtEC4gP8LoPRrzOseKkceeQG0I77jXnEpkjMzspAH10MILHa23tLtCtfwrNG7RFs/hntozcCp2tbCmqvVX1VClzlVuGf+TJcpiwmT2VCevBokvL2SsjXjc+F0U9nMGJvGKBcu7XKyTIVfwn6TKj+h746hY3uHLPUYYMt/fyVJ+tQ9chy7aDwr3bVzwrvU2VgdsgJ0wq7BOWruO5QW6rtCqr/PxaK59gvlOuoAAAAAElFTkSuQmCC) no-repeat; width: 155px; height: 20px;"></div>]]></label>
6
+ <sort_order>10000000</sort_order>
7
+ </proxiblue>
8
+ </tabs>
9
+ <sections>
10
+ <newrelic translate="label" module="proxiblue_newrelic">
11
+ <label>NewRelic</label>
12
+ <tab>proxiblue</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>342</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <api translate="label">
20
+ <label>Api Connection</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <api_key translate="label">
28
+ <label>API Key</label>
29
+ <comment><![CDATA[<a target="_blank" href="http://www.proxiblue.com.au/newrelic-how-to-get-api-key">How to find your API Key</a> <strong>Remember to click 'Save Config' after changed or else the buttons below will not work</strong>]]></comment>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </api_key>
36
+ <fetch_account_id translate="label">
37
+ <label>Fetch Account Details</label>
38
+ <comment><![CDATA[Click to fetch your Account Details]]></comment>
39
+ <frontend_type>button</frontend_type>
40
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_button_accountdetails</frontend_model>
41
+ <sort_order>2</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </fetch_account_id>
46
+ <account_id translate="label">
47
+ <label>Account ID</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>3</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </account_id>
54
+ <data_access_key translate="label">
55
+ <label>Data access key</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>4</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </data_access_key>
62
+ <license_key translate="label">
63
+ <label>License Key</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>5</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </license_key>
70
+ <fetch_application_name translate="label">
71
+ <label>Update Application Names</label>
72
+ <comment><![CDATA[Click to update the list of valid application names configured in Newrelic]]></comment>
73
+ <frontend_type>button</frontend_type>
74
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_button_appnames</frontend_model>
75
+ <sort_order>6</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </fetch_application_name>
80
+ <application_name translate="label">
81
+ <label>Application Name</label>
82
+ <comment><![CDATA[The application name to use.]]></comment>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>proxiblue_newrelic/adminhtml_system_config_source_select_appnames</source_model>
85
+ <sort_order>7</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </application_name>
90
+ </fields>
91
+ </api>
92
+ <settings translate="label">
93
+ <label>Settings</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>1</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ <fields>
100
+ <record_cache translate="label">
101
+ <label>Record Cache Events</label>
102
+ <comment><![CDATA[Enable to record cache clear events on NewRelic Graph]]></comment>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <sort_order>1</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </record_cache>
110
+ <record_index translate="label">
111
+ <label>Record Index Events</label>
112
+ <comment><![CDATA[Enable to record index clear events on NewRelic Graph]]></comment>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>adminhtml/system_config_source_yesno</source_model>
115
+ <sort_order>2</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ </record_index>
120
+ <record_system_log translate="label">
121
+ <label>Record system.log</label>
122
+ <comment><![CDATA[Send system.log entries to newrelic. Logging to system log must also be enabled]]></comment>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>adminhtml/system_config_source_yesno</source_model>
125
+ <sort_order>3</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ </record_system_log>
130
+ <system_log_ignore_message translate="label">
131
+ <label>Do not record these log entries</label>
132
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_ignoremessage</frontend_model>
133
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
134
+ <sort_order>4</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ <comment><![CDATA[Add message strings not to record in NewRelic.]]></comment>
139
+ </system_log_ignore_message>
140
+ <system_log_ignore_debug translate="label">
141
+ <label>Ignore DEBUG messages</label>
142
+ <comment><![CDATA[Enable to ignore any message flagged as DEBUG. Must be disabled to test.]]></comment>
143
+ <frontend_type>select</frontend_type>
144
+ <source_model>adminhtml/system_config_source_yesno</source_model>
145
+ <sort_order>5</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ </system_log_ignore_debug>
150
+ <record_exception translate="label">
151
+ <label>Record Exceptions</label>
152
+ <comment><![CDATA[Send exceptions to newrelic.]]></comment>
153
+ <frontend_type>select</frontend_type>
154
+ <source_model>adminhtml/system_config_source_yesno</source_model>
155
+ <sort_order>6</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </record_exception>
160
+ <exception_ignore_message translate="label">
161
+ <label>Do not record these exceptions</label>
162
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_ignoremessage</frontend_model>
163
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
164
+ <sort_order>7</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ <comment><![CDATA[Add message strings not to record in NewRelic]]></comment>
169
+ </exception_ignore_message>
170
+ <named_transactions translate="label">
171
+ <label>Name Route, Controllers and Actions</label>
172
+ <comment><![CDATA[Enable to add newrelic_named_transaction to controller calls. Ref: https://newrelic.com/docs/php/the-php-api]]></comment>
173
+ <frontend_type>select</frontend_type>
174
+ <source_model>adminhtml/system_config_source_yesno</source_model>
175
+ <sort_order>8</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </named_transactions>
180
+ <add_module_to_named_transactions translate="label">
181
+ <label>Add module name to named transactions</label>
182
+ <comment><![CDATA[Enable to include the module name in the named transaction]]></comment>
183
+ <frontend_type>select</frontend_type>
184
+ <source_model>adminhtml/system_config_source_yesno</source_model>
185
+ <sort_order>10</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>1</show_in_store>
189
+ </add_module_to_named_transactions>
190
+ <ignore_admin_routes translate="label">
191
+ <label>Do not send core magento admin request to New Relic</label>
192
+ <comment><![CDATA[Enable to ignore Backend Urls]]></comment>
193
+ <frontend_type>select</frontend_type>
194
+ <source_model>adminhtml/system_config_source_yesno</source_model>
195
+ <sort_order>11</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ </ignore_admin_routes>
200
+ <ignore_modules translate="label">
201
+ <label>Do not record these modules requests</label>
202
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_ignoremodule</frontend_model>
203
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
204
+ <sort_order>12</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ <comment><![CDATA[Add module names to not to record in NewRelic.<br/>To find the correct module name]]></comment>
209
+ </ignore_modules>
210
+ <custom_tracers translate="label">
211
+ <label>Custom Tracers</label>
212
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_tracers</frontend_model>
213
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
214
+ <sort_order>13</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <comment><![CDATA[Add tracers to newrelic for the class methods. Format must be class::method]]></comment>
219
+ </custom_tracers>
220
+ </fields>
221
+ </settings>
222
+ <metrics translate="label">
223
+ <label>Metrics</label>
224
+ <frontend_type>text</frontend_type>
225
+ <sort_order>3</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ <fields>
230
+ <signup_success translate="label">
231
+ <label>Record Customer Signup Success</label>
232
+ <comment><![CDATA[Enable to record customer signup metrics]]></comment>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>adminhtml/system_config_source_yesno</source_model>
235
+ <sort_order>1</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </signup_success>
240
+ </fields>
241
+ </metrics>
242
+ <embeded translate="label">
243
+ <label>Embedded Graphs</label>
244
+ <frontend_type>text</frontend_type>
245
+ <sort_order>2</sort_order>
246
+ <show_in_default>1</show_in_default>
247
+ <show_in_website>1</show_in_website>
248
+ <show_in_store>1</show_in_store>
249
+ <fields>
250
+ <enabled translate="label">
251
+ <label>Embed graphs on dashboard</label>
252
+ <comment><![CDATA[Enable emdedded graphs]]></comment>
253
+ <frontend_type>select</frontend_type>
254
+ <source_model>adminhtml/system_config_source_yesno</source_model>
255
+ <sort_order>1</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ </enabled>
260
+ <graph translate="label">
261
+ <label>Graph urls to display in dashboard tab</label>
262
+ <frontend_model>proxiblue_newrelic/adminhtml_system_config_form_field_graphurl</frontend_model>
263
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
264
+ <sort_order>2</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ <comment><![CDATA[<a target="_blank" href="http://www.proxiblue.com.au/new-relic-get-graph-urls">How to find your graph urls</a>]]></comment>
269
+ </graph>
270
+
271
+ </fields>
272
+ </embeded>
273
+ </groups>
274
+ </newrelic>
275
+ </sections>
276
+ </config>
app/code/community/ProxiBlue/NewRelic/sql/proxiblue_newrelic_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
4
+ *
5
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with ProxiBlue NewRelic Module.
17
+ * If not, see <http://www.gnu.org/licenses/>.
18
+ **/
19
+ ?>
20
+ <?php
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+ $installer->endSetup();
app/code/local/Mage/Core/Exception.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This file is part of ProxiBlue NewRelic Module available via GitHub https://github.com/ProxiBlue/NewRelic
5
+ *
6
+ * ProxiBlue NewRelic Module is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * ProxiBlue NewRelic Module is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with ProxiBlue NewRelic Module.
18
+ * If not, see <http://www.gnu.org/licenses/>.
19
+ * */
20
+
21
+ /**
22
+ * Magento Core Exception
23
+ *
24
+ * This class will be extended by other modules
25
+ *
26
+ * @category Mage
27
+ * @package Mage_Core
28
+ */
29
+ class Mage_Core_Exception extends Exception {
30
+
31
+ protected $_messages = array();
32
+ protected $_lastException = null;
33
+
34
+ public function addMessage(Mage_Core_Model_Message_Abstract $message) {
35
+ if (!isset($this->_messages[$message->getType()])) {
36
+ $this->_messages[$message->getType()] = array();
37
+ }
38
+ $this->_messages[$message->getType()][] = $message;
39
+ return $this;
40
+ }
41
+
42
+ public function getMessages($type = '') {
43
+ if ('' == $type) {
44
+ $arrRes = array();
45
+ foreach ($this->_messages as $messageType => $messages) {
46
+ $arrRes = array_merge($arrRes, $messages);
47
+ }
48
+ return $arrRes;
49
+ }
50
+ return isset($this->_messages[$type]) ? $this->_messages[$type] : array();
51
+ }
52
+
53
+ /**
54
+ * Set or append a message to existing one
55
+ *
56
+ * @param string $message
57
+ * @param bool $append
58
+ * @return Mage_Core_Exception
59
+ */
60
+ public function setMessage($message, $append = false) {
61
+ if ($append) {
62
+ $this->message .= $message;
63
+ } else {
64
+ $this->message = $message;
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Additions by ProxiBlue to log exceptions with new relic.
71
+ *
72
+ */
73
+ public function __construct($message = '', $code = 0, $previous = null) {
74
+ parent::__construct($message, $code, $previous);
75
+ if ($this instanceof Mage_Core_Model_Store_Exception || $this instanceof ProxiBlue_NewRelic_Exception) {
76
+ // this is a store or newrelic module exception
77
+ // log this one direct to newrelic to prevent endless loop.
78
+ ProxiBlue_NewRelic_Model_Log_Exception::pushEvent($this, false);
79
+ } else {
80
+ // determine if this is a Mage_Core_Model_Config exception, prevents endless loop
81
+ $stackTrace = self::getTrace();
82
+ if (is_array($stackTrace)) {
83
+ $maxTraceItterations = 100;
84
+ // 100 seems like a safe test. If this test works, a config option would be created to allow users to set this.
85
+ foreach ($stackTrace as $_trace) {
86
+ if($maxTraceItterations == 0) {
87
+ break;
88
+ }
89
+ if (is_array($_trace) && array_key_exists('class', $_trace) && $_trace['class'] == 'Mage_Core_Model_Config') {
90
+ // some config issue, log it direct
91
+ ProxiBlue_NewRelic_Model_Log_Exception::pushEvent($this, false);
92
+ return $this;
93
+ }
94
+ $maxTraceItterations--;
95
+ }
96
+ }
97
+ $newRelic = Mage::getModel('proxiblue_newrelic/log_Exception');
98
+ // make sure we have an object here!
99
+ if (is_object($newRelic) && $newRelic instanceof ProxiBlue_NewRelic_Model_Log_Exception && $newRelic->getEnabled()) {
100
+ $newRelic->recordEvent($this);
101
+ }
102
+ }
103
+ }
104
+
105
+ }
app/design/adminhtml/default/default/template/dashboard/newrelic.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <div style="margin:20px;">
2
+ <?php foreach ($this->getEmbededGraphs() as $graphUrl): ?>
3
+ <object data="<?php echo trim($graphUrl['string']); ?>" width="100%" height="300">
4
+ <embed src="<?php echo trim($graphUrl['string']); ?>" width="100%" height="300"> </embed>
5
+ Error: Embedded data could not be displayed.
6
+ </object>
7
+ <?php endforeach; ?>
8
+ </div>
app/etc/modules/ProxiBlue_NewRelic.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ProxiBlue_NewRelic>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </ProxiBlue_NewRelic>
8
+ </modules>
9
+ </config>
js/newrelic.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Array.prototype.remove = function() {
2
+ var what, a = arguments, L = a.length, ax;
3
+ while (L && this.length) {
4
+ what = a[--L];
5
+ while ((ax = this.indexOf(what)) !== -1) {
6
+ this.splice(ax, 1);
7
+ }
8
+ }
9
+ return this;
10
+ };
11
+
12
+ function fetchApplicationNames() {
13
+ new Ajax.Request(newrelic_base_url + 'proxiblue_newrelic/api/names/key/'+$('newrelic_api_api_key').value, {
14
+ onSuccess: function(response) {
15
+ var json = response.responseText.evalJSON();
16
+ if(json.error) {
17
+ alert(json.error);
18
+ exit;
19
+ }
20
+ var appnames = json.result, index;
21
+ selbox = $('newrelic_api_application_name');
22
+ var options = selbox.options;
23
+ $$('select#newrelic_api_application_name option').each(function(el) {
24
+ if (appnames.indexOf(el.value) != -1 ) {
25
+ //console.log(el.value);
26
+ appnames.remove(el.value);
27
+ }
28
+ });
29
+ // Loop the states
30
+ for (index = 0; index < appnames.length; ++index) {
31
+ //console.log(appnames[index]);
32
+ options[selbox.options.length] = new Option(
33
+ appnames[index],
34
+ appnames[index]
35
+ );
36
+ }
37
+ }
38
+ });
39
+ }
40
+
41
+ function fetchAccountDetails() {
42
+ new Ajax.Request(newrelic_base_url + 'proxiblue_newrelic/api/accountDetails/key/'+$('newrelic_api_api_key').value, {
43
+ onSuccess: function(response) {
44
+ var json = response.responseText.evalJSON();
45
+ if(json.error) {
46
+ alert(json.error);
47
+ exit;
48
+ }
49
+ $('newrelic_api_account_id').value = json.accountid;
50
+ $('newrelic_api_data_access_key').value = json.accesskey;
51
+ $('newrelic_api_license_key').value = json.licensekey;
52
+ }
53
+ });
54
+ }
55
+
56
+
package.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>proxiblue-newrelic</name><version>1.0.0</version><stability>stable</stability><license>Custom License</license><channel>community</channel><extends></extends><summary></summary><description></description><notes></notes><authors><author><name>Lucas van Staden</name><user>proxiblue</user><email>sales@proxiblue.com.au</email></author></authors><date>2015-11-02</date><time>22:33:08</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="js"><file name="newrelic.js" hash="666192d0daa4e084976a63ada1be4a99"/></dir><dir name="app"><dir name="code"><dir name="local"><dir name="Mage"><dir name="Core"><file name="Exception.php" hash="4882513a58ff5b23884e8e8341796899"/></dir></dir></dir><dir name="community"><dir name="ProxiBlue"><dir name="NewRelic"><file name="Exception.php" hash="5e884920e4e43ccc62e2aa4db3019645"/><dir name="Model"><file name="Abstract.php" hash="c947ecf65ba2e9d5af3530cc270d3524"/><file name="Api.php" hash="eab08c7732d4182eb797100119e90db1"/><file name="Cache.php" hash="19a08568607caa52b2b8997b7e3e391e"/><file name="Index.php" hash="c8292ea23e974f268ea5b93f76b99e73"/><file name="Metrics.php" hash="a6752a3b13ad1fb9ec39559de3de0cb4"/><file name="Observer.php" hash="fa551bcb6dcd8ffab9f43682b4e0da1b"/><dir name="Log"><file name="Exception.php" hash="c1c025083da67a5982dc30573da087cc"/><file name="System.php" hash="a73453852f37e85976c5542e260c2cb5"/><dir name="Writer"><file name="Stream.php" hash="3f5b432e94a076c46aedcde51a365437"/></dir></dir><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Select"><file name="Appnames.php" hash="414846424e80652d937b6a9c0058c59e"/></dir></dir></dir></dir></dir><dir name="Predispatch"><file name="Observer.php" hash="d3b1c8c9dc73fde51f7ba260698aaddc"/></dir></dir><dir name="sql"><dir name="proxiblue_newrelic_setup"><file name="mysql4-install-0.0.1.php" hash="b1d2946c28914cdf6f6473c53bef05e4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="d9ab63cb1bf3b8161106810ad676af39"/><file name="changelog.txt" hash="363a69fd8243a26f53f3596461270ec5"/><file name="config.xml" hash="5a92e19312ce774824db3b5f3b41ed03"/><file name="file-list.txt" hash="04d450c89c559a6dc410037aaed9b292"/><file name="system.xml" hash="b2945d449b82f4c39a922c344fed1c70"/></dir><dir name="Helper"><file name="Data.php" hash="0e19fa078c32dc479ec6670d816b0b1f"/></dir><dir name="controllers"><file name="ApiController.php" hash="fa3a1950c6e4e6612e489677a32eba33"/><file name="TestController.php" hash="e3070aec27ecf29119b5e2c1888572a8"/></dir><dir name="Block"><dir name="Adminhtml"><dir name="Dashboard"><file name="Diagrams.php" hash="cca0a2368442ae971a9d7cd6256132d0"/><dir name="Tab"><file name="Newrelic.php" hash="1be70ba2810192397025f5e2c10abd5d"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Graphurl.php" hash="8447db7a773f6aa1870b5af1bbec0bdc"/><file name="Ignoremessage.php" hash="5cda3bb00f9914e4a71fca8e344f2c88"/><file name="Ignoremodule.php" hash="de05829a3ef608bda3378464f8e14445"/><file name="Tracers.php" hash="2981ba79dced9ede669d27dc28c4cdf9"/><dir name="Button"><file name="Accountdetails.php" hash="0eabc2a353718890716016ffb661d4b0"/><file name="Appnames.php" hash="134ac4e2ea36bedf006f9159cc9ad7c6"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="ProxiBlue_NewRelic.xml" hash="0b601eb832b64bafb9a9050a82ddab27"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="dashboard"><file name="newrelic.phtml" hash="abf724cab5f22c044279c706673f67ee"/></dir></dir></dir></dir></dir></dir></dir></target></contents></package>