nti/metrics-bundle

Send metrics to StatsD Server.

v1.1.0 2020-08-12 15:59 UTC

This package is auto-updated.

Last update: 2024-05-13 00:26:52 UTC


README

StatsD Client

Installation

  1. Install the bundle using composer:

    $ composer require nti/metrics-bundle "dev-master"
  2. Add the bundle configuration to the AppKernel

    public function registerBundles()
    {
        $bundles = array(
            ...
            new NTI\MetricsBundle\NTIMetricsBundle(),
            ...
        );
    }
  3. Setup the configuration in the config.yml

# NTI Metrics
nti_metrics:
    host: "statsDserver" # default: localhost
    port: 8125           # default: 8125
    prefix: "greenlink." # default: ""

Usage

  1. Get the Metrics Client service
$collector = $container->get('nti.metrics');

The following methods are available for send metrics:

$collector->increment('glbs.email.send');            # Same as send "glbs.email.send:1|c"
$collector->decrement('glbs.email.send');            # Same as send "glbs.email.send:-1|c"

To send the values to statsD server you have to call the following method:

$collector->flush();