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

Commit 4947061

Browse files
authored
Merge pull request #68 from devngl/master
Laravel 6 support
2 parents a195c17 + 881cae7 commit 4947061

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2019-09-30 (6.0.1) devngl
2+
* Laravel 6 support.
3+
14
2019-02-27 (5.7.6) mpetrunic
25
* Fix Lumen compatibility issues
36

src/Providers/ElasticApmServiceProvider.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Database\Events\QueryExecuted;
66
use Illuminate\Support\Collection;
77
use Illuminate\Support\ServiceProvider;
8+
use Illuminate\Support\Str;
9+
use Illuminate\Support\Arr;
810
use PhilKra\Agent;
911
use PhilKra\ElasticApmLaravel\Apm\SpanCollection;
1012
use PhilKra\ElasticApmLaravel\Apm\Transaction;
@@ -102,7 +104,7 @@ protected function getAppConfig(): array
102104
protected function stripVendorTraces(Collection $stackTrace): Collection
103105
{
104106
return collect($stackTrace)->filter(function ($trace) {
105-
return !starts_with(array_get($trace, 'file'), [
107+
return !Str::startsWith((Arr::get($trace, 'file')), [
106108
base_path() . '/vendor',
107109
]);
108110
});
@@ -118,29 +120,29 @@ protected function getSourceCode(array $stackTrace): Collection
118120
return collect([]);
119121
}
120122

121-
if (empty(array_get($stackTrace, 'file'))) {
123+
if (empty(Arr::get($stackTrace, 'file'))) {
122124
return collect([]);
123125
}
124126

125-
$fileLines = file(array_get($stackTrace, 'file'));
127+
$fileLines = file(Arr::get($stackTrace, 'file'));
126128
return collect($fileLines)->filter(function ($code, $line) use ($stackTrace) {
127129
//file starts counting from 0, debug_stacktrace from 1
128-
$stackTraceLine = array_get($stackTrace, 'line') - 1;
130+
$stackTraceLine = Arr::get($stackTrace, 'line') - 1;
129131

130132
$lineStart = $stackTraceLine - 5;
131133
$lineStop = $stackTraceLine + 5;
132134

133135
return $line >= $lineStart && $line <= $lineStop;
134136
})->groupBy(function ($code, $line) use ($stackTrace) {
135-
if ($line < array_get($stackTrace, 'line')) {
137+
if ($line < Arr::get($stackTrace, 'line')) {
136138
return 'pre_context';
137139
}
138140

139-
if ($line == array_get($stackTrace, 'line')) {
141+
if ($line == Arr::get($stackTrace, 'line')) {
140142
return 'context_line';
141143
}
142144

143-
if ($line > array_get($stackTrace, 'line')) {
145+
if ($line > Arr::get($stackTrace, 'line')) {
144146
return 'post_context';
145147
}
146148

@@ -167,11 +169,11 @@ protected function listenForQueries()
167169
$sourceCode = $this->getSourceCode($trace);
168170

169171
return [
170-
'function' => array_get($trace, 'function') . array_get($trace, 'type') . array_get($trace,
172+
'function' => Arr::get($trace, 'function') . Arr::get($trace, 'type') . Arr::get($trace,
171173
'function'),
172-
'abs_path' => array_get($trace, 'file'),
173-
'filename' => basename(array_get($trace, 'file')),
174-
'lineno' => array_get($trace, 'line', 0),
174+
'abs_path' => Arr::get($trace, 'file'),
175+
'filename' => basename(Arr::get($trace, 'file')),
176+
'lineno' => Arr::get($trace, 'line', 0),
175177
'library_frame' => false,
176178
'vars' => $vars ?? null,
177179
'pre_context' => optional($sourceCode->get('pre_context'))->toArray(),

0 commit comments

Comments
 (0)