PHPackages                             classmarkets/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. classmarkets/statsd

AbandonedArchivedLibrary

classmarkets/statsd
===================

A simple library for interacting with a statsd server

1.0.0(13y ago)0357MITPHP

Since Nov 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/classmarkets/php-statsd)[ Packagist](https://packagist.org/packages/classmarkets/statsd)[ RSS](/packages/classmarkets-statsd/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHP StatsD Client
=================

[](#php-statsd-client)

[![Build Status](https://camo.githubusercontent.com/f9f1f7677802e65e417a4b4ea59a491e9f13c68191da43fbcc5b4f019d733ace/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f636c6173736d61726b6574732f7068702d7374617473642e706e67)](http://travis-ci.org/classmarkets/php-statsd)

This is a PHP [statsd](https://github.com/etsy/statsd.git) client based on [work by John Crepezzi](https://github.com/seejohnrun/php-statsd). We refactored the library into a composer module and opened the API a bit to improve flexibility.

Installation
------------

[](#installation)

`composer.json`

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/classmarkets/php-statsd"
        }
    ],
    "require": {
        "classmarkets/statsd": "~1.0"
    }
}
```

Usage
-----

[](#usage)

### Gauges

[](#gauges)

```
$statsd = new \Classmarkets\Statsd;
$statsd->gauge("my.favorite.numbers", 73); // see what I did there?

```

### Counting

[](#counting)

To count things:

```
$statsd = new \Classmarkets\Statsd;
$statsd->count('sheep', 3);
```

### Timing

[](#timing)

Record timings:

```
$statsd = new \Classmarkets\Statsd;
$statsd->timing('critical.query', 18);
```

Timings are given in milliseconds, see

### Timing Closures

[](#timing-closures)

And a convenience mechanism for timing:

```
$statsd = new \Classmarkets\Statsd;
$statsd->timeThis('critical.query', function() use ($db) {
    $db->executeCriticalQuery();
});
```

Configuration
-------------

[](#configuration)

### Host and Port

[](#host-and-port)

```
$statsd = new \Classmarkets\Statsd('localhost', 7000); // default localhost:8125
```

If called like this, Statsd will create a default UDP socket. For more control you can also pass a socket as the third argument:

```
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$statsd = new \Classmarkets\Statsd('localhost', 7000, $socket); // default localhost:8125
```

### Sample Rate

[](#sample-rate)

Any of the methods descriped in the usage section can take an optional third argument `$rate`, which is the sample rate:

```
$statsd = new \Classmarkets\Statsd;
$stats->count('numpoints', 123, 0.1);
```

Changes to the original library
-------------------------------

[](#changes-to-the-original-library)

- **BC break** CodeIgniter support has been removed. We are not familiar with CI and thus can't guarantee for compatibility. Support may be re-added in the future.
- **BC break** `Statsd` has been moved to the `\Classmarkets` namespace.
- **BC break** Codestyle has been changed to PSR-1. `Statsd::time_this()` is now called `Statsd::timeThis()`.
- **BC break** `Statsd::counting()` has been renamed to `Statsd::count()` for consistency
- `Statsd::send()` is now `public`, allowing to send arbitrary messages to statsd, like sending a batch of newline separated messages in one go.
- Support for [gauges](https://github.com/etsy/statsd#gauges) and [sets](https://github.com/etsy/statsd#sets) has been added.
- All messages are sent over one socket per `Statsd` instance, instead of creating a new one for each message, giving a significant speed improvement when reusing the same instance.
- The constructor now accepts an optional socket as its third argument.
- All methods return the result of `socket_sendto()`, so client code can deal with errors if desired.

Authors
-------

[](#authors)

- John Crepezzi
- Peter Schultz

License
-------

[](#license)

(The MIT License)

Copyright © 2012 John Crepezzi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. MIT License. See attached LICENSE

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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

Unknown

Total

1

Last Release

4933d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfb85e6ae68279e8c0ed0ba592d0d90c69501a714a967b2e9ee308c385266f9c?d=identicon)[pschultz](/maintainers/pschultz)

---

Top Contributors

[![pschultz](https://avatars.githubusercontent.com/u/607733?v=4)](https://github.com/pschultz "pschultz (20 commits)")[![seejohnrun](https://avatars.githubusercontent.com/u/64965?v=4)](https://github.com/seejohnrun "seejohnrun (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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