Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/beberlei/metrics
- Owner: beberlei
- Created: 2012-05-23T18:20:36.000Z (over 12 years ago)
- Default Branch: 3.x
- Last Pushed: 2024-03-11T07:50:51.000Z (8 months ago)
- Last Synced: 2024-05-02T00:23:45.986Z (6 months ago)
- Language: PHP
- Size: 308 KB
- Stars: 315
- Watchers: 15
- Forks: 38
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-influxdb - metrics - (PHP) 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" (Collecting data into InfluxDB / Libraries)
- awesome-php - Metrics - A simple metrics API library. (Table of Contents / Debugging and Profiling)
- awesome-php-cn - Metrics - 一个简单的度量标准API库. (目录 / 调试和性能分析 Debugging and Profiling)
- awesome-projects - Metrics - A simple metrics API library. (PHP / Debugging and Profiling)
- awesome-php - Metrics - A simple metrics API library. (Table of Contents / Debugging and Profiling)
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');
```