Skip to content

Commit

Permalink
Initial implementation of distribution support
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarciauskas committed Aug 7, 2018
1 parent 0c4060a commit 5b89937
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$statsd = new DogStatsd();
$statsd->increment('web.page_views');
$statsd->histogram('web.render_time', 15);
$statsd->distribution('web.render_time', 15);
$statsd->set('web.uniques', 3 /* a unique user id */);
$statsd->service_check('my.service.check', DogStatsd::CRITICAL);
$statsd->event("Event title", array("text"=>"Event text"));
Expand Down
1 change: 1 addition & 0 deletions examples/expandedExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$startTime1 = microtime(true);
$statsd->increment('web.page_views');
$statsd->histogram('web.render_time', 15);
$statsd->distribution('web.render_time', 15);
$statsd->set('web.uniques', 3); // A unique user id

runFunction($statsd);
Expand Down
13 changes: 13 additions & 0 deletions src/DogStatsd.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ public function histogram($stat, $value, $sampleRate = 1.0, $tags = null)
$this->send(array($stat => "$value|h"), $sampleRate, $tags);
}

/**
* Distribution
*
* @param string $stat The metric
* @param float $value The value
* @param float $sampleRate the rate (0-1) for sampling.
* @param array|string $tags Key Value array of Tag => Value, or single tag as string
**/
public function distribution($stat, $value, $sampleRate = 1.0, $tags = null)
{
$this->send(array($stat => "$value|d"), $sampleRate, $tags);
}

/**
* Set
*
Expand Down

0 comments on commit 5b89937

Please sign in to comment.