mantas-done/laravel-apm
Composer 安装命令:
composer require mantas-done/laravel-apm
包简介
Application monitoring for Laravel
README 文档
README
Monitor requests/cron/queue execution times in production.
If you have a question:
- which pages have the slowest loading time?
- which page to optimize to reduce the server load?
Then this package is for you.
Installation
Supported Laravel versions: 8 ... 11+
composer require mantas-done/laravel-apm
Add route to your routes/web.php file (don't forget securing it from unwanted visitors)
Route::get('/apm', '\Done\LaravelAPM\ApmController@index')->name('apm');
Daily clear log files by adding scheduled job to App/Console/Kernel.php
$schedule->command('apm:clear')->daily();
Why?
Laravel APM can show pages that have the biggest impact on the server load. When you are developing the website, it is hard to tell which pages will receive the most pageviews and which will use the most resources: (per page resource usage) x (pageviews) = (this package stats)
Running this package in production has minimal impact on server load.
Technical
This package logs every user request to a file (storage/app/apm/apm-2020-01-01.txt). On average logging adds an overhead of less than 1 ms to each request (0.001 second).
Customizations
Copy /vendor/mantas-done/laravel-apm/config/apm.php file to /config/apm.php Then edit /config/apm.php values to your liking.
return [ 'enabled' => env('APM', true), 'per_page' => 100, // how many results per page to show 'sampling' => 1, // logs only part of requests. 1 - 100%, 0.1 - 10% of requests. 'slow' => 5, // log queries of pages that spent in SQL more than 10 seconds ];
Recommendations
If you are using Closures for scheduler, it is recommended to add ->setName('some-name');, to be able to distinguish different Closures in APM logs.
$schedule->call(function () { DB::table('recent_users')->delete(); })->daily()->setName('some-name'); // add ->setName()
mantas-done/laravel-apm 适用场景与选型建议
mantas-done/laravel-apm 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 56.19k 次下载、GitHub Stars 达 59, 最近一次更新时间为 2020 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mantas-done/laravel-apm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mantas-done/laravel-apm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 56.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 59
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2020-01-25