put value/delta renamed to put sample

This commit is contained in:
reasno 2019-10-29 08:10:58 +08:00
parent fe6f7c5bc6
commit 3252c8299e
6 changed files with 10 additions and 10 deletions

View File

@ -189,7 +189,7 @@ interface HistogramInterface
{
public function with(string ...$labelValues): self;
public function put(float $delta);
public function put(float $sample);
}
```

View File

@ -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);
}
}

View File

@ -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));
}

View File

@ -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));
}
}

View File

@ -22,5 +22,5 @@ interface HistogramInterface
{
public function with(string ...$labelValues): self;
public function put(float $delta): void;
public function put(float $sample): void;
}

View File

@ -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