Skip to content

Commit eae4561

Browse files
committed
added metrics interface
1 parent bf54081 commit eae4561

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/Metrics.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Application metrics.
1818
*/
19-
final class Metrics
19+
final class Metrics implements MetricsInterface
2020
{
2121
/** @var RPC */
2222
private $rpc;

src/MetricsInterface.php

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Spiral Framework.
4+
*
5+
* @license MIT
6+
* @author Anton Titov (Wolfy-J)
7+
*/
8+
declare(strict_types=1);
9+
10+
namespace Spiral\RoadRunner;
11+
12+
use Spiral\RoadRunner\Exception\MetricException;
13+
14+
interface MetricsInterface
15+
{
16+
/**
17+
* Add collector value. Fallback to appropriate method of related collector.
18+
*
19+
* @param string $collector
20+
* @param float $value
21+
* @param array $labels
22+
*
23+
* @throws MetricException
24+
*/
25+
public function add(string $collector, float $value, array $labels = []);
26+
27+
/**
28+
* Subtract the collector value, only for gauge collector.
29+
*
30+
* @param string $collector
31+
* @param float $value
32+
* @param array $labels
33+
*
34+
* @throws MetricException
35+
*/
36+
public function sub(string $collector, float $value, array $labels = []);
37+
38+
/**
39+
* Observe collector value, only for histogram and summary collectors.
40+
*
41+
* @param string $collector
42+
* @param float $value
43+
* @param array $labels
44+
*
45+
* @throws MetricException
46+
*/
47+
public function observe(string $collector, float $value, array $labels = []);
48+
49+
/**
50+
* Set collector value, only for gauge collector.
51+
*
52+
* @param string $collector
53+
* @param float $value
54+
* @param array $labels
55+
*
56+
* @throws MetricException
57+
*/
58+
public function set(string $collector, float $value, array $labels = []);
59+
}

0 commit comments

Comments
 (0)