https://github.com/fieg/statistico
Library to track statistics.
https://github.com/fieg/statistico
Last synced: about 1 year ago
JSON representation
Library to track statistics.
- Host: GitHub
- URL: https://github.com/fieg/statistico
- Owner: fieg
- Created: 2014-07-01T13:22:40.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-06-16T15:05:42.000Z (about 10 years ago)
- Last Synced: 2025-06-01T08:43:44.729Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Statistico
==========
Library to track statistics.
[](https://travis-ci.org/fieg/statistico)
Installation
------------
Using composer:
```sh
composer require fieg/statistico:dev-master
```
Usage
-----
Tracking statistics:
```php
use Fieg\Statistico\Statistico;
$redis = new \Redis();
$driver = new Fieg\Statistico\Driver\RedisDriver($redis);
$statistico = new Statistico($driver);
// increment
$statistico->increment('your.bucket.name'); // increments with 1
// gauge
$statistico->gauge('your.bucket.name', 500); // sets bucket value to 500
// timing
$statistico->timing('your.bucket.name', 300); // sets bucket value to 300ms
```
Reading statistics:
```php
use Fieg\Statistico\Reader;
$redis = new \Redis();
$driver = new Fieg\Statistico\Driver\RedisDriver($redis);
$reader = new Reader($driver);
// query counts from 7 days ago to now
$counts = $reader->queryCounts('your.bucket.name', 'seconds', new \DateTime('-7 days'), new \DateTime());
// $counts would now contain an array of (unix) timestamps and counts
// [[10000000, 4], [10000001, 6], ...]
// query timings from 7 days ago to now
$timings = $reader->queryTimings('your.bucket.name', 'seconds', new \DateTime('-7 days'), new \DateTime());
// query gauges from 7 days ago to now
$gauges = $reader->queryGauges('your.bucket.name', 'seconds', new \DateTime('-7 days'), new \DateTime());
```
Available granularities are: seconds, minutes, hours and days.