2017 © Pedro Peláez
 

library statsd-php

Sends statistics to a statsd daemon over UDP

image

stevenscg/statsd-php

Sends statistics to a statsd daemon over UDP

  • Friday, September 22, 2017
  • by stevenscg
  • Repository
  • 1 Watchers
  • 5 Stars
  • 278 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 33 % Grown

The README.md

PHP Class for StatsD

Send statistics to the statsd daemon over UDP., (*1)

This class generally follows the official php-example from Etsy, but moves the configuration options into the main class with reasonable defaults. This should make incorporation into framework-based applications more straightforward., (*2)

Installation

Installation is via composer:, (*3)

composer require stevenscg/statsd-php

Configuration

The library can be configured by calling StatsD::config($params)., (*4)

$params is an array that supports the following keys:, (*5)

enabled - boolean - Set to false to disable UDP transmission (default: true), (*6)

prefix - string - Apply a global namespace to all metrics from this application, (*7)

host - string - Hostname or IP of your carbon/graphite server, (*8)

port - integer - StatsD port of your carbon/graphite server, (*9)

The library can also be configured via environment variables:, (*10)

STATSD_ENABLED - A boolean-like string (i.e. true, false, 1, 0), (*11)

STATSD_PREFIX - string, (*12)

STATSD_ADDR - string - Example: 127.0.0.1:8125, (*13)

StatsD Data Types and Class Methods

  • Counting - increment and decrement, (*14)

  • Timing - timing, (*15)

  • Sampling - supported via "sampleRate" parameter on increment and decrement, (*16)

  • Gauges - gauge, (*17)

  • Sets - set, (*18)

Usage

All methods are declared as static as they were in the upstream project., (*19)

Incrementing a counter is as simple as:, (*20)

StatsD::increment("api.requests");

Example: Tracking logins and failures, (*21)

function login() {
  ...
  if (!$this->Auth->login()) {
    StatsD::increment("logins.failed");
    return;
  }
  StatsD::increment("logins.ok");
  ...
}

License

MIT, (*22)

The Versions

22/09 2017

dev-master

9999999-dev

Sends statistics to a statsd daemon over UDP

  Sources   Download

MIT

The Requires

  • php ^7.0

 

22/09 2017

v1.0.0

1.0.0.0

Sends statistics to a statsd daemon over UDP

  Sources   Download

MIT

The Requires

  • php ^7.0