From 788b1b7b3b89e6d45357dc3ff76db7bf4a575c4e Mon Sep 17 00:00:00 2001 From: devngl Date: Mon, 30 Sep 2019 16:50:16 +0200 Subject: [PATCH 1/2] Laravel 6 support Remove str and arr global helpers for Laravel 6 support. --- CHANGELOG | 3 +++ src/Providers/ElasticApmServiceProvider.php | 24 +++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b18555d..b983384 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2019-09-30 (6.0.1) devngl + * Laravel 6 support. + 2019-02-27 (5.7.6) mpetrunic * Fix Lumen compatibility issues diff --git a/src/Providers/ElasticApmServiceProvider.php b/src/Providers/ElasticApmServiceProvider.php index 561c7f5..6e62d1d 100644 --- a/src/Providers/ElasticApmServiceProvider.php +++ b/src/Providers/ElasticApmServiceProvider.php @@ -5,6 +5,8 @@ use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Collection; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Str; +use Illuminate\Support\Arr; use PhilKra\Agent; use PhilKra\ElasticApmLaravel\Apm\SpanCollection; use PhilKra\ElasticApmLaravel\Apm\Transaction; @@ -102,7 +104,7 @@ protected function getAppConfig(): array protected function stripVendorTraces(Collection $stackTrace): Collection { return collect($stackTrace)->filter(function ($trace) { - return !starts_with(array_get($trace, 'file'), [ + return !Str::startsWith((Arr::get($trace, 'file'), [ base_path() . '/vendor', ]); }); @@ -118,29 +120,29 @@ protected function getSourceCode(array $stackTrace): Collection return collect([]); } - if (empty(array_get($stackTrace, 'file'))) { + if (empty(Arr::get($stackTrace, 'file'))) { return collect([]); } - $fileLines = file(array_get($stackTrace, 'file')); + $fileLines = file(Arr::get($stackTrace, 'file')); return collect($fileLines)->filter(function ($code, $line) use ($stackTrace) { //file starts counting from 0, debug_stacktrace from 1 - $stackTraceLine = array_get($stackTrace, 'line') - 1; + $stackTraceLine = Arr::get($stackTrace, 'line') - 1; $lineStart = $stackTraceLine - 5; $lineStop = $stackTraceLine + 5; return $line >= $lineStart && $line <= $lineStop; })->groupBy(function ($code, $line) use ($stackTrace) { - if ($line < array_get($stackTrace, 'line')) { + if ($line < Arr::get($stackTrace, 'line')) { return 'pre_context'; } - if ($line == array_get($stackTrace, 'line')) { + if ($line == Arr::get($stackTrace, 'line')) { return 'context_line'; } - if ($line > array_get($stackTrace, 'line')) { + if ($line > Arr::get($stackTrace, 'line')) { return 'post_context'; } @@ -167,11 +169,11 @@ protected function listenForQueries() $sourceCode = $this->getSourceCode($trace); return [ - 'function' => array_get($trace, 'function') . array_get($trace, 'type') . array_get($trace, + 'function' => Arr::get($trace, 'function') . Arr::get($trace, 'type') . Arr::get($trace, 'function'), - 'abs_path' => array_get($trace, 'file'), - 'filename' => basename(array_get($trace, 'file')), - 'lineno' => array_get($trace, 'line', 0), + 'abs_path' => Arr::get($trace, 'file'), + 'filename' => basename(Arr::get($trace, 'file')), + 'lineno' => Arr::get($trace, 'line', 0), 'library_frame' => false, 'vars' => $vars ?? null, 'pre_context' => optional($sourceCode->get('pre_context'))->toArray(), From 881cae7fae79bbf87edd68ce2851396691b54284 Mon Sep 17 00:00:00 2001 From: devngl Date: Thu, 24 Oct 2019 23:32:01 +0200 Subject: [PATCH 2/2] Fix missing parenthesis --- src/Providers/ElasticApmServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/ElasticApmServiceProvider.php b/src/Providers/ElasticApmServiceProvider.php index 6e62d1d..45d4195 100644 --- a/src/Providers/ElasticApmServiceProvider.php +++ b/src/Providers/ElasticApmServiceProvider.php @@ -104,7 +104,7 @@ protected function getAppConfig(): array protected function stripVendorTraces(Collection $stackTrace): Collection { return collect($stackTrace)->filter(function ($trace) { - return !Str::startsWith((Arr::get($trace, 'file'), [ + return !Str::startsWith((Arr::get($trace, 'file')), [ base_path() . '/vendor', ]); });