diff --git a/config/sentry.php b/config/sentry.php index 8d3aaa1e..2905b498 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -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), diff --git a/test/Sentry/Features/QueueIntegrationTest.php b/test/Sentry/Features/QueueIntegrationTest.php index fc472a8b..9feb327a 100644 --- a/test/Sentry/Features/QueueIntegrationTest.php +++ b/test/Sentry/Features/QueueIntegrationTest.php @@ -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); } }