定制 simple-as-fuck/laravel-performance-log 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simple-as-fuck/laravel-performance-log

最新稳定版本:0.5.0

Composer 安装命令:

composer require simple-as-fuck/laravel-performance-log

包简介

Laravel service for logging slow parts of application.

README 文档

README

Laravel service for logging slow parts of application.

Installation

composer require simple-as-fuck/php-performance-log

Configuration

php artisan vendor:publish --tag performance-log-config

Support

If any PHP platform requirements in composer.json ends with security support, consider package version as unsupported except last version.

PHP supported versions.

Http middleware usage

For http request time logging you must register SimpleAsFuck\PerformanceLog\Middleware\LaravelMiddleware. Look at laravel documentation how to use laravel middlewares.

Recommended usage is register middleware as global on first position and all of your request will be measured.

If you want register middleware on route group you should configure middleware priority and put SimpleAsFuck\PerformanceLog\Middleware\LaravelMiddleware on first position.

Thresholds overwrite

Sql

If you know than some sql is slow, and you are fine with that you can overwrite 'performance_log.database.slow_query_threshold' or 'performance_log.database.slow_transaction_threshold' by setting a temporary threshold in PerformanceLogConfig.

/** @var \SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig $config */
$config = app()->make(\SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig::class);

$sqlThreshold = $config->setSlowSqlQueryThreshold(null);
$transactionThreshold = $config->setSlowDbTransactionThreshold(null);

// run some slow queries without annoying performance log

$sqlThreshold->restore();
$transactionThreshold->restore();

Http

If you know that some concrete controller action is slow or should be extra fast, you can overwrite 'performance_log.http.slow_request_threshold' by setting a temporary threshold. The temporary threshold can be set only once per request and live until request ends.

/** @var \SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig $config */
$config = app()->make(\SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig::class);

$config->setSlowRequestThreshold(null);

// run some extra slow logic without annoying performance log

// no need for threshold restoring, performance middleware will handle it

Console

If you want to overwrite 'performance_log.console.slow_command_threshold', you can do it by setting a temporary threshold. The temporary threshold can be set only once per command run and live until command ends.

/** @var \SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig $config */
$config = app()->make(\SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig::class);

$config->setSlowCommandThreshold(60); // one minute

// no need for threshold restoring, performance listener will handle it

Job

If you want to overwrite 'performance_log.queue.slow_job_threshold', you can set a temporary threshold. The temporary threshold can be set anywhere in job run and live until a job ends.

/** @var \SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig $config */
$config = app()->make(\SimpleAsFuck\PerformanceLog\Service\PerformanceLogConfig::class);

$config->setSlowJobThreshold(10000); // 10 seconds

// no need for threshold restoring, performance listener will handle it

Usage with monitoring

Is recommended send performance warning logs into your monitoring system, so you know what is slow.

For simple monitoring is laravel sentry integration. Sentry integration can collect information about request or command with stacktrace, this can make finding slow query much easier.

统计信息

  • 总下载量: 123.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固