2017 © Pedro Peláez
 

library dog-statsd

DataDog StatsD Client

image

graze/dog-statsd

DataDog StatsD Client

  • Tuesday, June 26, 2018
  • by graze
  • Repository
  • 10 Watchers
  • 19 Stars
  • 103,329 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 16 Versions
  • 20 % Grown

The README.md

graze/dog-statsd

Giphy, (*1)

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads, (*2)

Client to talk to DataDogs StatsD Agent Forked from: League/StatsD, (*3)

For more information on the metric, see: Datadogs metrics guide., (*4)

Install

Via Composer, (*5)

``` bash $ composer require graze/dog-statsd, (*6)


## Usage ### Configuring ```php $statsd = new Graze\DogStatsD\Client(); $statsd->configure([ 'host' => '127.0.0.1', 'port' => 8125, 'namespace' => 'example', ]);

OR, (*7)

$statsd1 = DogStatsD\Client::instance('server1')->configure([...]);
$statsd2 = DogStatsD\Client::instance('server2')->configure([...]);

The StatsD client waits for ini_get('default_socket_timeout') seconds when opening the socket by default. To reduce this timeout, add 'timeout' => <int> to your config., (*8)

The StatsD client will either throw a ConnectionException, throw a warning or ignore all errors if it is unable to send data to the StatsD server. This can be configured using the onError property, (*9)

    'onError' => 'error' // 'error', 'exception' or 'ignore'

By default this is set to 'error', (*10)

Core StatsD implementation

To use this with a core statsd implementation (without the extra features DataDog have added) include the following in your configuration:, (*11)

'dataDog' => false

Methods

Counters

$statsd->increment('web.pageview');
$statsd->decrement('storage.remaining');
$statsd->increment([
    'first.metric',
    'second.metric'
], 2);
$statsd->increment('web.clicks', 1, 0.5);

Gauges

$statsd->gauge('api.logged_in_users', 123456);

Sets

$userID = 23;
$statsd->set('api.unique_logins', $userID);

Histogram

$result = $db->fetch();
$statsd->histogram('db.results', count($result), 0.5);

Timers

$statsd->timing('api.response_time', 256);

Timing Blocks

$statsd->time('api.dbcall', function () {
    // this code execution will be timed and recorded in ms
});

Tags

$statsd->increment('web.pageview', 1, ['page' => 'some/page']);
$statsd->guage('api.logged_in_users', 123456, ['environement' => 'live']);
$statsd->set('api.unique_logins', $userID, ['tag']);
$statsd->timing('api.response_time', 245, ['end-point' => 'page', 'env' => 'test']);
Tags Processors

You can add tag processors to inject tags at runtime for each metric., (*12)

$statsd->addTagProcessor(function (array $tags) {
    $tags['new-key'] = 'new-value';
    return $tags;
});

Events

$statsd->event(
    'build.success',
    'The build super_awesome_application_build_1 has completed',
    [
        'time'  => time(),
        'alert' => Client::ALERT_SUCCESS,
    ],
    [
        'environment' => 'live',
    ]
);

Service Check

$statsd->serviceCheck(
    'service.api.account',
    Client::STATUS_OK,
    [
        'host' => 'this.hostname.com',
        'time' => time(),
    ],
    [
        'environment' => 'staging',
    ]
);

Default Tags

Send the same base tags with every request, (*13)

$client = new Client();
$client->configure([
    'tags' => [
        'env'     => 'live',
        'release' => 'app-2.3.1',
    ],
]);

Testing

bash $ make test, (*14)

Contributing

Please see CONTRIBUTING for details., (*15)

Security

If you discover any security related issues, please email security@graze.com instead of using the issue tracker., (*16)

Credits

Forked from thephpleague/statsd:

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

26/06 2018

0.4.0

0.4.0.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

19/04 2018

dev-tags-processor

dev-tags-processor https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

04/04 2018

dev-composer-platform

dev-composer-platform https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

02/02 2018

dev-new-composer

dev-new-composer https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

24/08 2017

0.3.3

0.3.3.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

11/08 2017

0.3.2

0.3.2.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

11/08 2017

dev-standards

dev-standards https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php ^5.5|^7.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

08/08 2017

0.3.1

0.3.1.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

18/05 2017

dev-0.3-rc1

dev-0.3-rc1 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

18/05 2017

0.3

0.3.0.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

04/05 2017

dev-persistent-stream

dev-persistent-stream https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

02/12 2016

v0.2

0.2.0.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

04/08 2016

v0.1.2

0.1.2.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

10/02 2016

v0.1.1

0.1.1.0 https://github.com/graze/dog-statsd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd dog-statsd

04/11 2015

v0.1

0.1.0.0 https://github.com/graze/statsd-dd

DataDog StatsD Client

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Harry Bragg

statsd datadog graze dogstatsd statsd-dd