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

Enable queue tracing by default #903

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading