Skip to content

Commit

Permalink
Enable queue tracing by default (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Jun 4, 2024
1 parent f6f5248 commit b34c6ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
// Performance monitoring specific configuration
'tracing' => [
// Trace queue jobs as their own transactions (this enables tracing for queue jobs)
'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false),
'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', true),

// Capture queue jobs as spans when executed on the sync driver
'queue_jobs' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true),
Expand Down
32 changes: 16 additions & 16 deletions test/Sentry/Features/QueueIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,46 +87,46 @@ public function testQueueJobsWithBreadcrumbSetInBetweenKeepsNonJobBreadcrumbsOnC
$this->assertCount(1, $this->getCurrentSentryBreadcrumbs());
}

protected function withoutSampling($app): void
protected function withTracingEnabled($app): void
{
$app['config']->set('sentry.traces_sample_rate', 1.0);
}

/**
* @define-env withoutSampling
* @define-env withTracingEnabled
*/
public function testQueueJobDoesntCreateTransactionByDefault(): void
public function testQueueJobCreatesTransactionByDefault(): void
{
dispatch(new QueueEventsTestJob);

$transaction = $this->getLastSentryEvent();

$this->assertNull($transaction);
$this->assertNotNull($transaction);

$this->assertEquals(EventType::transaction(), $transaction->getType());
$this->assertEquals(QueueEventsTestJob::class, $transaction->getTransaction());

$traceContext = $transaction->getContexts()['trace'];

$this->assertEquals('queue.process', $traceContext['op']);
}

protected function withQueueJobTracingEnabled($app): void
protected function withQueueJobTracingDisabled($app): void
{
$app['config']->set('sentry.traces_sample_rate', 1.0);
$app['config']->set('sentry.tracing.queue_job_transactions', true);
$app['config']->set('sentry.tracing.queue_job_transactions', false);
}

/**
* @define-env withQueueJobTracingEnabled
* @define-env withQueueTracingDisabled
*/
public function testQueueJobCreatesTransactionWhenEnabled(): void
public function testQueueJobDoesntCreateTransaction(): void
{
dispatch(new QueueEventsTestJob);

$transaction = $this->getLastSentryEvent();

$this->assertNotNull($transaction);

$this->assertEquals(EventType::transaction(), $transaction->getType());
$this->assertEquals(QueueEventsTestJob::class, $transaction->getTransaction());

$traceContext = $transaction->getContexts()['trace'];

$this->assertEquals('queue.process', $traceContext['op']);
$this->assertNull($transaction);
}
}

Expand Down

0 comments on commit b34c6ec

Please sign in to comment.