PHPackages                             hitmeister/metrics - 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. hitmeister/metrics

Abandoned → [influxdb/influxdb-php](/?search=influxdb%2Finfluxdb-php)Library[Logging &amp; Monitoring](/categories/logging)

hitmeister/metrics
==================

Metrics forwarder for PHP.

2.0.2(10y ago)52.0kMITPHPPHP &gt;=5.5

Since Jun 14Pushed 9y ago3 watchersCompare

[ Source](https://github.com/hitmeister/metrics)[ Packagist](https://packagist.org/packages/hitmeister/metrics)[ Docs](https://www.hitmeister.de/)[ RSS](/packages/hitmeister-metrics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

Metrics [![Build Status](https://camo.githubusercontent.com/93395af477dcfadf62513b54bd1307a1f0326b64bf829fce48f06fbe5a5e7020/68747470733a2f2f7472617669732d63692e6f72672f6869746d6569737465722f6d6574726963732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hitmeister/metrics)
=============================================================================================================================================================================================================================================================================================

[](#metrics--)

[![Latest Stable Version](https://camo.githubusercontent.com/4eabb5baa2613bdd5287549844ef936715c38ddb5d67e9032a140f2567c2a72e/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6869746d6569737465722f6d6574726963732e737667)](https://packagist.org/packages/hitmeister/metrics)[![Coverage Status](https://camo.githubusercontent.com/fd097ff8420fbffbf3a45379b934e040ac345da370b4b810ace1b63080ba5d47/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6869746d6569737465722f6d6574726963732e737667)](https://coveralls.io/r/hitmeister/metrics?branch=master)[![Total Downloads](https://camo.githubusercontent.com/fc8849795834ecacc600c38a87c7c45fa0b3b070897516f4af2f7abf2d01da30/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6869746d6569737465722f6d6574726963732e737667)](https://packagist.org/packages/hitmeister/metrics)

Metrics forwarder for PHP. We can forward to [statsd](https://github.com/etsy/statsd) and [InfluxDB](https://influxdb.com/).

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

[](#installation)

You can install the component in two different ways:

- Install it via Composer: **hitmeister/metrics** on [Packagist](https://packagist.org/packages/hitmeister/metrics);
- Use the [official Git repository](https://github.com/hitmeister/metrics): `git clone git@github.com:hitmeister/metrics.git`.

Usage
-----

[](#usage)

Here is some examples how you can use this library.

### Stats Daemon

[](#stats-daemon)

```
use Hitmeister\Component\Metrics\Collector;
use Hitmeister\Component\Metrics\Handler\StatsDaemonHandler;

// Create new handler
$handler = new StatsDaemonHandler('127.0.0.1', 8125);

// Create new collector and set handler
$collector = new Collector();
$collector->setHandler($handler);

// Increment one stats
$collector->increment('hello_world');

// Increments `one_long_task` counter and reports used memory and elapsed time
$collector->closure('one_long_task', function(){
    for ($i = 0; $i < 1000; $i++) {
        usleep(100);
    }
});
```

### InfluxDB 0.9.x UDP

[](#influxdb-09x-udp)

#### Important notice

[](#important-notice)

If you are using InfluxDb &gt;= 0.9.3 you have to specify new Formatter for handler.

```
use \Hitmeister\Component\Metrics\Formatter\InfluxDb\LineFormatter;
// ....
$handler = new UdpHandler('127.0.0.1', 4444);
$handler->setFormatter(new LineFormatter());
// ....
```

If you are using InfluxDB &lt;= 0.9.2 you don't have to change anything.

```
use Hitmeister\Component\Metrics\Collector;
use Hitmeister\Component\Metrics\Handler\InfluxDb\UdpHandler;

// Create new handler
$handler = new UdpHandler('127.0.0.1', 4444);

// Create new collector and set handler
$collector = new Collector();
$collector->setHandler($handler);

// Set global tags
$collector->setTags([
    'env' => 'development',
    'instance' => 'web01',
]);

// Increment one stats
$collector->increment('hello', ['operation' => 'world']);

// Increments `one_long_task` counter and reports used memory and elapsed time
$collector->closure('one_long_task', function(){
    for ($i = 0; $i < 1000; $i++) {
        usleep(100);
    }
});
```

### Flush metrics on script shutdown

[](#flush-metrics-on-script-shutdown)

```
use Hitmeister\Component\Metrics\Buffer\OnShutdownBuffer;
use Hitmeister\Component\Metrics\Collector;
use Hitmeister\Component\Metrics\Handler\StatsDaemonHandler;

// Create new handler
$handler = new StatsDaemonHandler('127.0.0.1', 8125);

// Create buffer
$buffer = new OnShutdownBuffer();
$buffer->setHandler($handler);

// Create new collector and set buffer
$collector = new Collector();
$collector->setBuffer($buffer);

// Increment some stats
for ($i = 0; $i < 100; $i++) {
    $collector->increment('stats_'.$i);
}

// All metrics will be flushed to the stats daemon after script shutdown
// It uses register_shutdown_function function under the hood
```

Some benchmarks
---------------

[](#some-benchmarks)

```
Hitmeister\Component\Metrics\Benchmarks\Collector\InfluxUdpImmediateEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    counterName                    : [1,000     ] [0.0002313616276] [4,322.23792]
    counterNameMultiValue          : [1,000     ] [0.0000676133633] [14,789.97570]
    counterPrefixName              : [1,000     ] [0.0000578238964] [17,293.88820]
    counterPrefixNameMultiValue    : [1,000     ] [0.0000662095547] [15,103.56028]
    counterTagsName                : [1,000     ] [0.0000726783276] [13,759.25993]
    counterTagsNameMultiValue      : [1,000     ] [0.0000773749352] [12,924.08191]
    counterTagsNamePrefix          : [1,000     ] [0.0000779783726] [12,824.06861]
    counterTagsNamePrefixMultiValue: [1,000     ] [0.0000772831440] [12,939.43217]

Hitmeister\Component\Metrics\Benchmarks\Collector\InfluxUdpShutdownEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    counterName                    : [1,000     ] [0.0000207498074] [48,193.21851]
    counterNameMultiValue          : [1,000     ] [0.0000219464302] [45,565.49701]
    counterPrefixName              : [1,000     ] [0.0000201663971] [49,587.43970]
    counterPrefixNameMultiValue    : [1,000     ] [0.0000193657875] [51,637.45599]
    counterTagsName                : [1,000     ] [0.0000242691040] [41,204.65262]
    counterTagsNameMultiValue      : [1,000     ] [0.0000208075047] [48,059.58315]
    counterTagsNamePrefix          : [1,000     ] [0.0000179619789] [55,673.15299]
    counterTagsNamePrefixMultiValue: [1,000     ] [0.0000188963413] [52,920.29726]

Hitmeister\Component\Metrics\Benchmarks\Collector\NoHandlerEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    counterName                    : [1,000     ] [0.0000142347813] [70,250.46479]
    counterNameMultiValue          : [1,000     ] [0.0000161037445] [62,097.35876]
    counterPrefixName              : [1,000     ] [0.0000175075531] [57,118.20460]
    counterPrefixNameMultiValue    : [1,000     ] [0.0000142931938] [69,963.36947]
    counterTagsName                : [1,000     ] [0.0000159406662] [62,732.63536]
    counterTagsNameMultiValue      : [1,000     ] [0.0000165419579] [60,452.33634]
    counterTagsNamePrefix          : [1,000     ] [0.0000143866539] [69,508.86613]
    counterTagsNamePrefixMultiValue: [1,000     ] [0.0000144739151] [69,089.80694]

Hitmeister\Component\Metrics\Benchmarks\Collector\StatsDaemonImmediateEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    counterName                    : [1,000     ] [0.0002136104107] [4,681.41977]
    counterNameMultiValue          : [1,000     ] [0.0000218720436] [45,720.46480]
    counterPrefixName              : [1,000     ] [0.0000505478382] [19,783.23971]
    counterPrefixNameMultiValue    : [1,000     ] [0.0000250971317] [39,845.19071]
    counterTagsName                : [1,000     ] [0.0000598993301] [16,694.67751]
    counterTagsNameMultiValue      : [1,000     ] [0.0000255017281] [39,213.02893]
    counterTagsNamePrefix          : [1,000     ] [0.0000610182285] [16,388.54526]
    counterTagsNamePrefixMultiValue: [1,000     ] [0.0000282423496] [35,407.81887]

Hitmeister\Component\Metrics\Benchmarks\Collector\StatsDaemonShutdownEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    counterName                    : [1,000     ] [0.0000177154541] [56,447.88975]
    counterNameMultiValue          : [1,000     ] [0.0000172858238] [57,850.87308]
    counterPrefixName              : [1,000     ] [0.0000182156563] [54,897.82990]
    counterPrefixNameMultiValue    : [1,000     ] [0.0000215911865] [46,315.19435]
    counterTagsName                : [1,000     ] [0.0000220284462] [45,395.84822]
    counterTagsNameMultiValue      : [1,000     ] [0.0000185434818] [53,927.30499]
    counterTagsNamePrefix          : [1,000     ] [0.0000192592144] [51,923.19786]
    counterTagsNamePrefixMultiValue: [1,000     ] [0.0000217378139] [46,002.78585]

Hitmeister\Component\Metrics\Benchmarks\Formatter\InfluxDbLineEvent
    Method Name                Iterations    Average Time      Ops/second
    ------------------------  ------------  --------------    -------------
    counterName             : [10,000    ] [0.0000206048250] [48,532.32187]
    counterNameAndTags      : [1,000     ] [0.0000351431370] [28,455.05797]
    counterNameTagsAndSample: [1,000     ] [0.0000465621948] [21,476.65083]

Hitmeister\Component\Metrics\Benchmarks\Formatter\StatsDaemonEvent
    Method Name                Iterations    Average Time      Ops/second
    ------------------------  ------------  --------------    -------------
    counterName             : [10,000    ] [0.0000089899778] [111,234.97946]
    counterNameAndTags      : [1,000     ] [0.0000233101845] [42,899.70339]
    counterNameTagsAndSample: [1,000     ] [0.0000242178440] [41,291.86725]

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~17 days

Total

6

Last Release

3902d ago

Major Versions

1.0.1 → 2.0.0-rc12015-06-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/1fa348b195270b0730fc61916236dea129a9f2e25898c6233c1433469b77b5bb?d=identicon)[digitalcrab](/maintainers/digitalcrab)

![](https://www.gravatar.com/avatar/92b6b5d852eb4d345e999bf340ce84c5ccc70a8f3201b7708172f2cfeee0f4c9?d=identicon)[hitmeister](/maintainers/hitmeister)

---

Top Contributors

[![aazon](https://avatars.githubusercontent.com/u/378058?v=4)](https://github.com/aazon "aazon (1 commits)")

---

Tags

monitoringstatsdMetricstimercounterinfluxdbgaugeinflux

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hitmeister-metrics/health.svg)

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

###  Alternatives

[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19024.6M15](/packages/datadog-php-datadogstatsd)[slickdeals/statsd

a PHP client for statsd

264.5M8](/packages/slickdeals-statsd)[liuggio/statsd-php-client

Statsd (Object Oriented) client library for PHP

1153.9M9](/packages/liuggio-statsd-php-client)[open-telemetry/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)

PHPackages © 2026

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