Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Development #32

Merged
merged 5 commits into from
Feb 13, 2019
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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,30 @@ use ElasticApm;

### Lumen
not tested yet.

## Agent Configuration

### Laravel

The following environment variables are supported in the default configuration:

| Variable | Description |
|------------------|-------------|
|APM_ACTIVE | `true` or `false` defaults to `true`. If `false`, the agent will collect, but not send, transaction data. |
|APM_APPNAME | Name of the app as it will appear in APM. |
|APM_APPVERSION | Version of the app as it will appear in APM. |
|APM_SERVERURL | URL to the APM intake service. |
|APM_SECRETTOKEN | Secret token, if required. |
|APM_APIVERSION | APM API version, defaults to `v1` (only v1 is supported at this time). |
|APM_USEROUTEURI | `true` or `false` defaults to `false`. The default behavior is to record the URL as sent in the request. This can result in excessive unique entries in APM. Set to `true` to have the agent use the route URL instead. |
|APM_QUERYLOG | `true` or `false` defaults to 'true'. Set to `false` to completely disable query logging, or to `auto` if you would like to use the threshold feature. |
|APM_THRESHOLD | Query threshold in milliseconds, defaults to `200`. If a query takes longer then 200ms, we enable the query log. Make sure you set `APM_QUERYLOG=auto`. |

You may also publish the `elastic-apm.php` configuration file to change additional settings:

```bash
php artisan vendor:publish --tag=config --provider="PhilKra\ElasticApmLaravel\Providers\ElasticApmService
Provider"
```

Once published, open the `config/elastic-apm.php` file and review the various settings.
5 changes: 4 additions & 1 deletion config/elastic-apm.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
//'env' => []
],

// GuzzleHttp\Client options (http://docs.guzzlephp.org/en/stable/request-options.html#request-options)
'httpClient' => [],

'server' => [
// The apm-server to connect to
'serverUrl' => env('APM_SERVERURL', 'http://127.0.0.1:8200'),
Expand All @@ -35,7 +38,7 @@
'transactions' => [

//This option will bundle transaction on the route name without variables
'use_route_uri' => env('APM_USE_ROUTE_URI', false),
'use_route_uri' => env('APM_USEROUTEURI', false),

],

Expand Down
8 changes: 7 additions & 1 deletion src/Middleware/RecordTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PhilKra\ElasticApmLaravel\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;
use PhilKra\Agent;

class RecordTransaction
Expand Down Expand Up @@ -76,7 +77,12 @@ public function handle($request, Closure $next)
*/
public function terminate($request, $response)
{
$this->agent->send();
try {
$this->agent->send();
}
catch(\Throwable $t) {
Log::error($t);
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Providers/ElasticApmServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public function register()
'framework' => 'Laravel',
'frameworkVersion' => app()->version(),
],
['active' => config('elastic-apm.active')],
[
'active' => config('elastic-apm.active'),
'httpClient' => config('elastic-apm.httpClient'),
],
$this->getAppConfig(),
config('elastic-apm.env'),
config('elastic-apm.server')
Expand Down