PHPackages                             clearspring/phetric - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. clearspring/phetric

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

clearspring/phetric
===================

Emit metrics about your application

2610.0k8PHP

Since Feb 14Pushed 12y ago8 watchersCompare

[ Source](https://github.com/addthis/Phetric)[ Packagist](https://packagist.org/packages/clearspring/phetric)[ RSS](/packages/clearspring-phetric/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Phetric
=======

[](#phetric)

Phetric is a library that allow you to send PHP application-level metrics to a catcher (such as [MetricCatcher](https://github.com/addthis/MetricCatcher)) that then makes them available in a fun and interesting way.

License
-------

[](#license)

Licensed under the MIT licenses.

Copyright (c) 2013 AddThis

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.

How to Use Phetric
------------------

[](#how-to-use-phetric)

If you are not using an autoloader, you need to include the Sender (which will pull in everything else):

```
require_once('phetric/Sender.php');
```

Next up, you need to tell Phetric where it should send stats once it has them. When we init the sender, we need to say where we want our metrics, what port we want them sent to, and an optional string that will be prepended to all the stats. This is usefull for identifying the application that is sending the request.

```
Phetric_Sender::init( 'localhost', '1420', $prepend );
```

Finally, we can send our metrics. Phetric implements Gauges, Counters, Meters, Histograms and Timers. When you create a new metric, you need to create it with a name and for everything other than timers, mark our value.

### Gauges

[](#gauges)

```
// Create a metric and mark some data
$gauge = Phetric_Gauge::create('label');
$gauge->mark(42414);
```

### Timers

[](#timers)

Timers count in microseconds the time betweent when they are started and stopped.

```
// Create a Timer and call it
$blue = Phetric_Timer::create('blue');
$blue->start();

// Do something

// Stop our Timer
$blue->stop();
```

### Counter

[](#counter)

Counters default to 1 if you don't specifify a number when you mark it

```
// One line example
Phetric_Counter::create('orange')->mark(123);
```

### Meter

[](#meter)

A meter measures the rate of events over time (e.g., “requests per second”). In addition to the mean rate, meters also track 1-, 5-, and 15-minute moving averages.

```
Phetric_Meter::create('red')->mark(123);
```

### Histogram

[](#histogram)

A histogram measures the statistical distribution of values. In addition to minimum, maximum, mean, etc., it also measures median, 75th, 90th, 95th, 98th, 99th, and 99.9th percentiles.

```
$yellow = Phetric_Histogram::create('yellow');
$yellow->mark(13);
```

Checking the data you are sending
---------------------------------

[](#checking-the-data-you-are-sending)

If you don't want run a local copy of MetricCatcher, this bash function will use netcat to listen on 1420 and output anything that arrives on UDP.

```
catcher(){
    while true;
    do
        nc -w 1 -l -u 1420;
    done;
}

```

Administrivia
=============

[](#administrivia)

Author
------

[](#author)

Phetric was written by [Aaron Jorbin](http://aaron.jorb.in) while at [AddThis](http://addthis.com).

Using Phetric with Composer
---------------------------

[](#using-phetric-with-composer)

Phetric is available on [packagist](https://packagist.org/packages/clearspring/phetric) thanks to

Bugs &amp; so forth
-------------------

[](#bugs--so-forth)

Please reqport bugs or request new features at the GitHub page for Phetric:

Jobs
----

[](#jobs)

When this was written, AddThis was hiring; even if the blame on this line is from long ago, they probably still are. Check out  if you're intersted in doing webapps, working with Big Data, and like smart, fun coworkers. AddThis is based just outside of Washington, DC (Tysons Corner) and has offices in New York, Los Angeles, and beyond.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/323cf209e19dd825678e9ccc51bc3f745f96571f1c68af26ae7955c1fa9ad1f2?d=identicon)[aaronjorbin](/maintainers/aaronjorbin)

---

Top Contributors

[![aaronjorbin](https://avatars.githubusercontent.com/u/622599?v=4)](https://github.com/aaronjorbin "aaronjorbin (11 commits)")[![ammmze](https://avatars.githubusercontent.com/u/203336?v=4)](https://github.com/ammmze "ammmze (1 commits)")[![cburroughs](https://avatars.githubusercontent.com/u/24433?v=4)](https://github.com/cburroughs "cburroughs (1 commits)")[![rfagen](https://avatars.githubusercontent.com/u/2048237?v=4)](https://github.com/rfagen "rfagen (1 commits)")

### Embed Badge

![Health badge](/badges/clearspring-phetric/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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