Skip to content

Commit

Permalink
RUM can be enabled only for certain ratio of users
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich authored and Vrtak-CZ committed Oct 9, 2013
1 parent c2d515d commit 7c729c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -32,6 +32,7 @@ newrelic:
# optional options with default values
rum:
enabled: auto # other options are Yes/No
ratio: 1
transactionTracer:
enabled: Yes
detail: 1
Expand Down
3 changes: 2 additions & 1 deletion src/VrtakCZ/NewRelic/Extension.php
Expand Up @@ -21,6 +21,7 @@ class Extension extends \Nette\Config\CompilerExtension
),
'rum' => array(
'enabled' => 'auto',
'ratio' => 1,
),
'transactionTracer' => array(
'enabled' => TRUE,
Expand Down Expand Up @@ -226,7 +227,7 @@ private function setupRUM()
$config = $this->getConfig($this->defaults);
$builder = $this->getContainerBuilder();

$rumEnabled = $this->enabled && true === $config['rum']['enabled'];
$rumEnabled = $this->enabled && true === $config['rum']['enabled'] && mt_rand(0, 99) <= round($config['rum']['ratio'] * 100) - 1;

$builder->addDefinition($this->prefix('rum'))
->setClass('Nette\DI\NestedAccessor', array('@container', $this->prefix('rum')));
Expand Down

0 comments on commit 7c729c0

Please sign in to comment.