Description
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:
Metrics alternatives and similar libraries
Based on the "Miscellaneous" category.
Alternatively, view Metrics alternatives based on common mentions on social networks and blogs.
-
Country List
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats. -
Hprose-PHP
Hprose is a cross-language RPC. This project is Hprose 3.0 for PHP -
SuperClosure
Serialize closures. Not maintained. Consider using opis/closure. -
dotenv-linter
⚡️Lightning-fast linter for .env files. Written in Rust 🦀 -
Pagerfanta
Pagination library for PHP applications with support for several data providers -
Essence
Extracts information about web pages, like youtube videos, twitter statuses or blog articles. -
sabre/vobject
:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects -
Token Bucket
Implementation of the Token Bucket algorithm in PHP. -
Prooph Service Bus
PHP Lightweight Message Bus supporting CQRS. -
Lodash-PHP
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP -
Embera
A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support. -
noCAPTCHA
:passport_control: Helper for Google's new noCAPTCHA (reCAPTCHA v2 & v3) -
ClassPreloader
Optimizes class loading performance by generating a single PHP file containing all of the autoloaded files. -
git-profile
Utility that helps you switch git configurations with ease. -
Slimdump
A tool for creating configurable dumps of large MySQL-databases. -
Cake Utility
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp -
RedisSessionHandler
An alternative Redis session handler for PHP featuring per-session locking and session fixation protection -
html-object
A set of classes to create and manipulate HTML objects abstractions -
Sslurp
Sslurp is a simple library which aims to make properly dealing with SSL in PHP suck less. -
Procrastinator
Execute time consuming tasks as late as possible in a request -
Yell
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.
Static code analysis for 29 languages.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Metrics or a related project?
Popular Comparisons
README
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:
composer require beberlei/metrics
API
You can instantiate clients:
<?php
$collector = \Beberlei\Metrics\Factory::create('statsd');
You can measure stats:
<?php
$collector->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
$collector->flush();
Configuration
<?php
$statsd = \Beberlei\Metrics\Factory::create('statsd');
$zabbix = \Beberlei\Metrics\Factory::create('zabbix', array(
'hostname' => '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
class AppKernel extends Kernel
{
public function registerBundles()
{
//..
$bundles[] = new \Beberlei\Bundle\MetricsBundle\BeberleiMetricsBundle();
//..
}
}
Do Configuration:
# app/config/config.yml
beberlei_metrics:
default: foo
collectors:
foo:
type: statsd
bar:
type: zabbix
prefix: foo.beberlei.de
host: localhost
port: 10051
baz:
type: zabbix_file
prefix: foo.beberlei.de
file: /etc/zabbix/zabbix_agentd.conf
librato:
type: librato
username: foo
password: bar
source: hermes10
dbal:
type: doctrine_dbal
connection: metrics # using the connection named "metrics"
monolog:
type: monolog
influxdb:
type: influxdb
influxdb_client: influxdb_client_service # using the InfluxDB client service named "influxdb_client_service"
tags:
dc: "west"
node_instance: "hermes10"
prometheus:
type: prometheus
prometheus_collector_registry: prometheus_collector_registry_service # using the Prometheus collector registry service named "prometheus_collector_registry_service"
namespace: app_name # optional
tags:
dc: "west"
node_instance: "hermes10"
This adds collectors to the Metrics registry. The functions are automatically included in the Bundle class so that in your code you can just start using the convenient functions. Metrics are also added as services:
<?php
$metrics = $container->get('beberlei_metrics.collector.foo');
and the default collector can be fetched:
<?php
$metrics = $container->get('beberlei_metrics.collector');