Skip to content

Commit

Permalink
Merge pull request #3 from smortexa/master
Browse files Browse the repository at this point in the history
[fix] Exclude `/exporter/group/octane-metrics` route from being tracked
  • Loading branch information
rennokki authored Oct 7, 2021
2 parents 875f149 + bd99285 commit ba3e6fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ return [

This package is pretty straightforward. Upon installing it, it will register the route at `/exporter/group/octane-metrics` and you can point Prometheus towards it for scraping.

```yaml
scrape_configs:
- job_name: 'octane'
metrics_path: '/exporter/group/octane-metrics'
scrape_interval: 5
static_configs:
- targets: ['localhost:8000']
labels:
app: 'my-octane-app'
```
Please keep in mind that the metrics are calculated by-process. Point your Prometheus scraper to all instances that run the Octane start command.
```
Expand Down
5 changes: 5 additions & 0 deletions src/Listeners/TrackTerminatedRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class TrackTerminatedRequests
*/
public function handle(RequestTerminated $event): void
{
// Do not track requests for the metrics endpoints.
if ($event->request->routeIs('laravel-exporter.metrics')) {
return;
}

$this->incrementRequestsCount();

$statusCode = $event->response->getStatusCode();
Expand Down
6 changes: 6 additions & 0 deletions tests/MetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function test_octane_requests()
Request::create('/test2', 'GET'),
Request::create('/test3', 'GET'),
Request::create('/exporter/group/octane-metrics', 'GET'),
Request::create('/exporter/group/octane-metrics', 'GET'),
]);

$app->bind('test-binding', function ($app) {
Expand Down Expand Up @@ -126,6 +127,11 @@ public function test_octane_requests()
'status="4xx_count"} 1',
$client->responses[3]->original
);

$this->assertStringContainsString(
'status="total_count"} 3',
$client->responses[4]->original
);
}

public function test_octane_workers()
Expand Down

0 comments on commit ba3e6fa

Please sign in to comment.