Skip to content

Commit

Permalink
Add tests for disabling http_client_requests tracing/breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Nov 13, 2023
1 parent 8a9270a commit e773335
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/Sentry/Features/HttpClientIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ public function testHttpClientBreadcrumbDoesntConsumeBodyStream(): void
$this->assertEquals('response', $response->toPsrResponse()->getBody()->getContents());
}

public function testHttpClientBreadcrumbIsNotRecordedWhenDisabled(): void
{
$this->resetApplicationWithConfig([
'sentry.breadcrumbs.http_client_requests' => false,
]);

$this->dispatchLaravelEvent(new ResponseReceived(
new Request(new PsrRequest('GET', 'https://example.com', [], 'request')),
new Response(new PsrResponse(200, [], 'response'))
));

$this->assertEmpty($this->getCurrentBreadcrumbs());
}

public function testHttpClientSpanIsRecorded(): void
{
$transaction = $this->startTransaction();
Expand Down Expand Up @@ -93,4 +107,22 @@ public function testHttpClientSpanIsRecordedWithCorrectResult(): void
$this->assertEquals('http.client', $span->getOp());
$this->assertEquals(SpanStatus::internalError(), $span->getStatus());
}

public function testHttpClientSpanIsNotRecordedWhenDisabled(): void
{
$this->resetApplicationWithConfig([
'sentry.tracing.http_client_requests' => false,
]);

$transaction = $this->startTransaction();

$client = Http::fake();

$client->get('https://example.com');

/** @var \Sentry\Tracing\Span $span */
$span = last($transaction->getSpanRecorder()->getSpans());

$this->assertNotEquals('http.client', $span->getOp());
}
}

0 comments on commit e773335

Please sign in to comment.