2017 © Pedro Peláez
 

library metrics

Minimalistic library for collecting metrics during script execution

image

hgg/metrics

Minimalistic library for collecting metrics during script execution

  • Wednesday, March 4, 2015
  • by hglattergotz
  • Repository
  • 1 Watchers
  • 1 Stars
  • 104 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version License Code Climate, (*1)

Metrics is a container for keeping track of counters or any value for that matter and for tracking time. A common application would be to use it for a process that takes a few seconds for which various information should be collected and then logged., (*2)

The collected data can be emitted as an array or as a JSON string., (*3)

Installation

Using Composer:, (*4)

{
    "require": {
        "hgg/metrics": "*"
    }
}

Usage

Simple use case

<?php
$metrics = new Metrics(true);
$metrics->myCounter = 0;

while (1) {
    // Do some work
    ++$metrics->myCounter;
}

print_r($metrics->toArray());

The above constructs a Metrics object with time tracking turned on and a single counter that is incremented as a result of some process. The metrics container is then emitted as an array., (*5)

Initialize multiple counters more efficiently

<?php
$metrics = new Metrics(true);
$metrics->initMembers(array('counter1', 'counter2', 'counter3'), 0);

This initializes the named counters to 0 with a single call., (*6)

Output to Array

<?php
$arrayResult = $metrics->toArray();

Output to JSON

<?php
$json = $metrics->toJson();

Sample output (JSON)

{
  "counter1": 23,
  "counter2": 569,
  "counter3": 0,
  "elapsed-time": "00:00:24"
}

Note

For a more comprehensive solution take a look at beberlei/metrics., (*7)

The Versions

04/03 2015

dev-master

9999999-dev http://github.com/hglattergotz/metrics

Minimalistic library for collecting metrics during script execution

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

metrics

04/03 2015

v1.0

1.0.0.0 http://github.com/hglattergotz/metrics

Minimalistic library for collecting metrics during script execution

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

metrics

01/10 2013

v0.0.1

0.0.1.0 http://github.com/hglattergotz/metrics

Minimalistic library for collecting metrics during script execution

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

metrics