generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ekateiva/feature/wipe-storage-config
Add config setting if the collector registry should be wiped
- Loading branch information
Showing
9 changed files
with
91 additions
and
2 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
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,38 @@ | ||
<?php | ||
|
||
namespace Spatie\Prometheus\Tests\Actions; | ||
|
||
use Prometheus\CollectorRegistry; | ||
use Spatie\Prometheus\Actions\RenderCollectorsAction; | ||
|
||
it('does not wipe storage by default', closure: function () { | ||
$mock = $this->mock(CollectorRegistry::class, function (\Mockery\MockInterface $mock) { | ||
$mock | ||
->shouldReceive('getMetricFamilySamples') | ||
->once() | ||
->andReturn([]); | ||
|
||
$mock->shouldNotReceive('wipeStorage'); | ||
}); | ||
|
||
$subject = new RenderCollectorsAction($mock); | ||
$subject->execute([]); | ||
}); | ||
|
||
it('wipes storage if config is set', closure: function () { | ||
config()->set('prometheus.wipe_storage_after_rendering', true); | ||
|
||
$mock = $this->mock(CollectorRegistry::class, function (\Mockery\MockInterface $mock) { | ||
$mock | ||
->shouldReceive('getMetricFamilySamples') | ||
->once() | ||
->andReturn([]); | ||
|
||
$mock | ||
->shouldReceive('wipeStorage') | ||
->once(); | ||
}); | ||
|
||
$subject = new RenderCollectorsAction($mock); | ||
$subject->execute([]); | ||
}); |
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,17 @@ | ||
<?php | ||
|
||
namespace Spatie\Prometheus\Tests\TestSupport\Actions; | ||
|
||
use Spatie\Prometheus\Actions\RenderCollectorsAction; | ||
|
||
class TestRenderCollectorsAction extends RenderCollectorsAction | ||
{ | ||
protected function renderRegistry(): string | ||
{ | ||
$result = "# TestRenderCollectorsAction\n"; | ||
|
||
$result .= parent::renderRegistry(); | ||
|
||
return $result; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
..._/PrometheusMetricsControllerTest__it_can_replace_default_render_collectors_action__1.txt
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,4 @@ | ||
# TestRenderCollectorsAction | ||
# HELP app_my_gauge | ||
# TYPE app_my_gauge gauge | ||
app_my_gauge 123.45 |
File renamed without changes.
File renamed without changes.