2017 © Pedro Peláez
 

library statsd

Simple extensible StatsD client library for PHP 5.5+

image

vend/statsd

Simple extensible StatsD client library for PHP 5.5+

  • Wednesday, February 17, 2016
  • by dominics
  • Repository
  • 8 Watchers
  • 2 Stars
  • 30,961 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 7 % Grown

The README.md

vend/statsd

Simple extensible StatsD client for PHP 5.5+

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Latest Unstable Version, (*1)

Features

  • Correctly splits large numbers of metrics across multiple datagrams
  • Can substitute out the underlying format of the metrics being sent, to support things like Datadog's tags and histograms
  • Supports sample rates, but leaves skipping the send to the caller (use the factory and socket directly)
  • Doesn't block during metric sending, and only supports UDP (opinionated, but that's all you should need)

Usage

This library uses dependency injection throughout. To instantiate a Client, you'll need a Socket and a Factory:, (*2)

use Vend\Statsd\Client;
use Vend\Statsd\Socket;
use Vend\Statsd\Factory;

$client = new Client(
    new Socket(),
    new Factory()
);

Once you have a client, you can use the familiar statsd methods to enqueue metrics on the client. The client doesn't send them until ->flush() is called., (*3)

$client->increment('some.metric_key'); // incremented by 1
$client->decrement('some.metric_key'); // decremented by 1
$client->counter('some.counter', 3);   // incremented by 3
$client->gauge('some.gauge', 10);
$client->timer('some.timer', 0.25);
$client->set('some.set', 'some_value');

$client->flush(); // actually sends the metrics

These methods return the MetricInterface produced by the factory (so you can then attach extra information)., (*4)

You can also use the factory and socket to directly and immediately send metrics. The ->getData() method on MetricInterface provides the serialized string that should be sent to the statsd server., (*5)

$socket = new Socket('127.0.0.1', 8125);
$factory = new Factory();

$socket->open();
$socket->write($factory->increment('some.key')->getData());
$socket->close();

Extending

For an example of how to extend the library, see the Vend\Statsd\Datadog namespace. A different Factory is used by passing it to the Client. The Datadog-specific factory will allow the metrics to carry tag information., (*6)

NullClient, ClientAwareInterface and ClientAwareTrait

Helpful utility classes for performing optional (setter) injection of statsd clients into your classes. Use them in pretty much the same way as their PSR3 equivalents., (*7)

The Versions

17/02 2016

dev-master

9999999-dev https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

 

The Development Requires

statsd monitoring

17/02 2016

v1.1.1

1.1.1.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

 

The Development Requires

statsd monitoring

07/12 2015

v1.1.0

1.1.0.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

 

The Development Requires

statsd monitoring

03/12 2015

dev-feature-validate-logger

dev-feature-validate-logger https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

 

The Development Requires

statsd monitoring

03/12 2015

v1.0.3

1.0.3.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

 

The Development Requires

statsd monitoring

01/12 2015

v1.0.2

1.0.2.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

statsd monitoring

01/12 2015

v1.0.1

1.0.1.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

statsd monitoring

01/12 2015

v1.0.0

1.0.0.0 https://github.com/vend/statsd/

Simple extensible StatsD client library for PHP 5.5+

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

statsd monitoring