Luciano Andrade преди 7 години
родител
ревизия
565e502b01
променени са 1 файла, в които са добавени 15 реда и са изтрити 16 реда
  1. 15 16
      Services/StatsD.php

+ 15 - 16
Services/StatsD.php

@@ -9,12 +9,11 @@ class StatsD
 {
     public function __construct($config = false){
            $this->config = array();
-           if(false === $config){
-               $this->config["enabled"] = true;
-               $this->config["host"] = "127.0.0.1";
-               $this->config["port"] = 8125;
-           }else{
-               $this->confg = $config;
+           $this->config["enabled"] = true;
+           $this->config["host"] = "127.0.0.1";
+           $this->config["port"] = 8125;
+           if(is_array($config)){
+               $this->config = $config;
                $this->config["enabled"] = true;
            }
     }
@@ -25,9 +24,9 @@ class StatsD
      * @param string|array $stats The metric(s) to set.
      * @param float $time The elapsed time (ms) to log
      */
-    public static function timing($stats, $time)
+    public function timing($stats, $time)
     {
-        StatsD::updateStats($stats, $time, 1, 'ms');
+        return $this->updateStats($stats, $time, 1, 'ms');
     }
 
     /**
@@ -36,9 +35,9 @@ class StatsD
      * @param string|array $stats The metric(s) to set.
      * @param float $value The value for the stats.
      */
-    public static function gauge($stats, $value)
+    public function gauge($stats, $value)
     {
-        StatsD::updateStats($stats, $value, 1, 'g');
+        return $this->updateStats($stats, $value, 1, 'g');
     }
 
     /**
@@ -55,9 +54,9 @@ class StatsD
      * @param string|array $stats The metric(s) to set.
      * @param float $value The value for the stats.
      */
-    public static function set($stats, $value)
+    public function set($stats, $value)
     {
-        StatsD::updateStats($stats, $value, 1, 's');
+        return $this->updateStats($stats, $value, 1, 's');
     }
 
     /**
@@ -70,7 +69,7 @@ class StatsD
      */
     public static function increment($stats, $sampleRate = 1)
     {
-        StatsD::updateStats($stats, 1, $sampleRate, 'c');
+        return $this->updateStats($stats, 1, $sampleRate, 'c');
     }
 
     /**
@@ -83,7 +82,7 @@ class StatsD
      */
     public static function decrement($stats, $sampleRate = 1)
     {
-        StatsD::updateStats($stats, -1, $sampleRate, 'c');
+        $this->updateStats($stats, -1, $sampleRate, 'c');
     }
 
     /**
@@ -106,7 +105,7 @@ class StatsD
             $data[$stat] = "$delta|$metric";
         }
 
-        StatsD::send($data, $sampleRate);
+        $this->send($data, $sampleRate);
     }
 
     /**
@@ -117,7 +116,7 @@ class StatsD
      * 
      * @return void
      */
-    public static function send($data, $sampleRate = 1)
+    public function send($data, $sampleRate = 1)
     {
         $config = $this->config;
         if (!$config["enabled"]){