Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This library provides base classes to collect and publish metrics.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 build.xml
Octocat-spinner-32 composer.json
Octocat-spinner-32 phpunit.xml.dist
README.md

Ekino PHP Metric

Build Status

This library provides base classes to collect and publish metrics.

Metric Reporters :

  • CollectD
  • StatsD
  • NewRelic
  • XHGui

Metric Collectors :

  • Doctrine
  • Xhprof
  • Timer
  • Memory Usage

Installation

Using Composer

Use composer.phar:

$ php composer.phar require ekino/metric

You just have to specify the version you want : master-dev. It will add the package in your composer.json file and install it.

Or you can do it by yourself, first, add the following to your composer.json file:

// composer.json
{
    // ...
    require: {
        // ...
        "ekino/metric": "dev-master"
    }
}

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

$ php composer.phar update ekino/php-metric

Usage with CollectD

<?php

// initialize a reporter
$collectd = new Ekino\Metric\Reporter\CollectDReporter('web1-php', new Ekino\Metric\Writer\UdpWriter('localhost', 25826));

// initialize the metric manager
$manager = new Ekino\Metric\MetricManager($collectd);

// store the current memory usage
$collector = new Ekino\Metric\Collector\MemoryUsageCollector('memory.usage.', true);
$manager->addMetric($collector->get());

// store execution time of one callback function
$heavy = function() { sleep(1); };
$collector = new Ekino\Metric\Collector\TimerFunctionCollector('php.function.heavy', $heavy);
$collector->run();

$manager->addMetric($collector->get());

// send metric to the reporter
$manager->flush();
Something went wrong with that request. Please try again.