Skip to content

Commit d61d03e

Browse files
committed
refactor(collectors): Remove redundant memory usage calculation
- Eliminate memory usage calculation from ApplicationCollector - Incorporate memory usage calculation into RequestBasicCollector - Enhance consistency in memory reporting across collectors
1 parent 2fde561 commit d61d03e

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/Collectors/ApplicationCollector.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Guanguans\LaravelExceptionNotify\Collectors;
1515

16-
use Guanguans\LaravelExceptionNotify\Support\Utils;
1716
use Illuminate\Container\Container;
1817
use Illuminate\Support\Carbon;
1918

@@ -33,9 +32,7 @@ public function collect(): array
3332
'php version' => \PHP_VERSION,
3433
'environment' => $this->container->environment(),
3534
'debug' => $this->container->hasDebugModeEnabled(),
36-
'locale' => $this->container->getLocale(),
3735
'in console' => $this->container->runningInConsole(),
38-
'memory' => Utils::humanBytes(memory_get_peak_usage(true)),
3936
];
4037
}
4138
}

src/Collectors/RequestBasicCollector.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public function __construct(private Request $request) {}
2323
public function collect(): array
2424
{
2525
return [
26-
'path' => $this->request->decodedPath(),
26+
'url' => $this->request->url(),
2727
'ip' => $this->request->ip(),
2828
'method' => $this->request->method(),
2929
'controller action' => $this->request->route()?->getActionName(),
30+
'memory' => Utils::humanBytes(memory_get_peak_usage(true)),
3031
'duration' => blank($startTime = \defined('LARAVEL_START') ? LARAVEL_START : $this->request->server('REQUEST_TIME_FLOAT'))
3132
? 'Unknown'
3233
: Utils::humanMilliseconds((microtime(true) - $startTime) * 1000),

tests/__snapshots__/FeatureTest__it_can_proactive_report_exception__1.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{
22
"Application": {
3-
"time": "2025-03-22 08:20:39",
3+
"time": "2025-03-23 06:28:50",
44
"name": "Laravel",
55
"version": "9.52.20",
66
"php version": "8.0.30",
77
"environment": "testing",
88
"debug": false,
9-
"locale": "en",
10-
"in console": true,
11-
"memory": "52.50 MB"
9+
"in console": true
1210
},
1311
"Chore": {},
1412
"Exception Basic": {
@@ -37,11 +35,12 @@
3735
"49": "#49 {main}"
3836
},
3937
"Request Basic": {
40-
"path": "proactive-report-exception",
38+
"url": "http:\/\/localhost\/proactive-report-exception",
4139
"ip": "127.0.0.1",
4240
"method": "POST",
4341
"controller action": "Closure",
44-
"duration": "15.69 ms"
42+
"memory": "50.50 MB",
43+
"duration": "13.81 ms"
4544
},
4645
"Request File": {
4746
"file": {

0 commit comments

Comments
 (0)