PHPackages                             graze/dog-statsd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. graze/dog-statsd

ActiveLibrary

graze/dog-statsd
================

DataDog StatsD Client

1.0.0(5y ago)413.1M↓16.5%10[2 issues](https://github.com/graze/dog-statsd/issues)[4 PRs](https://github.com/graze/dog-statsd/pulls)3MITPHPPHP ^7.1|^8.0CI failing

Since Nov 4Pushed 4y ago10 watchersCompare

[ Source](https://github.com/graze/dog-statsd)[ Packagist](https://packagist.org/packages/graze/dog-statsd)[ Docs](https://github.com/graze/dog-statsd)[ RSS](/packages/graze-dog-statsd/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (19)Used By (3)

graze/dog-statsd
================

[](#grazedog-statsd)

[![Giphy](https://camo.githubusercontent.com/19ac46683efe4161c4d761bb89632f84c2934f8492ff0700689f4d22a316dd9b/687474703a2f2f6d65646961312e67697068792e636f6d2f6d656469612f414c4349336554696937714f6b2f67697068792e676966)](https://camo.githubusercontent.com/19ac46683efe4161c4d761bb89632f84c2934f8492ff0700689f4d22a316dd9b/687474703a2f2f6d65646961312e67697068792e636f6d2f6d656469612f414c4349336554696937714f6b2f67697068792e676966)

[![Latest Version on Packagist](https://camo.githubusercontent.com/19d92a2f13fbd92bd458c6d8abb050a7f32af479d57ada671f80b71bed0ca547/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a652f646f672d7374617473642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/dog-statsd)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/20c63377e119f03b5ddc41a1fc1fbd39a670c3a295508d8362547fbb37160478/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6772617a652f646f672d7374617473642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/graze/dog-statsd)[![Coverage Status](https://camo.githubusercontent.com/f3e0eea35a8a3cf3b424e22b14ea2ac823e19412b8972c16184cf517093472cd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6772617a652f646f672d7374617473642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/dog-statsd/code-structure)[![Quality Score](https://camo.githubusercontent.com/6c57a104afa705c45431d122dc43b47146debb3ec3a9820c59e94f0e45d79862/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6772617a652f646f672d7374617473642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/dog-statsd)[![Total Downloads](https://camo.githubusercontent.com/4db7a404034d1a7245e4d503e0ae21457f809d9028bc95acb48059d849b34801/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617a652f646f672d7374617473642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/dog-statsd)

Client to talk to [DataDogs StatsD Agent](http://docs.datadoghq.com/guides/dogstatsd) Forked from: [League/StatsD](https://github.com/thephpleague/statsd)

For more information on the metric, see: [Datadogs metrics guide](http://docs.datadoghq.com/guides/metrics/).

Install
-------

[](#install)

Via Composer

```
$ composer require graze/dog-statsd
```

Usage
-----

[](#usage)

### Configuring

[](#configuring)

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

OR

```
$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' => ` to your config.

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

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

```

By default this is set to `'error'`

#### Core StatsD implementation

[](#core-statsd-implementation)

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

```
'dataDog' => false

```

### Methods

[](#methods)

#### Counters

[](#counters)

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

#### Gauges

[](#gauges)

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

#### Sets

[](#sets)

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

#### Histogram

[](#histogram)

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

#### Timers

[](#timers)

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

#### Timing Blocks

[](#timing-blocks)

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

#### Tags

[](#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

[](#tags-processors)

You can add tag processors to inject tags at runtime for each metric.

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

#### Events

[](#events)

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

#### Service Check

[](#service-check)

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

#### Default Tags

[](#default-tags)

Send the same base tags with every request

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

Testing
-------

[](#testing)

```
$ make test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Harry Bragg](https://github.com/h-bragg)
- [All Contributors](../../contributors)

### Forked from [thephpleague/statsd](https://github.com/thephpleague/statsd):

[](#forked-from-thephpleaguestatsd)

- [Marc Qualie](https://github.com/marcqualie)
- [League/StatsD Contributors](https://github.com/thephpleague/statsd/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~165 days

Recently: every ~256 days

Total

13

Last Release

1860d ago

Major Versions

0.4.3 → 1.0.02021-04-14

PHP version history (4 changes)v0.1PHP &gt;=5.5.0

v0.1.2PHP &gt;=5.5

0.3.2PHP ^5.5|^7.0

1.0.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/637788?v=4)[graze.com](/maintainers/graze)[@graze](https://github.com/graze)

---

Top Contributors

[![biggianteye](https://avatars.githubusercontent.com/u/1482649?v=4)](https://github.com/biggianteye "biggianteye (2 commits)")[![rares-mollie](https://avatars.githubusercontent.com/u/70578482?v=4)](https://github.com/rares-mollie "rares-mollie (1 commits)")[![shirshir](https://avatars.githubusercontent.com/u/660457?v=4)](https://github.com/shirshir "shirshir (1 commits)")

---

Tags

datadogphpstatsdstatsd-clientstatsdDataDoggrazedogstatsddog-statsd

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/graze-dog-statsd/health.svg)

```
[![Health](https://phpackages.com/badges/graze-dog-statsd/health.svg)](https://phpackages.com/packages/graze-dog-statsd)
```

###  Alternatives

[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19024.6M15](/packages/datadog-php-datadogstatsd)[datadog/dd-trace

PHP APM Client

55020.5M15](/packages/datadog-dd-trace)[league/statsd

A simple library for working with StatsD in PHP.

3514.3M12](/packages/league-statsd)[liuggio/statsd-php-client

Statsd (Object Oriented) client library for PHP

1153.9M9](/packages/liuggio-statsd-php-client)[liuggio/statsd-client-bundle

Provides a statsd client and simple ready-to-use support for #Symfony2 Application

164730.7k](/packages/liuggio-statsd-client-bundle)[slickdeals/statsd

a PHP client for statsd

264.5M8](/packages/slickdeals-statsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
