mirror of
https://github.com/danog/better-prometheus.git
synced 2024-11-26 20:34:38 +01:00
Fix metric name for gauge, improve typehints
This commit is contained in:
parent
99f8d9435a
commit
f0eb82c76a
@ -5,6 +5,9 @@ $config = new class extends Amp\CodeStyle\Config {
|
|||||||
{
|
{
|
||||||
return array_merge(parent::getRules(), [
|
return array_merge(parent::getRules(), [
|
||||||
'void_return' => true,
|
'void_return' => true,
|
||||||
|
'phpdoc_to_param_type' => true,
|
||||||
|
'phpdoc_to_return_type' => true,
|
||||||
|
'phpdoc_to_property_type' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ final class BetterCollectorRegistry
|
|||||||
*
|
*
|
||||||
* @throws MetricsRegistrationException
|
* @throws MetricsRegistrationException
|
||||||
*/
|
*/
|
||||||
public function registerGauge(string $namespace, string $name, string $help, $labels = []): BetterGauge
|
public function registerGauge(string $namespace, string $name, string $help, array $labels = []): BetterGauge
|
||||||
{
|
{
|
||||||
$metricIdentifier = "$namespace:$name";
|
$metricIdentifier = "$namespace:$name";
|
||||||
if (isset($this->gauges[$metricIdentifier])) {
|
if (isset($this->gauges[$metricIdentifier])) {
|
||||||
@ -123,7 +123,7 @@ final class BetterCollectorRegistry
|
|||||||
*
|
*
|
||||||
* @throws MetricsRegistrationException
|
* @throws MetricsRegistrationException
|
||||||
*/
|
*/
|
||||||
public function getOrRegisterGauge(string $namespace, string $name, string $help, $labels = []): BetterGauge
|
public function getOrRegisterGauge(string $namespace, string $name, string $help, array $labels = []): BetterGauge
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$gauge = $this->getGauge($namespace, $name);
|
$gauge = $this->getGauge($namespace, $name);
|
||||||
@ -141,7 +141,7 @@ final class BetterCollectorRegistry
|
|||||||
*
|
*
|
||||||
* @throws MetricsRegistrationException
|
* @throws MetricsRegistrationException
|
||||||
*/
|
*/
|
||||||
public function registerCounter(string $namespace, string $name, string $help, $labels = []): BetterCounter
|
public function registerCounter(string $namespace, string $name, string $help, array $labels = []): BetterCounter
|
||||||
{
|
{
|
||||||
$metricIdentifier = "$namespace:$name";
|
$metricIdentifier = "$namespace:$name";
|
||||||
if (isset($this->counters[$metricIdentifier])) {
|
if (isset($this->counters[$metricIdentifier])) {
|
||||||
@ -178,7 +178,7 @@ final class BetterCollectorRegistry
|
|||||||
*
|
*
|
||||||
* @throws MetricsRegistrationException
|
* @throws MetricsRegistrationException
|
||||||
*/
|
*/
|
||||||
public function getOrRegisterCounter(string $namespace, string $name, string $help, $labels = []): BetterCounter
|
public function getOrRegisterCounter(string $namespace, string $name, string $help, array $labels = []): BetterCounter
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$counter = $this->getCounter($namespace, $name);
|
$counter = $this->getCounter($namespace, $name);
|
||||||
|
@ -36,7 +36,7 @@ final class BetterGauge extends BetterCollector
|
|||||||
$labels = $this->labels + $labels;
|
$labels = $this->labels + $labels;
|
||||||
$this->storageAdapter->updateGauge(
|
$this->storageAdapter->updateGauge(
|
||||||
[
|
[
|
||||||
'name' => $this->name,
|
'name' => $this->metricName,
|
||||||
'help' => $this->help,
|
'help' => $this->help,
|
||||||
'type' => self::TYPE,
|
'type' => self::TYPE,
|
||||||
'labelNames' => \array_keys($labels),
|
'labelNames' => \array_keys($labels),
|
||||||
|
@ -79,7 +79,7 @@ final class BetterHistogram extends BetterCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param double $value e.g. 123
|
* @param double|int $value e.g. 123
|
||||||
* @param array<string, string> $labels e.g. ['status' => '201', 'opcode' => 'SOME_OP']
|
* @param array<string, string> $labels e.g. ['status' => '201', 'opcode' => 'SOME_OP']
|
||||||
*/
|
*/
|
||||||
public function observe(float|int $value, array $labels = []): void
|
public function observe(float|int $value, array $labels = []): void
|
||||||
|
@ -93,10 +93,10 @@ final class BetterSummary extends BetterCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param double $value e.g. 123
|
* @param double|int $value e.g. 123
|
||||||
* @param array<string, string> $labels e.g. ['status' => '404', 'opcode' => 'SOME_OP']
|
* @param array<string, string> $labels e.g. ['status' => '404', 'opcode' => 'SOME_OP']
|
||||||
*/
|
*/
|
||||||
public function observe(float $value, array $labels = []): void
|
public function observe(float|int $value, array $labels = []): void
|
||||||
{
|
{
|
||||||
self::assertValidLabels($labels);
|
self::assertValidLabels($labels);
|
||||||
$labels = $this->labels + $labels;
|
$labels = $this->labels + $labels;
|
||||||
|
Loading…
Reference in New Issue
Block a user