Skip to content

Commit

Permalink
Refactor to remove send_value [#2]
Browse files Browse the repository at this point in the history
  • Loading branch information
seejohnrun committed Dec 18, 2013
1 parent 1b2732f commit b6f05a5
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions libraries/statsd.php
Expand Up @@ -21,7 +21,7 @@ public function timing($key, $time, $rate = 1) {

// Record gauge
public function gauge($key, $gauge) {
$this->send_value("$key:$gauge|g");
$this->send("$key:$gauge|g");
}

// Time something
Expand All @@ -39,23 +39,13 @@ public function counting($key, $amount = 1, $rate = 1) {
}

// Send
private function send($value, $rate) {
private function send($value, $rate = NULL) {
$fp = fsockopen('udp://' . $this->host, $this->port, $errno, $errstr);
// Will show warning if not opened, and return false
if ($fp) {
fwrite($fp, "$value|@$rate");
fwrite($fp, $rate ? "$value|@$rate" : $value);
fclose($fp);
}
}

private function send_value($value) {
$fp = fsockopen('udp://' . $this->host, $this->port, $errno, $errstr);
// Will show warning if not opened, and return false
if ($fp) {
fwrite($fp, "$value");
fclose($fp);
}

}

}

0 comments on commit b6f05a5

Please sign in to comment.