Skip to content
This repository was archived by the owner on Apr 4, 2022. It is now read-only.

Latest commit

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

php-statsd

Simple PHP library to send stats to statsd.

Installation

Add the dependency to your composer.json.

{"require": {"shazam/php-statsd": "2.*"}}

Usage

An example of how to send metrics of how long it takes to load a page.

<?phpuseStatsd;
// $config = array(...);// $path = ...// initialize client$configuration = newStatsd\Client\Configuration();
$configuration->setHost($config['host'])
->setNamespace($config['namespace']);
$statsClient = newStatsd\Client($configuration);
// add stats (you can also add an array of stats with addStats())$statsClient->addStat(
array(
'namespace' => 'endpoints.' . $path, // that will be your stat namespace'value' => $executionTime, // calculate it in microseconds'type' => 'ms'
)
);
// send them$statsClient->sendStats();

You can use TIME_MS, COUNT, GAUGE or SET (ms, c, g, s) as type of stats.

Configuration

  • A host to push metrics (use 127.0.0.1 if you have netpipes installed in your box).
  • A port (by default, 8126).
  • A namespace (where all your metrics will be added. Use "." to separate folders.
  • Optionally, a Monolog\Logger object, to log the metrics.

An example of a config file for that client could be:

stats:
enable: trueclient:
host: 127.0.0.1namespace: shazam.twitterhose

About

Simple PHP library to send stats to statsd

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages