Skip to content

Commit

Permalink
Register an event handler triggered sooner.
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes committed Oct 2, 2011
1 parent 93c88d4 commit 55b4650
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions DataCollector/MysqlndDataCollector.php
Expand Up @@ -5,6 +5,7 @@
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

/**
* Data collector collecting mysqlnd statistics.
Expand All @@ -22,6 +23,13 @@ public function __construct()
}
}

public function onEarlyKernelRequest(GetResponseEvent $event)
{
if (!$this->initialData && function_exists('mysqli_get_client_stats')) {
$this->initialData = mysqli_get_client_stats();
}
}

/**
* {@inheritdoc}
*/
Expand Down
3 changes: 2 additions & 1 deletion Resources/config/services.xml
Expand Up @@ -9,8 +9,9 @@
</parameters>

<services>
<service id="data_collector.mysqlnd" class="%js_mysqlnd.data_collector.class%" public="false">
<service id="data_collector.mysqlnd" class="%js_mysqlnd.data_collector.class%" public="true">
<tag name="data_collector" template="JSMysqlndBundle:Collector:mysqlnd" id="mysqlnd" />
<tag name="kernel.event_listener" event="kernel.request" method="onEarlyKernelRequest" />
</service>
</services>

Expand Down

0 comments on commit 55b4650

Please sign in to comment.