This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrometheusStatistic.php
98 lines (83 loc) · 1.84 KB
/
PrometheusStatistic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
declare(strict_types=1);
namespace libPrometheus;
use JetBrains\PhpStorm\Pure;
use Threaded;
class PrometheusStatistic extends Threaded
{
public const TYPE_COUNTER = "counter";
public const TYPE_GAUGE = "gauge";
private int $value;
private string $identifier;
private string $help;
private string $type;
public function __construct(int $value, string $identifier, string $help, string $type)
{
$this->value = $value;
$this->identifier = $identifier;
$this->help = $help;
$this->type = $type;
}
public function toReturnableWebString(): string
{
return "# HELP " . $this->identifier . " " . $this->getHelp() . PHP_EOL
. "# TYPE " . $this->identifier . " " . $this->type . PHP_EOL
. $this->identifier . " " . $this->value;
}
/**
* @return string
*/
public function getHelp(): string
{
return $this->help;
}
/**
* @return string
*/
public function getIdentifier(): string
{
return $this->identifier;
}
/**
* @return int
*/
public function getValue(): int
{
return $this->value;
}
/**
* @param string $help
*/
public function setHelp(string $help): void
{
$this->help = $help;
}
/**
* @param string $identifier
*/
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @param int $value
*/
public function setValue(int $value): void
{
$this->value = $value;
}
}