/**
  * Execute CLI command
  *
  * @throws \InvalidArgumentException When namespace doesn't end with Bundle
  * @throws \RuntimeException         When bundle can't be executed
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $connection = new \Domnikl\Statsd\Connection\UdpSocket('graphite.beaast.com', 8125);
     $statsd = new \Domnikl\Statsd\Client($connection, "test.namespace");
     // the global namespace is prepended to every key (optional)
     $statsd->setNamespace("test");
     // simple counts
     $statsd->increment("foo.bar");
     $statsd->decrement("foo.bar");
     $statsd->count("foo.bar", 1000);
     $statsd->gauge('foobar', 3);
     $statsd->startTiming("foo.bar");
     $statsd->startMemoryProfile('memory.foo');
     // Getting needed info
     $bundleName = $this->getBundleName($input);
     $bundleNamespace = $this->getBundleNamespace($input);
     $bundleDir = $this->getBundleDir($bundleNamespace);
     $generator = $this->getGenerator();
     $generator->generate($bundleNamespace, $bundleName, $bundleDir);
     $output->writeln('Generating the bundle stub code: <info>OK</info>');
     $errors = array();
     // App kernal update
     $this->updateKernel($input, $output, $this->getContainer()->get('kernel'), $bundleNamespace, $bundleName);
     // Check that the namespace is already autoloaded
     $this->checkAutoloader($output, $bundleNamespace, $bundleName, $bundleDir);
     // Check cache
     $command = $this->getApplication()->find('cache:clear');
     $cacheInput = new ArrayInput(array('command' => 'cache:clear'));
     $command->run($cacheInput, $output);
     $statsd->endTiming("foo.bar");
     $statsd->endMemoryProfile('memory.foo');
     $statsd->memory('foo.memory_peak_usage');
     $statsd->gauge('foobar', '+11');
 }
Beispiel #2
0
function StatsdPost($location, $browser, $label, $cached, &$metrics)
{
    $connection = new \Domnikl\Statsd\Connection\Socket(GetSetting('statsdHost'), GetSetting('statsdPort') ?: 8125);
    $statsd = new \Domnikl\Statsd\Client($connection, GetSetting('statsdPrefix') ?: '');
    $base_key = graphite_key($location, $browser, $label, $cached);
    foreach ($metrics as $metric => $value) {
        $statsd->gauge($base_key . $metric, $value);
    }
}