PHPackages                             hellofresh/stats-php - 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. hellofresh/stats-php

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

hellofresh/stats-php
====================

2.0.0(6y ago)546.7k2MITPHPPHP &gt;= 7.3CI passing

Since Oct 24Pushed 7mo ago209 watchersCompare

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

READMEChangelog (8)Dependencies (5)Versions (15)Used By (0)

hellofresh/stats-php
====================

[](#hellofreshstats-php)

[![codecov](https://camo.githubusercontent.com/751b2986c0804a00f35409060e2292d6a24bf09ea9ff1a9933c5a18dcbfacf1e/68747470733a2f2f636f6465636f762e696f2f67682f68656c6c6f66726573682f73746174732d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/hellofresh/stats-php)

> Generic Stats library written in PHP

This is generic stats library that we at HelloFresh use in our projects to collect services' stats and then create monitoring dashboards to track activity and problems.

Supported PHP versions
----------------------

[](#supported-php-versions)

`stats-php` version `1.x` supports the following PHP version: `7.0`, `7.1`, `7.2`. If you are going to use the library with newer PHP versions - consider using version `2.x+`.

Since version `2.x`, this library start using the built-in `intl` PHP extension instead of `behat/transliterator`

Key Features
------------

[](#key-features)

- Several stats backends:
    - `log` for development environment
    - `statsd` for production
    - `memory` for testing purpose, to track stats operations in unit tests
    - `noop` for environments that do not require any stats gathering
- Fixed metric sections count for all metrics to allow easy monitoring/alerting setup in `grafana`
- Easy to build HTTP requests metrics - timing and count
- Generalise or modify HTTP Requests metric - e.g. skip ID part

Dependencies
------------

[](#dependencies)

### Version `1.x`

[](#version-1x)

- `php: >= 7.0`
- `behat/transliterator: ^1.2`

### Version `2.x`

[](#version-2x)

- `php: >= 7.3`
- `ext-intl: >= 2.0`

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

[](#installation)

```
composer require hellofresh/stats-php
```

Usage
-----

[](#usage)

### Instance creation

[](#instance-creation)

Connection DSN has the following format: `:///?`.

- `` - one of supported backends: `log`, `statsd`, `memory`, `noop`
- `` - used for `statsd` backend only, to defining host and port
- `` - used for `statsd` backend only, to define prefix/namespace
- `` - user for `statsd` backend only:
    - `timeout` - statsd request timeout in seconds, if not set `ini_get('default_socket_timeout')` is used
    - `error` - throw connection error exception, default value is `true`

```
