Closed
Description
Problem Statement
Is there consideration to add a db.bindings
to record SQL bindings, making it convenient for SQL analysis?
It could be set as a configurable option for enabling.
protected function queryExecutedHandler(DatabaseEvents\QueryExecuted $query): void
{
if (!$this->traceSqlQueries) {
return;
}
$parentSpan = SentrySdk::getCurrentHub()->getSpan();
// If there is no tracing span active there is no need to handle the event
if ($parentSpan === null) {
return;
}
$context = new SpanContext();
$context->setOp('db.sql.query');
$context->setDescription($query->sql);
$context->setData([
'db.name' => $query->connection->getDatabaseName(),
'db.system' => $query->connection->getDriverName(),
'server.address' => $query->connection->getConfig('host'),
'server.port' => $query->connection->getConfig('port'),
]);
$context->setStartTimestamp(microtime(true) - $query->time / 1000);
$context->setEndTimestamp($context->getStartTimestamp() + $query->time / 1000);
if ($this->traceSqlQueryOrigins) {
$queryOrigin = $this->resolveQueryOriginFromBacktrace();
if ($queryOrigin !== null) {
$context->setData(array_merge($context->getData(), [
'db.sql.origin' => $queryOrigin
]));
}
}
$parentSpan->startChild($context);
}
Solution Brainstorm
if ($this->traceSqlBindings) {
$context->setData(array_merge($context->getData(), [
'db.sql.bindings' => $query->bindings,
]));
}
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status