Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow storage to be wiped after a render of data in metrics controller #22

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
* You can change the Middleware which is used for the IP whitelisting. You can add your own, like a token based authentication.
*/
"middleware" => \LKDevelopment\HorizonPrometheusExporter\Http\Middleware\IPWhitelistingMiddleware::class,

/**
* Allow storage to be wiped after a render of data in metrics controller
*/
"wipe_storage_after_render" => false,
];
4 changes: 4 additions & 0 deletions src/Http/Controller/HorizonPrometheusExporterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public function metrics()
$renderer = new RenderTextFormat();
$result = $renderer->render(ExporterRepository::getRegistry()->getMetricFamilySamples());

if(config('horizon-exporter.wipe_storage_after_render', false)) {
ExporterRepository::getRegistry()->wipeStorage();
}

return new Response($result, Response::HTTP_OK, ["Content-Type" => RenderTextFormat::MIME_TYPE]);
}
}