Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/beberlei/metrics

Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.
https://github.com/beberlei/metrics

Last synced: 9 days ago
JSON representation

Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.

Awesome Lists containing this project

README

        

# Metrics

[![Build Status](https://travis-ci.org/beberlei/metrics.svg?branch=master)](https://travis-ci.org/beberlei/metrics)

Simple library that abstracts different metrics collectors. I find this
necessary to have a consistent and simple metrics API that doesn't cause vendor
lock-in.

It also ships with a Symfony Bundle. **This is not a library for displaying metrics.**

Currently supported backends:

* Doctrine DBAL
* Graphite
* InfluxDB
* Telegraf
* Librato
* Logger (Psr\Log\LoggerInterface)
* Null (Dummy that does nothing)
* Prometheus
* StatsD
* Zabbix
* DogStatsD

## Installation

Using Composer:

```bash
composer require beberlei/metrics
```

## API

You can instantiate clients:

```php
increment('foo.bar');
$collector->decrement('foo.bar');

$start = microtime(true);
$diff = microtime(true) - $start;
$collector->timing('foo.bar', $diff);

$value = 1234;
$collector->measure('foo.bar', $value);
```

Some backends defer sending and aggregate all information, make sure to call
flush:

```php
flush();
```

## Configuration

```php
'foo.beberlei.de',
'server' => 'localhost',
'port' => 10051,
));

$zabbixConfig = \Beberlei\Metrics\Factory::create('zabbix_file', array(
'hostname' => 'foo.beberlei.de',
'file' => '/etc/zabbix/zabbix_agentd.conf'
));

$librato = \Beberlei\Metrics\Factory::create('librato', array(
'hostname' => 'foo.beberlei.de',
'username' => 'foo',
'password' => 'bar',
));

$null = \Beberlei\Metrics\Factory::create('null');
```

## Symfony Bundle Integration

Register Bundle into Kernel:

```php
get('beberlei_metrics.collector.foo');
```

and the default collector can be fetched:

```php
get('beberlei_metrics.collector');
```