Skip to content

Commit

Permalink
延迟写入追踪数据
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Jan 30, 2021
1 parent fa922b7 commit 9613066
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/middleware/TraceRpcServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace think\swoole\middleware;

use Swoole\Coroutine;
use think\swoole\rpc\Protocol;
use think\tracing\Tracer;
use Throwable;
Expand Down Expand Up @@ -40,7 +41,10 @@ public function handle(Protocol $protocol, $next)
throw $e;
} finally {
$scope->close();
$this->tracer->flush();

Coroutine::defer(function () {
$this->tracer->flush();
});
}
}
}

0 comments on commit 9613066

Please sign in to comment.