scoutapp/scout-apm-lumen

Scout 应用性能监控代理 - https://scoutapm.com

1.4.0 2023-12-07 14:31 UTC

This package is auto-updated.

Last update: 2024-09-07 16:13:53 UTC


README

使用Scout的PHP APM代理监控PHP Lumen应用程序的性能。在安装并配置scout-apm包后,将收集详细的性能指标和事务跟踪。

要求

  • PHP版本:PHP 7.2+(推荐使用PHP 8.3+)
  • Lumen版本:5.5+

快速开始

需要Scout账户。请注册Scout账户

composer require scoutapp/scout-apm-lumen

ScoutApmServiceProvider添加到您的bootstrap/app.php文件中,例如

// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(\Scoutapm\Laravel\Providers\ScoutApmServiceProvider::class);

将四个中间件添加到您的bootstrap/app.php文件中,例如

$app->middleware([
    // These three should be as early as possible in the pipeline:
    \Scoutapm\Laravel\Middleware\SendRequestToScout::class,
    \Scoutapm\Laravel\Middleware\IgnoredEndpoints::class,
    \Scoutapm\Laravel\Middleware\MiddlewareInstrument::class,
    
    // The rest of your middleware should go here
    // ...
    
    // This middleware should come last
    \Scoutapm\Laravel\Middleware\ActionInstrument::class,
]);

如果您想使用\Scoutapm\Laravel\Facades\ScoutApm外观,您应该启用外观,如果尚未启用,请在bootstrap/app.php中取消注释withFacades()调用

$app->withFacades();

配置

在您的.env文件中,确保设置了几个配置变量

SCOUT_KEY=ABC0ZABCDEFGHIJKLMNOP
SCOUT_NAME="My Lumen App"
SCOUT_MONITOR=true

您的密钥可以在Scout组织设置页面中找到。

日志详细程度

一旦您设置好Scout并且一切正常,您可以减少库的日志系统的详细程度。库默认情况下非常嘈杂,这让我们在出现问题时有更多的信息来支持客户。然而,如果一切按预期工作,可以通过将配置密钥log_level设置为更高的Psr\Log\LogLevel来减少这些日志。例如,如果您使用.env配置

SCOUT_LOG_LEVEL=error

\Psr\Log\LogLevel中定义的任何常量都是此配置选项的可用值。

文档

有关完整安装和故障排除文档,请访问我们的帮助站点

支持

请通过support@scoutapm.com联系我们或在此仓库中创建一个问题。