• Stars
    star
    316
  • Rank 132,587 (Top 3 %)
  • Language
    PHP
  • Created over 12 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

Metrics

Build Status

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');

More Repositories

1

assert

Thin assertion library for use in libraries and business-model
PHP
2,407
star
2

DoctrineExtensions

A set of Doctrine 2 extensions
PHP
1,956
star
3

litecqrs-php

Small convention based CQRS library for PHP
PHP
553
star
4

composer-monorepo-plugin

Integrates Composer into monolithic repositories with many packages.
PHP
305
star
5

porpaginas

A simple abstraction for paginated and non-paginated results
PHP
159
star
6

AcmePizzaBundle

Acme Form Experimental Bundle
PHP
131
star
7

php-rfc-watch

Interactive voting results for PHP RFC process.
HTML
127
star
8

zf-doctrine

A Zend Framework 1.x and Doctrine 1.2 Integration - UNMAINTAINED
PHP
102
star
9

netbeans-php-enhancements

Netbeans PHP Enhancements, such as PHP Code Sniffer Support
Java
102
star
10

fastcgi-serve

Small webserver to use in front of fast-cgi servers (php-fpm, hhvm, ...)
Go
92
star
11

symfony-minimal-distribution

This contains the code from my blog post http://whitewashing.de/2014/10/26/symfony_all_the_things_web.html
PHP
67
star
12

bankaccount

Sample application used for PHPUnit training.
PHP
46
star
13

vim-php-refactor

Some simple vim refactoring functions for your PHP code
Vim Script
40
star
14

xdebug-trace-gui

Fork of Trace GUI by Thomas Hambach
PHP
35
star
15

license-manager

License Switch Project - Helping open source projects to switch licenses
CSS
34
star
16

Doctrine-Workflow

A Doctrine 2 persistence layer for ezcWorkflow
PHP
33
star
17

DoctrineCodeGenerator

Prototype of an AST based Event Driven CodeGenerator
PHP
31
star
18

http-client-middleware

Missing interfaces for HTTP-Client middlewares using PSR-7 messages.
PHP
28
star
19

Doctrine-ActiveEntity

ActiveRecord ORM (Mod) on top of Doctrine2
PHP
25
star
20

env

PHP PECL extension for loading 12factor env variables from a file
C
24
star
21

Whitewashing

Symfony2 Bundle that powers the www.whitewashing.de blog
PHP
23
star
22

azure-blob-storage

Small platform-independent library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
PHP
22
star
23

WhitewashingZFMvcCompatBundle

PHP
21
star
24

zelten

A social network website based on tent.io protocol
JavaScript
17
star
25

TentPHP

A Tent.io client written in PHP
PHP
16
star
26

githubpr_to_jira

Converts Github PR to Jira Issues
PHP
16
star
27

pearanha

Pearanha is deprecated, use Composer intead
PHP
15
star
28

context

DEPRECATED
PHP
15
star
29

WhitewashingLogglyBundle

loggly.com logger for Monolog integrated into Symfony2 - not really maintained anymore
PHP
15
star
30

php-compiletime-poc

Extension that counts the time spent in PHP file compilation during the execution of a script
C
13
star
31

php-ast-tracer-poc

C
13
star
32

doctrine-example-app

Example App Setup for Training/Workshops
PHP
13
star
33

dbdeploy-php

DBDeploy PHP clone
PHP
12
star
34

ZendNavigationBundle

A Zend Navigation Bundle for Symfony2
PHP
11
star
35

phpricot

A forgiving HTML Parsing library written in PHP
PHP
11
star
36

hdrhistogram-php

A PHP extension wrapper for the C hdrhistogram API.
C
10
star
37

symfony-azure-edition

Symfony2 on Windows Azure Edition
PHP
10
star
38

ReviewSquawkBundle

Symfony2 app that provides a static-code-analysis as a service platform
JavaScript
9
star
39

ZetaBundle

A Zeta Components Bundle for Symfony2
PHP
8
star
40

websocket-proxy-example

Example Go microservice that acts as a Websocket proxy for other server applications
Go
6
star
41

stdlib

Some fun
PHP
6
star
42

compilefile-ext

C
5
star
43

php8-benchmark-doctrine

PHP
5
star
44

Zend_Db-Adapter-for-ext-mysql

Legacy applications often work with ext/mysql all over the place. This Zend_Db adapter allows to share the resources and benefit from Zend_Db.
PHP
5
star
45

ZetaWorkflowCouchDB

Zeta Components CouchDB Backend for Workflow
PHP
4
star
46

php-overload-poc

C
4
star
47

php-couch-content-repository

PHP
3
star
48

flow3-doctrine2

prototype hack for doctrine2 as persistence manager for flow3
PHP
3
star
49

funcall

Fork of the pecl extension "funcall"
C
3
star
50

redmine_gherkinviewer

Redmine Plugin: Display feature files from project repository directly in a "Features" tab in the project.
Ruby
3
star
51

AzureTaskDemoBundle

Demo bundle for Azure Functionality with a Symfony+Doctrine application
JavaScript
2
star
52

beberlei

1
star
53

deprecations

PHP
1
star
54

pecl_http

PHP
1
star
55

cj-push-server

PubSubHubBub Server in Clojure
Clojure
1
star
56

interrupt-sampler-poc

C
1
star
57

hdrhistogram-php-stubs

Adding support for hdrhistogram in IDEs and Scrutinizer
PHP
1
star