diff --git a/doc/zh/metric.md b/doc/zh/metric.md index b23dc661d..351c0b054 100644 --- a/doc/zh/metric.md +++ b/doc/zh/metric.md @@ -189,7 +189,7 @@ interface HistogramInterface { public function with(string ...$labelValues): self; - public function put(float $delta); + public function put(float $sample); } ``` diff --git a/src/metric/src/Adapter/Prometheus/Histogram.php b/src/metric/src/Adapter/Prometheus/Histogram.php index 0950f515b..749ec1d4f 100644 --- a/src/metric/src/Adapter/Prometheus/Histogram.php +++ b/src/metric/src/Adapter/Prometheus/Histogram.php @@ -44,8 +44,8 @@ class Histogram implements HistogramInterface return $this; } - public function put(float $value): void + public function put(float $sample): void { - $this->histogram->observe($value, $this->labelValues); + $this->histogram->observe($sample, $this->labelValues); } } diff --git a/src/metric/src/Adapter/RemoteProxy/Histogram.php b/src/metric/src/Adapter/RemoteProxy/Histogram.php index 52dd85beb..5a42d1d5e 100644 --- a/src/metric/src/Adapter/RemoteProxy/Histogram.php +++ b/src/metric/src/Adapter/RemoteProxy/Histogram.php @@ -40,7 +40,7 @@ class Histogram implements HistogramInterface /** * @var float */ - public $value; + public $sample; public function __construct(string $name, array $labelNames) { @@ -54,9 +54,9 @@ class Histogram implements HistogramInterface return $this; } - public function put(float $value): void + public function put(float $sample): void { - $this->value = $value; + $this->sample = $sample; $process = ProcessCollector::get(static::TARGET_PROCESS_NAME)[0]; $process->write(serialize($this)); } diff --git a/src/metric/src/Adapter/StatsD/Histogram.php b/src/metric/src/Adapter/StatsD/Histogram.php index 279483495..ec1b75205 100644 --- a/src/metric/src/Adapter/StatsD/Histogram.php +++ b/src/metric/src/Adapter/StatsD/Histogram.php @@ -56,8 +56,8 @@ class Histogram implements HistogramInterface return $this; } - public function put(float $delta): void + public function put(float $sample): void { - $this->client->timing($this->name, $delta, $this->sampleRate, array_combine($this->labelNames, $this->labelValues)); + $this->client->timing($this->name, $sample, $this->sampleRate, array_combine($this->labelNames, $this->labelValues)); } } diff --git a/src/metric/src/Contract/HistogramInterface.php b/src/metric/src/Contract/HistogramInterface.php index ce2aeb1c8..5c36aa61b 100644 --- a/src/metric/src/Contract/HistogramInterface.php +++ b/src/metric/src/Contract/HistogramInterface.php @@ -22,5 +22,5 @@ interface HistogramInterface { public function with(string ...$labelValues): self; - public function put(float $delta): void; + public function put(float $sample): void; } diff --git a/src/metric/src/Listener/OnPipeMessage.php b/src/metric/src/Listener/OnPipeMessage.php index 01b588ca7..ed25b7621 100644 --- a/src/metric/src/Listener/OnPipeMessage.php +++ b/src/metric/src/Listener/OnPipeMessage.php @@ -63,7 +63,7 @@ class OnPipeMessage implements ListenerInterface break; case $inner instanceof Histogram: $histogram = $this->factory->makeHistogram($inner->name, $inner->labelNames); - $histogram->with(...$inner->labelValues)->put($inner->value); + $histogram->with(...$inner->labelValues)->put($inner->sample); break; default: // Nothing to do