Giter Site home page Giter Site logo

php-statsd's Introduction

php-statsd

Simple PHP library to send stats to statsd.

Installation

Add the dependency to your composer.json.

{
    "require": {
        "shazam/php-statsd": "2.*"
    }
}

Usage

An example of how to send metrics of how long it takes to load a page.

<?php

use Statsd;

// $config = array(...);
// $path = ...

// initialize client
$configuration = new Statsd\Client\Configuration();
$configuration->setHost($config['host'])
    ->setNamespace($config['namespace']);

$statsClient = new Statsd\Client($configuration);

// add stats (you can also add an array of stats with addStats())
$statsClient->addStat(
    array(
        'namespace' => 'endpoints.' . $path, // that will be your stat namespace
        'value' => $executionTime, // calculate it in microseconds
        'type' => 'ms'
    )
);

// send them
$statsClient->sendStats();

You can use TIME_MS, COUNT, GAUGE or SET (ms, c, g, s) as type of stats.

Configuration

  • A host to push metrics (use 127.0.0.1 if you have netpipes installed in your box).
  • A port (by default, 8126).
  • A namespace (where all your metrics will be added. Use "." to separate folders.
  • Optionally, a Monolog\Logger object, to log the metrics.

An example of a config file for that client could be:

stats:
  enable: true
  client:
    host: 127.0.0.1
    namespace: shazam.twitterhose

php-statsd's People

Contributors

iordanis avatar

Watchers

James Cloos avatar

Forkers

tubbz-alt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.