PHPackages                             tuleap/prometheus-client - 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. tuleap/prometheus-client

ActiveLibrary

tuleap/prometheus-client
========================

Prometheus instrumentation library

v1.9.0(5mo ago)10114.9k—5.9%2[5 PRs](https://github.com/Enalean/php-prometheus-client/pulls)Apache-2.0PHPPHP ~8.2.0|~8.3.0|~8.4.0|~8.5.0CI passing

Since Jun 24Pushed 1mo ago9 watchersCompare

[ Source](https://github.com/Enalean/php-prometheus-client)[ Packagist](https://packagist.org/packages/tuleap/prometheus-client)[ RSS](/packages/tuleap-prometheus-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (15)Versions (37)Used By (0)

A prometheus client library written in PHP
==========================================

[](#a-prometheus-client-library-written-in-php)

[![Latest Stable Version](https://camo.githubusercontent.com/51023d3961b69043a384f10abdf8844d4422fbaa893cdeaf822cac43db65423f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74756c6561702f70726f6d6574686575732d636c69656e742e737667)](https://packagist.org/packages/tuleap/prometheus-client)[![Build Status](https://github.com/Enalean/php-prometheus-client/workflows/CI/badge.svg)](https://github.com/Enalean/php-prometheus-client/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/a182a251c791efd4cf48deca85364b72788ff28331e8126d5e2b4c0f16b78e46/68747470733a2f2f636f6465636f762e696f2f67682f456e616c65616e2f7068702d70726f6d6574686575732d636c69656e742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Enalean/php-prometheus-client)[![Type Coverage](https://camo.githubusercontent.com/c02e6d418114feae228382006494f0112a0521047adea00033fe8d7a3c9091e3/68747470733a2f2f73686570686572642e6465762f6769746875622f656e616c65616e2f7068702d70726f6d6574686575732d636c69656e742f636f7665726167652e737667)](https://shepherd.dev/github/enalean/php-prometheus-client)

This library uses Redis or APCu to do the client side aggregation. If using Redis, we recommend to run a local Redis instance next to your PHP workers.

How does it work?
-----------------

[](#how-does-it-work)

Usually PHP worker processes don't share any state. You can pick from three adapters. Redis, APC or an in memory adapter. While the first needs a separate binary running, the second just needs the [APC](https://pecl.php.net/package/APCU) extension to be installed. If you don't need persistent metrics between requests (e.g. a long running cron job or script) the in memory adapter might be suitable to use.

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

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
composer require tuleap/prometheus-client
```

Usage
-----

[](#usage)

A simple counter:

```
$storage = new \Enalean\Prometheus\Storage\InMemoryStore();
(new \Enalean\Prometheus\Registry\CollectorRegistry($storage))
    ->getOrRegisterCounter(\Enalean\Prometheus\Value\MetricName::fromName('some_quick_counter'), 'just a quick measurement')
    ->inc();
```

Write some enhanced metrics:

```
$storage = new \Enalean\Prometheus\Storage\InMemoryStore();
$registry = new \Enalean\Prometheus\Registry\CollectorRegistry($storage);

$counter = $registry->getOrRegisterCounter(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_counter'),
    'it increases',
    \Enalean\Prometheus\Value\MetricLabelNames::fromNames('type')
);
$counter->incBy(3, 'blue');

$gauge = $registry->getOrRegisterGauge(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_gauge'),
    'it sets',
    \Enalean\Prometheus\Value\MetricLabelNames::fromNames('type')
);
$gauge->set(2.5, 'blue');

$histogram = $registry->getOrRegisterHistogram(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_histogram'),
    'it observes',
    \Enalean\Prometheus\Value\HistogramLabelNames::fromNames('type'),
    [0.1, 1, 2, 3.5, 4, 5, 6, 7, 8, 9]
);
$histogram->observe(3.5, 'blue');
```

Manually register and retrieve metrics (these steps are combined in the `getOrRegister...` methods):

```
$storage = new \Enalean\Prometheus\Storage\InMemoryStore();
$registry = new \Enalean\Prometheus\Registry\CollectorRegistry($storage);

$counterA = $registry->registerCounter(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_counter'),
    'it increases',
    \Enalean\Prometheus\Value\MetricLabelNames::fromNames('type')
);
$counterA->incBy(3, 'blue');

// once a metric is registered, it can be retrieved using e.g. getCounter:
$counterB = $registry->getCounter(\Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_counter'));
$counterB->incBy(2, 'red');
```

Expose the metrics:

```
$storage = new \Enalean\Prometheus\Storage\InMemoryStore();
$registry = new \Enalean\Prometheus\Registry\CollectorRegistry($storage);

$renderer = new \Enalean\Prometheus\Renderer\RenderTextFormat();

header('Content-type: ' . $renderer->getMimeType());
echo $renderer->render($registry->getMetricFamilySamples());
```

Using the Redis storage:

```
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$storage = new \Enalean\Prometheus\Storage\RedisStore($redis);
$registry = new \Enalean\Prometheus\Registry\CollectorRegistry($storage);

$counter = $registry->registerCounter(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_counter'),
    'it increases',
    \Enalean\Prometheus\Value\MetricLabelNames::fromNames('type')
);
$counter->incBy(3, 'blue');

$renderer = new \Enalean\Prometheus\Renderer\RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
```

Using the APCu storage:

```
$storage = new \Enalean\Prometheus\Storage\APCUStore();
$registry = new \Enalean\Prometheus\Registry\CollectorRegistry($storage);

$counter = $registry->registerCounter(
    \Enalean\Prometheus\Value\MetricName::fromNamespacedName('test', 'some_counter'),
    'it increases',
    \Enalean\Prometheus\Value\MetricLabelNames::fromNames('type')
);
$counter->incBy(3, 'blue');

$renderer = new \Enalean\Prometheus\Renderer\RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
```

Also look at the [examples](examples).

Development
-----------

[](#development)

### Dependencies

[](#dependencies)

- PHP 7.3+
- PHP Redis extension
- PHP APCu extension
- [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
- Redis

Start a Redis instance:

```
docker-compose up redis

```

### Tests

[](#tests)

Run the tests:

```
composer install

# when Redis is not listening on localhost:
# export REDIS_HOST=192.168.59.100
./vendor/bin/phpunit
# You might need to enable APCu on the CLI
php -d apc.enable_cli=1 vendor/bin/phpunit

```

Run the tests with mutation testing:

```
# when Redis is not listening on localhost:
# export REDIS_HOST=192.168.59.100
./vendor/bin/infection --initial-tests-php-options="-d apc.enable_cli=1"

```

Run the static analysis:

```
vendor/bin/psalm

```

Check conformance with the coding standards:

```
vendor/bin/phpcs

```

### Black box testing

[](#black-box-testing)

Just start the nginx, fpm &amp; Redis setup with docker-compose:

```
docker-compose up

```

Pick the adapter you want to test.

```
docker-compose exec phpunit env ADAPTER=apcu vendor/bin/phpunit --testsuite=functionnal
docker-compose exec phpunit env ADAPTER=redis vendor/bin/phpunit --testsuite=functionnal

```

Acknowledgment
--------------

[](#acknowledgment)

This library is based on the work done on [Jimdo/prometheus\_client\_php](https://github.com/Jimdo/prometheus_client_php).

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

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

Every ~132 days

Recently: every ~248 days

Total

27

Last Release

164d ago

Major Versions

v0.9.1 → v1.0.02020-02-07

PHP version history (12 changes)v0.1.0PHP &gt;=5.6.0

v0.2.0PHP &gt;=5.3.3

v0.6.0PHP &gt;=5.6.3

v1.0.0PHP &gt;=7.3

v1.1.0PHP ^7.3|^7.4|^8.0

v1.2.0PHP ~7.3.0|~7.4.0|~8.0.0

v1.3.0PHP ~8.0.0|~8.1.0

v1.4.0PHP ~8.0.0|~8.1.0|~8.2.0

v1.5.0PHP ~8.1.0|~8.2.0

v1.7.0PHP ~8.1.0|~8.2.0|~8.3.0

v1.8.0PHP ~8.2.0|~8.3.0|~8.4.0

v1.9.0PHP ~8.2.0|~8.3.0|~8.4.0|~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b3676ab4de37017277bdb538aaa5f44eb9f20ddcdf7c38de459cad2dd946e6b?d=identicon)[tuleap](/maintainers/tuleap)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (631 commits)")[![LeSuisse](https://avatars.githubusercontent.com/u/737767?v=4)](https://github.com/LeSuisse "LeSuisse (191 commits)")[![schnipseljagd](https://avatars.githubusercontent.com/u/289073?v=4)](https://github.com/schnipseljagd "schnipseljagd (110 commits)")[![bracki](https://avatars.githubusercontent.com/u/49786?v=4)](https://github.com/bracki "bracki (97 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (85 commits)")[![jlis](https://avatars.githubusercontent.com/u/1401164?v=4)](https://github.com/jlis "jlis (6 commits)")[![buffcode](https://avatars.githubusercontent.com/u/2863518?v=4)](https://github.com/buffcode "buffcode (3 commits)")[![mps-sepetrov](https://avatars.githubusercontent.com/u/24416480?v=4)](https://github.com/mps-sepetrov "mps-sepetrov (3 commits)")[![vaceletm](https://avatars.githubusercontent.com/u/216464?v=4)](https://github.com/vaceletm "vaceletm (2 commits)")[![rdohms](https://avatars.githubusercontent.com/u/94331?v=4)](https://github.com/rdohms "rdohms (2 commits)")[![Hyzual](https://avatars.githubusercontent.com/u/2051507?v=4)](https://github.com/Hyzual "Hyzual (2 commits)")[![vlydev](https://avatars.githubusercontent.com/u/2308269?v=4)](https://github.com/vlydev "vlydev (1 commits)")[![crazycodr](https://avatars.githubusercontent.com/u/4398521?v=4)](https://github.com/crazycodr "crazycodr (1 commits)")[![cweiske](https://avatars.githubusercontent.com/u/59036?v=4)](https://github.com/cweiske "cweiske (1 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![lvrach](https://avatars.githubusercontent.com/u/733195?v=4)](https://github.com/lvrach "lvrach (1 commits)")[![oraoto](https://avatars.githubusercontent.com/u/24709398?v=4)](https://github.com/oraoto "oraoto (1 commits)")[![samnela](https://avatars.githubusercontent.com/u/1852108?v=4)](https://github.com/samnela "samnela (1 commits)")[![seiffert](https://avatars.githubusercontent.com/u/1111118?v=4)](https://github.com/seiffert "seiffert (1 commits)")[![1player](https://avatars.githubusercontent.com/u/690120?v=4)](https://github.com/1player "1player (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tuleap-prometheus-client/health.svg)

```
[![Health](https://phpackages.com/badges/tuleap-prometheus-client/health.svg)](https://phpackages.com/packages/tuleap-prometheus-client)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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