Download the PHP package extraswoft/jaeger without Composer

On this page you can find all versions of the php package extraswoft/jaeger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jaeger

简介

本项目属于swoft的jaeger client,非侵入式地对项目环境进行跟踪并且异步上报到jaeger server,可以和其他的swoft项目或者其他语言(java,go)进行全链路监控,能监控mysql,redis,httpClient的正常异常情况。并且上传是使用thrift,udp 上传,效率较高。 目前新版本(v0.0.0.7以上)支持log记录,不使用udp,提高效率

之前我还写过zipkin的sdk,链接如下swoft-zipkin

环境要求

1.扩展要求

配置步骤

1.composer

先给composer.json添加如下语句,因为我们项目里引入的opentracing/opentracing官方最新的也只是一个beta包,不加会导致无法引入

引入本项目的包

2.config/properties/app.php 添加

需要在app文件,beanScan里加上扫描我们的命名空间

3.config/beans/base.php添加我们的中间件

4.在.env配置文件中添加以下配置

ZIPKIN_HOST: jager_client 的地址
ZIPKIN_RAND: 采样率,1为100%, 最小可设为0.0001,线上环境建议采样
ENV: 配置环境,通过配置环境可以共用一个jaegerServer
JAEGER_OPEN: 是否开启jaeger,可不同环境不同配置
JAEGER_MODE: 1:使用udp传输,2:写入日志,日志依赖 @log 的配置(小时区分日志)

5.httpClient 的修改

当我们使用swoft官方的httpClient的时候,需要使用我们客户端的adapter,挂上钩子

当然,你也可以看下我们适配器的源码放到自己的适配器里,比较简单

源码修改

因为在mysql,redis和http的请求上没有钩子函数,所以我们需要自己实现,只要在请求开始和结束加上事件触发即可。建议自己或者公司项目直接fork官方的swoft-component,然后根据自己需要开发,并且隔一段时间同步最新代码,在swoft里面composer使用component这个仓库。

1.mysql(协程)

src/db/src/Db.php中,在$connection->prepare($sql);前添加(注意命名空间加入)

src/db/src/DbCoResult.php中,在Log::profileEnd($this->profileKey);后添加(注意命名空间加入)

2.redis (非协程),协程可以根据自己需要添加

src/redis/src/Redis.php(注意命名空间加入)

在 $result = $connection->$method(...$params);前后添加

3.httpClient (协程)

src/http-client/src/Adapter/CoroutineAdapter.php

在 $client->execute($path);前添加

src/http-client/src/HttpCoResult.php

在 得到$response后添加

捕获异常

在全局的SwoftExceptionHandler.php里面添加对MysqlExceptionRedisException异常的钩子,保证我们能把异常的情况也上报了

完成

完成以上修改后,重新composer引入新的swoft-component包,然后重启项目就可以了

log记录

新版本支持将数据写入log,但由于原生字符串包含换行符,导致写入日志变成多行而不是一行,所以在写入日志时 会特殊处理, 变为: 'jaegerMsg:' . urlencode($thriftFile) . "\n"

获取header

因为链路传递是通过header来服务的,所以项目里面当有特殊的client时,想要获取header来传递可以使用下面方法

Jaeger 的搭建

我把我的搭建心得都放在了下面这篇文章里面了 全链路监控Jaeger搭建实战

但是如果你懒得看,也可以直接用下面的

直接起就搭建完成了,默认client 接受端口是6831

效果图

jaegerUI.png


All versions of jaeger with dependencies

PHP Build Version
Package Version
Requires jukylin/jaeger-php Version v2.0.4-beta
opentracing/opentracing Version 1.0.0-beta2
psr/http-server-handler Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package extraswoft/jaeger contains the following files

Loading the files please wait ....