PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
423 stars 93 forks source link

[Gauge] decBy() should be able to receive a float value #60

Closed Swop closed 3 years ago

Swop commented 3 years ago

Hi,

Looks like the Prometheus\Gauge::decBy method is forcing the caller to send an int value. Here's the method signature:

/**
 * @param int $value
 * @param string[] $labels
 */
public function decBy(int $value, array $labels = []): void
{
    $this->incBy(-$value, $labels);
}

I think this a mistake, because set() and incBy() accept float values:

/**
 * @param double $value e.g. 123
 * @param string[] $labels e.g. ['status', 'opcode']
 */
public function set(float $value, array $labels = []): void {}

/**
 * @param int|float $value
 * @param string[] $labels
 */
public function incBy($value, array $labels = []): void {}

Am I missing something? I can create a PR if you want to fix the issue, but I wasn't sure if there was any kind of issues preventing the usage of a flat specifically here.

Thx

LKaemmerling commented 3 years ago

Hey @Swop,

this is already fixed in the master (https://github.com/PromPHP/prometheus_client_php/commit/8564d6b0ae6a19d40abfc360950341f0f2130ca8) but was not released yet.