-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented remove method for metric
- Loading branch information
Showing
10 changed files
with
112 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
final class Gauge extends Metric | ||
{ | ||
protected const TYPE = 'gauge'; | ||
|
||
private array $buffer = []; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\PHPStreamServer\BundledPlugin\Metrics\Internal; | ||
|
||
use Prometheus\Storage\InMemory as PrometheusInMemory; | ||
|
||
final class InMemory extends PrometheusInMemory | ||
{ | ||
public function remove(string $type, string $namespace, string $name, array $labels): void | ||
{ | ||
$data = [ | ||
'type' => $type, | ||
'name' => $namespace . '_' . $name, | ||
'labelValues' => $labels, | ||
]; | ||
|
||
$metaKey = $this->metaKey($data); | ||
$valueKey = $this->valueKey($data); | ||
|
||
if ($type === 'counter') { | ||
unset($this->counters[$metaKey]['samples'][$valueKey]); | ||
} elseif($type === 'gauge') { | ||
unset($this->gauges[$metaKey]['samples'][$valueKey]); | ||
} elseif($type === 'histogram') { | ||
unset($this->histograms[$metaKey]['samples'][$valueKey]); | ||
} elseif($type === 'summary') { | ||
unset($this->summaries[$metaKey]['samples'][$valueKey]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/BundledPlugin/Metrics/Internal/Message/RemoveMetricMessage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\PHPStreamServer\BundledPlugin\Metrics\Internal\Message; | ||
|
||
use Luzrain\PHPStreamServer\MessageBus\MessageInterface; | ||
|
||
/** | ||
* @implements MessageInterface<null> | ||
*/ | ||
final readonly class RemoveMetricMessage implements MessageInterface | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $namespace, | ||
public string $name, | ||
public array $labels, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters