-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7dbc18
commit 97573d4
Showing
10 changed files
with
170 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JustBetter\Sentry\Model; | ||
|
||
use Sentry\State\Scope; | ||
use Sentry\Tracing\Span; | ||
|
||
class PerformanceTracingDto | ||
{ | ||
public function __construct( | ||
private Scope $scope, | ||
private ?Span $parentSpan = null, | ||
private ?Span $span = null | ||
) | ||
{ | ||
} | ||
|
||
public function getScope(): Scope | ||
{ | ||
return $this->scope; | ||
} | ||
|
||
public function getParentSpan(): ?Span | ||
{ | ||
return $this->parentSpan; | ||
} | ||
|
||
public function getSpan(): ?Span | ||
{ | ||
return $this->span; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JustBetter\Sentry\Plugin\Profiling; | ||
|
||
use JustBetter\Sentry\Model\PerformanceTracingDto; | ||
use JustBetter\Sentry\Model\SentryPerformance; | ||
use Magento\Framework\DB\LoggerInterface; | ||
use Sentry\Tracing\SpanContext; | ||
|
||
use function Sentry\trace; | ||
|
||
class DbQueryLoggerPlugin | ||
{ | ||
private ?PerformanceTracingDto $tracingDto = null; | ||
|
||
public function beforeStartTimer(LoggerInterface $subject): void | ||
{ | ||
$this->tracingDto = SentryPerformance::traceStart( | ||
SpanContext::make() | ||
->setOp('db.sql.query') | ||
->setStartTimestamp(microtime(true)) | ||
); | ||
} | ||
|
||
public function beforeLogStats(LoggerInterface $subject, $type, $sql, $bind = [], $result = null): void | ||
{ | ||
if ($this->tracingDto === null) { | ||
return; | ||
} | ||
|
||
$this->tracingDto->getSpan()?->setDescription($sql); | ||
SentryPerformance::traceEnd($this->tracingDto); | ||
$this->tracingDto = null; | ||
} | ||
} |
Oops, something went wrong.