summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-06-28 10:54:45 +0300
committerWolfy-J <[email protected]>2019-06-28 10:54:45 +0300
commiteae4561a593a3ed1f09bf16937c905c525f151aa (patch)
treee8ef1304a055a5cbb9751c9d0868724911cd0cf2 /src
parentbf540817226fae3833a81e08b6021789fdca8f2c (diff)
added metrics interface
Diffstat (limited to 'src')
-rw-r--r--src/Metrics.php2
-rw-r--r--src/MetricsInterface.php59
2 files changed, 60 insertions, 1 deletions
diff --git a/src/Metrics.php b/src/Metrics.php
index c07a1e7a..cf0cbc6c 100644
--- a/src/Metrics.php
+++ b/src/Metrics.php
@@ -16,7 +16,7 @@ use Spiral\RoadRunner\Exception\MetricException;
/**
* Application metrics.
*/
-final class Metrics
+final class Metrics implements MetricsInterface
{
/** @var RPC */
private $rpc;
diff --git a/src/MetricsInterface.php b/src/MetricsInterface.php
new file mode 100644
index 00000000..04756216
--- /dev/null
+++ b/src/MetricsInterface.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Spiral Framework.
+ *
+ * @license MIT
+ * @author Anton Titov (Wolfy-J)
+ */
+declare(strict_types=1);
+
+namespace Spiral\RoadRunner;
+
+use Spiral\RoadRunner\Exception\MetricException;
+
+interface MetricsInterface
+{
+ /**
+ * Add collector value. Fallback to appropriate method of related collector.
+ *
+ * @param string $collector
+ * @param float $value
+ * @param array $labels
+ *
+ * @throws MetricException
+ */
+ public function add(string $collector, float $value, array $labels = []);
+
+ /**
+ * Subtract the collector value, only for gauge collector.
+ *
+ * @param string $collector
+ * @param float $value
+ * @param array $labels
+ *
+ * @throws MetricException
+ */
+ public function sub(string $collector, float $value, array $labels = []);
+
+ /**
+ * Observe collector value, only for histogram and summary collectors.
+ *
+ * @param string $collector
+ * @param float $value
+ * @param array $labels
+ *
+ * @throws MetricException
+ */
+ public function observe(string $collector, float $value, array $labels = []);
+
+ /**
+ * Set collector value, only for gauge collector.
+ *
+ * @param string $collector
+ * @param float $value
+ * @param array $labels
+ *
+ * @throws MetricException
+ */
+ public function set(string $collector, float $value, array $labels = []);
+} \ No newline at end of file