承接 fido/php-xray 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

fido/php-xray

Composer 安装命令:

composer require fido/php-xray

包简介

PHP instrumentation library for AWS X-Ray

README 文档

README

Build Status PHP Version Coverage Status

An instrumentation library for AWS X-Ray for PHP 8.x LICENSE CHANGELOG

Installation

To use this package, use Composer:

  • From CLI: composer require fido-id/php-xray
  • Or, directly in your composer.json:
{
  "require": {
    "fido/php-xray": "^0.2.1",
  }
}

Usage

Start a new trace, create a new segment, add any desired subsegment, close it and submit it.

eg.

$client = new \GuzzleHttp\Client();

$trace = new Trace(name: 'a_new_trace');

$httpSegment = new HttpSegment(
    name: \uniqid("http_segment_post_500_"),
    url: 'ifconfig.me/ua',
    method: 'GET'
);

$httpSegment
    ->closeWithPsrResponse($client->get('ifconfig.me/ua'))

$trace->addSubsegment($httpSegment);

$trace->end()->submit(new DaemonSegmentSubmitter());

Closing segments is mandatory before submitting, closing a parent segment will automatically close any child segment.

Available built-in segments

  • Segment: Default simple segment extended by any other segment in this list.
  • RemoteSegment: A segment with the $traced boolean property, extended by the other segment.
  • DynamoSegment: A segment thought for Dynamo operations with $tableName, $operation and $requestId dynamo related properties.
  • HttpSegment: A segment thought for operation over HTTP with $url, $method and $responseCoderelated properties. It also features a closeWithPsrResponse helper method which allows to populate and close the segment with an object implementing the Psr\Http\Message\ResponseInterface interface.
  • SqlSegment: A segment thought for SQL operations with $query property and $url,$preparation,$databaseType,$databaseVersion,$driverVersion and $user optional properties.

You may want to extend one of the above class to instrument custom segments for metadata, annotation and aws data custom handling (Remember to extend __construct and jsonSerialize methods accordingly).

Fault and error handling

Any segment has the $fault and $error boolean properties that can be used accordingly, also you can set the cause with a Cause object.

eg.

$trace = new Trace(name: 'a_new_trace');
    
$pdo = new \PDO('a_totally_valid_dsn');
$query = "SELECT * FROM table_name";

$sqlSegment = new SqlSegment(
    name: \uniqid("subsegment_sql_"),
    query: $query
);

try {
    $pdo->exec($query);
} catch (\Throwable $exception) {
    $sqlSegment->setError(true);
    $sqlSegment->setCause(Cause::fromThrowable($exception));
}

$trace->addSubsegment($sqlSegment);

$trace->end()->submit(new DaemonSegmentSubmitter());

How to test the software

You can run the library test suite with PHPUnit by running composer test script, you can also run composer mutation script for mutation testing report.

Known issues

  • Segments currently support only Cause object but not exception ID.
  • Submitting open segment is not supported yet.

Getting help

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

Getting involved

Feedbacks and pull requests are very welcome, more on how to contribute on CONTRIBUTING.

Credits and references

This library is inspired by patrickkerrigan/php-xray, initially we thought to fork it but ended up re-writing it from scratch using PHP8 named constructors instead of fluent approach which allow us to have always valid entities instantiated.

fido/php-xray 适用场景与选型建议

fido/php-xray 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.27k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「aws」 「apm」 「tracing」 「X-Ray」 「AWS X-Ray」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fido/php-xray 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fido/php-xray 我们能提供哪些服务?
定制开发 / 二次开发

基于 fido/php-xray 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-25