gluedev/laravel-stackdriver
Composer 安装命令:
composer require gluedev/laravel-stackdriver
包简介
Enables logging, tracing and error reporting to Google Stackdriver for the Laravel framework
README 文档
README
Enables logging, tracing and error reporting to Google Stackdriver for Laravel. Requires PHP >= 7.1
Screenshots
Installation
Via Composer
composer require gluedev/laravel-stackdriver
And publish the config file
php artisan vendor:publish --provider="GlueDev\Laravel\Stackdriver\StackdriverServiceProvider"
Usage
First, you will want to open config/stackdriver.php. Here you can see that you have four environment settings available to enable and disable the different features of this package:
STACKDRIVER_ENABLED=false STACKDRIVER_LOGGING_ENABLED=true STACKDRIVER_TRACING_ENABLED=true STACKDRIVER_ERROR_REPORTING_ENABLED=true
The first variable listed has priority over the others.
Authentication
At the time of writing, Google prefers you to authenticate using a service account. It will throw a warning otherwise, which you can (but probably should not) disable by setting SUPPRESS_GCLOUD_CREDS_WARNING=true
Create a service account with the appropriate roles attached to it and add it to your project. Make sure not to commit this file to git, because of security. You can then specify the path to the service account JSON file in the keyFilePath or in the STACKDRIVER_KEY_FILE_PATH environment variable.
Tracing
Tracing requires the OpenCencus module to be installed. As we use docker, this is how we install it:
RUN pecl install opencensus-alpha RUN docker-php-ext-enable opencensus
Please note: If you run in to an opencensus.so: undefined symbol: ZVAL_DESTRUCTOR error after installing the OpenCencus extension, it is recommended to build the extension yourself, following these instructions.
Logging
Other than changing the values in the config file, logging needs no additional setup.
Error reporting
Error reporting requires you to add the following to the report function in your Exceptions/handler.php
use GlueDev\Laravel\Stackdriver\StackdriverExceptionHandler; /** * Report or log an exception. * * @param \Exception $exception * @return void */ public function report(Exception $exception) { StackdriverExceptionHandler::report($exception); parent::report($exception); }
Log in to Google Cloud Console and you should start seeing logs, traces and errors appear.
Batch daemon
Google also provides a batch daemon, which is recommended to use. We have seen issues with slow time to first byte on requests when the daemon was not running. The easiest way to run the daemon is using Supervisor. An example configuration for you to edit:
[program:google-batch-daemon] command = php -d auto_prepend_file='' -d disable_functions='' /app/vendor/bin/google-cloud-batch daemon process_name = %(program_name)s user = application numprocs = 1 autostart = true autorestart = true stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0
You also need to tell Google that the daemon is running. This is done by setting the IS_BATCH_DAEMON_RUNNING=true.
And that is it!
Change log
Please see the changelog for more information on what has changed recently.
Credits
License
Please see the license file for more information.
gluedev/laravel-stackdriver 适用场景与选型建议
gluedev/laravel-stackdriver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.8k 次下载、GitHub Stars 达 47, 最近一次更新时间为 2018 年 11 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「google」 「laravel」 「error reporting」 「tracing」 「stackdriver」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gluedev/laravel-stackdriver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gluedev/laravel-stackdriver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gluedev/laravel-stackdriver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
Audit changes of your Eloquent models in Laravel/Lumen
统计信息
- 总下载量: 65.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-27

