Skip to content

Commit

Permalink
leftover removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Cech committed Aug 25, 2021
1 parent 2abfa68 commit 3d18bcd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ class Client extends CApplicationComponent
*/
public $jsDsn;

/**
* Enable Sentry tracing
* https://docs.sentry.io/product/sentry-basics/tracing/distributed-tracing/
* @var bool
*/
public $tracing = false;

/**
* user context for error reporting
* @var array
Expand Down Expand Up @@ -128,6 +121,7 @@ public function captureMessage(string $message, ?Severity $level = null, ?Scope
*/
public function captureException(\Throwable $exception, ?Scope $scope = null): ?string
{
$this->rootTransaction->setHttpStatus(500);
return $this->getSentry()->getClient()->captureException($exception, $scope);
}

Expand Down Expand Up @@ -252,6 +246,8 @@ protected function attachEventHandlers(): void
{
Yii::app()->attachEventHandler('onBeginRequest', [$this, 'handleBeginRequestEvent']);
Yii::app()->attachEventHandler('onEndRequest', [$this, 'handleEndRequestEvent']);
Yii::app()->attachEventHandler('onException', [$this, 'handleExceptionEvent']);
Yii::app()->attachEventHandler('onError', [$this, 'handleExceptionEvent']);
}

private function isPhpErrorReportingEnabled(): bool
Expand All @@ -266,7 +262,7 @@ private function isJsErrorReportingEnabled(): bool

private function isTracingEnabled(): bool
{
return $this->tracing === true;
return isset($this->options['traces_sampler']);
}

//region Events
Expand Down Expand Up @@ -300,19 +296,23 @@ public function handleEndRequestEvent(\CEvent $event): void
}

if ($this->rootTransaction !== null) {
if ($this->rootTransaction->getStatus() === null) {
$this->rootTransaction->setHttpStatus(200);
}
$this->rootTransaction->finish();
}
}

public function handleExceptionEvent(\CEvent $event): void
{
$this->rootTransaction->setHttpStatus(500);
}

/**
* @param string[]|int[]|bool[] $data
*/
public function startRootTransaction(string $description, array $data = []): Transaction
{
if (!isset($data['component'])) {
$data['component'] = 'yii-sentrytracing';
}

$context = new TransactionContext();
$context->setOp('yii-app');
$context->setName($description);
Expand Down

0 comments on commit 3d18bcd

Please sign in to comment.