Fixed bug that server crash when tracer flush failed in defer. (#3228)

* Fixed bug that server crash when tracer flush failed in defer.
* Update CHANGELOG-2.1.md
This commit is contained in:
李铭昕 2021-01-30 19:47:11 +08:00 committed by GitHub
parent 0bfb89fa1c
commit 80830d726f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 21 deletions

View File

@ -5,6 +5,7 @@
- [#3204](https://github.com/hyperf/hyperf/pull/3204) Fixed unexpected behavior for `middlewares` when using `rpc-server`.
- [#3209](https://github.com/hyperf/hyperf/pull/3209) Fixed bug that connection was not be released to pool when the amqp consumer broken in coroutine style server.
- [#3222](https://github.com/hyperf/hyperf/pull/3222) Fixed memory leak for join queries in `hyperf/database`.
- [#3228](https://github.com/hyperf/hyperf/pull/3228) Fixed bug that server crash when tracer flush failed in defer.
## Added

View File

@ -25,25 +25,6 @@ composer require jonahgeorge/jaeger-client-php
php bin/hyperf.php vendor:publish hyperf/tracer
```
### opentracking/opentracking 版本申明
由于 [官方包](https://github.com/opentracing/opentracing-php) 最新版还是 `1.0.0-beta6`, 会导致 composer 安装时不符合 `minimum-stability`, 所以 hyperf 框架 fork 了一份, 并基于当前 master 分支打上 `v1.0.0` 版本
```json
{
"require": {
...
"opentracing/opentracing":"1.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/hyperf/opentracing-php.git"
}
]
}
```
## 使用
### 配置
@ -218,7 +199,7 @@ return [
### 配置 Span tag
`1.1.11` 版本后增加了 Span Tag 配置的功能,对于一些 Hyperf 自动收集追踪信息的 Span Tag 名称,可以通过更改 Span Tag 配置来更改对应的名称,只需在配置文件 `config/autolaod/opentracing.php` 内增加 `tags` 配置即可,参考配置如下。如配置项存在,则以配置项的值为准,如配置项不存在,则以组件的默认值为准。
对于一些 Hyperf 自动收集追踪信息的 Span Tag 名称,可以通过更改 Span Tag 配置来更改对应的名称,只需在配置文件 `config/autolaod/opentracing.php` 内增加 `tags` 配置即可,参考配置如下。如配置项存在,则以配置项的值为准,如配置项不存在,则以组件的默认值为准。
```php
return [

View File

@ -45,7 +45,10 @@ class TraceMiddleware implements MiddlewareInterface
$span = $this->buildSpan($request);
defer(function () {
try {
$this->tracer->flush();
} catch (\Throwable $exception) {
}
});
try {
$response = $handler->handle($request);