Skip to content

Commit ced4c23

Browse files
committed
add config option to disable ext
1 parent c917f52 commit ced4c23

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Newrelic.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
class Newrelic extends Component implements BootstrapInterface
1717
{
18+
/**
19+
* @var bool Enable agent
20+
*/
21+
public $enabled = true;
1822
/**
1923
* @var \NewRelic\NewRelic
2024
*/
@@ -45,6 +49,10 @@ class Newrelic extends Component implements BootstrapInterface
4549
*/
4650
public function bootstrap($app)
4751
{
52+
if (!$this->enabled) {
53+
return;
54+
}
55+
4856
if ($this->handler) {
4957
$handler = new $this->handler(['newrelic' => $this]);
5058
} elseif ($app instanceof \yii\web\Application) {
@@ -62,7 +70,7 @@ public function init()
6270
{
6371
parent::init();
6472

65-
if (Agent::isLoaded()) {
73+
if ($this->enabled && Agent::isLoaded()) {
6674
$this->name = $this->name ? $this->name : \Yii::$app->name;
6775
$this->agent = new Agent();
6876
$this->agent->setAppname($this->name, $this->licence);

0 commit comments

Comments
 (0)