Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThinkORM一个请求中,多个SQL只记录了一个SQL问题 #3

Merged
merged 1 commit into from Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Arms.php
Expand Up @@ -10,6 +10,7 @@
use Zipkin\Endpoint;
use Workerman\Timer;
use support\Db;
use const Zipkin\Tags\SQL_QUERY;

class Arms implements MiddlewareInterface
{
Expand Down Expand Up @@ -58,7 +59,11 @@ public function process(Request $request, callable $next): Response
$logs = \think\facade\Db::getDbLog(true);
if (!empty($logs['sql'])) {
foreach ($logs['sql'] as $sql) {
$rootSpan->tag('db.statement', $sql);
$sqlSpan = $tracer->newChild($rootSpan->getContext());
$sqlSpan->setName(SQL_QUERY);
$sqlSpan->start();
$sqlSpan->tag('db.statement', $sql);
$sqlSpan->finish();
}
}
}
Expand Down