PHPackages                             ez-php/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. [Framework](/categories/framework)
4. /
5. ez-php/metrics

ActiveLibrary[Framework](/categories/framework)

ez-php/metrics
==============

Prometheus metrics endpoint for ez-php — Counter, Gauge, Histogram with a /metrics route and static Metrics facade.

1.2.0(1mo ago)00MITPHPPHP ^8.5CI passing

Since Mar 28Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/metrics)[ Packagist](https://packagist.org/packages/ez-php/metrics)[ Docs](https://github.com/ez-php/metrics)[ RSS](/packages/ez-php-metrics/feed)WikiDiscussions main Synced 1mo ago

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

ez-php/metrics
==============

[](#ez-phpmetrics)

Prometheus metrics endpoint for the ez-php framework.

Exposes a `/metrics` route in the [Prometheus text exposition format](https://prometheus.io/docs/instrumenting/exposition_formats/). Supports the three standard Prometheus metric types: **Counter**, **Gauge**, and **Histogram**.

---

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

[](#installation)

```
composer require ez-php/metrics
```

Register the provider in `provider/modules.php`:

```
\EzPhp\Metrics\MetricsServiceProvider::class,
```

---

Usage
-----

[](#usage)

### Counter — monotonically increasing

[](#counter--monotonically-increasing)

```
use EzPhp\Metrics\Metrics;

Metrics::counter('http_requests_total', 'Total HTTP requests')
    ->inc(['method' => 'GET', 'status' => '200']);

Metrics::counter('bytes_sent_total', 'Total bytes sent')
    ->incBy(1024.0);
```

### Gauge — current value (can increase or decrease)

[](#gauge--current-value-can-increase-or-decrease)

```
Metrics::gauge('memory_usage_bytes', 'Current memory usage')
    ->set((float) memory_get_usage());

Metrics::gauge('active_connections', 'Active connections')
    ->inc();

Metrics::gauge('queue_depth', 'Queue depth')
    ->dec(['queue' => 'default']);
```

### Histogram — distributions and latency

[](#histogram--distributions-and-latency)

```
$start = microtime(true);
// ... handle request ...
Metrics::histogram('request_duration_seconds', 'Request duration in seconds')
    ->observe(microtime(true) - $start, ['route' => '/api/users']);
```

Custom bucket boundaries:

```
Metrics::histogram('response_size_bytes', 'Response size', [100, 1000, 10000, 100000])
    ->observe((float) strlen($responseBody));
```

---

/metrics endpoint
-----------------

[](#metrics-endpoint)

`MetricsServiceProvider` registers `GET /metrics` automatically. The response body is the full Prometheus text exposition format output:

```
# HELP http_requests_total Total HTTP requests
# TYPE http_requests_total counter
http_requests_total{method="GET",status="200"} 42

# HELP request_duration_seconds Request duration in seconds
# TYPE request_duration_seconds histogram
request_duration_seconds_bucket{route="/api/users",le="0.005"} 0
...
request_duration_seconds_bucket{route="/api/users",le="+Inf"} 5
request_duration_seconds_count{route="/api/users"} 5
request_duration_seconds_sum{route="/api/users"} 1.23

```

**Content-Type:** `text/plain; version=0.0.4; charset=utf-8`

---

Security
--------

[](#security)

The `/metrics` endpoint is unprotected by default. To restrict access, apply middleware in your route definition or via global middleware in your application.

---

Relation to ez-php/health
-------------------------

[](#relation-to-ez-phphealth)

ModulePurpose`ez-php/health`Liveness check — is the service up?`ez-php/metrics`Time-series data — counters, gauges, histograms for alerting and dashboardsBoth are complementary production-observability tools.

---

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

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

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (9 commits)")

---

Tags

phpframeworkmonitoringMetricsobservabilityprometheusez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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