0to10/observability-php
Composer 安装命令:
composer require 0to10/observability-php
包简介
Library to simplify customising observability integrations in PHP projects.
README 文档
README
Observability library for PHP
This package aims to make it easier to monitor your application by generalising frequently used methods to customise how you instrument your code.
Getting started
Getting started is usually easy: just follow the instructions below.
Installation
Use Composer to install this library into your project:
composer require 0to10/observability-php
Basic usage
Below is the high-level documentation of how to work with this library.
<?php require 'vendor/autoload.php'; use ZERO2TEN\Observability\Client; use ZERO2TEN\Observability\APM\Agent\NullAgent; $nullAgent = new NullAgent(); $client = new Client($nullAgent); try { // Some application code } catch (\Exception $e) { $client->transaction()->recordException($e); } // Add a parameter to the current transaction $client->transaction()->addParameter('user_id', 50);
Working with transactions
A Transaction is a logical unit of work in a software application. This might be handling a request and sending a response (in a Web transaction), executing a script that handles some piece of business logic, etc.
This library exposes a helper class via the transaction() method of a
Client instance that can be used to customise monitoring of a transaction.
The methods of the returned class are documented in TransactionInterface.
Real-user monitoring
Real-user monitoring (RUM) may be customised by calling the browser() method
of a Client instance.
Automatic instrumentation (e.g. automatic injection of browser scripts in the header and footer of a page) may be disabled using the following method:
<?php require 'vendor/autoload.php'; use ZERO2TEN\Observability\Client; use ZERO2TEN\Observability\APM\Agent\NullAgent; $client = new Client(new NullAgent); $browser = $client->browser(); $browser->disableAutomaticTimingScripts();
Note that this must be done before any output is sent to the browser, and that it's more stable to disable RUM as part of your PHP configuration (if available).
<?php require 'vendor/autoload.php'; use ZERO2TEN\Observability\Client; use ZERO2TEN\Observability\APM\Agent\NullAgent; $client = new Client(new NullAgent); $browser = $client->browser(); // Returns the header RUM script (Javascript) as string without <script> tags $browser->getHeaderScript(); // Returns the footer RUM script (Javascript) as string without <script> tags $browser->getFooterScript();
Legacy usage
Library versions up to 2.0.0 continue to support using the Client class located
in the Nouve\APM namespace. Please do not use this method for new projects.
<?php require 'vendor/autoload.php'; use Nouve\APM\Agents\NullAgent; use Nouve\APM\Client; // Creates a Client instance with the first supported AgentInterface // implementation configured in the Client class $client = Client::create(); // Alternatively, you can instantiate a Client instance yourself $nullAgent = new NullAgent(); $client = new Client($nullAgent);
Usage notes
It is important to understand that this library exposes generic methods to adjust observability within projects. Depending on the capabilities of the used observability tool, methods may not have the desired outcome. Always make sure that you understand the impact of customising your setup before publishing this into any production environment.
0to10/observability-php 适用场景与选型建议
0to10/observability-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.36k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「monitoring」 「Metrics」 「apm」 「telemetry」 「observability」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 0to10/observability-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 0to10/observability-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 0to10/observability-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony bundle for chameleon-system/sanitycheck
Elastic APM bundle
SoftWax Health Check Bundle for Symfony framework
1Pilot client for Symfony
Statsd (Object Oriented) client library for PHP
Wizaplace Elastic APM Wrapper
统计信息
- 总下载量: 20.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-14