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

Tracing: symfony http client #606

Merged
merged 31 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bc0592b
http client tracing
alekitto Mar 22, 2022
c680429
sentry sentry-trace header in tracing http client
alekitto Mar 23, 2022
166c478
add test on http client request
alekitto Mar 23, 2022
5ce0a9d
use newer phpunit on php 8
alekitto Mar 23, 2022
9d42874
require php 8.1 in psalm
alekitto Mar 23, 2022
0ee2c44
Revert "require php 8.1 in psalm"
alekitto Apr 12, 2022
0648814
fix for review
alekitto Apr 13, 2022
73132c2
add a couple of tests and changelog line
alekitto Apr 14, 2022
095abc3
use http.url and http.method tags, instead of url and method
alekitto Apr 15, 2022
d4c749f
http.request -> http.client
alekitto May 2, 2022
12490c4
add tests for traceable response classes
alekitto Jun 22, 2022
6760d1b
style fixes
alekitto Jun 22, 2022
79695c3
create fixtures for destructible and streamable responses
alekitto Jun 22, 2022
c4687c1
use ->assert instead of self::assert in phpunit tests
alekitto Jun 22, 2022
38faf38
mark test classes as final
alekitto Jun 22, 2022
0e2e979
rename variable
alekitto Jun 22, 2022
b00333f
test http-client tracing enabled/disabled
alekitto Jun 22, 2022
4a28c72
add span description
alekitto Jun 22, 2022
0d63111
update CHANGELOG.md
alekitto Jun 23, 2022
fd9f433
Add a test for the `TraceableHttpClient::withOptions()` method
ste93cry Jul 4, 2022
39eaa7f
fix withOptions test for v4
alekitto Jul 5, 2022
993c494
add test for http-client stream method
alekitto Jul 5, 2022
f2f5adc
Mark the `TraceableHttpClientFor*` classes as `@internal`
ste93cry Jul 6, 2022
e732d59
Minor methods and variables names changes
ste93cry Jul 6, 2022
c6d5f2b
Improve the test for the `TraceableHttpClient::stream()` method
ste93cry Jul 6, 2022
8a824d7
Improve the tests for the `TraceableResponse` class
ste93cry Jul 7, 2022
27d9d53
fix tests for lower deps
alekitto Jul 11, 2022
dcea7b5
fix static analysis
alekitto Jul 11, 2022
71ba653
add error conditions tests for stream methods
alekitto Jul 12, 2022
0ae2524
Minor improvements to the tests
ste93cry Jul 14, 2022
d9a3a71
Improve the tests for the `HttpClientTracingPass` class
ste93cry Jul 14, 2022
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
Prev Previous commit
Next Next commit
add error conditions tests for stream methods
  • Loading branch information
alekitto committed Jul 12, 2022
commit 71ba653a9c522839ca1199ab1db94b4f6fea1562
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ parameters:
count: 1
path: src/Tracing/HttpClient/TraceableHttpClientForV6.php

-
message: "#^Parameter \\#1 $responses of method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableHttpClient::stream\\(\\) expects iterable<\\(int\\|string\\), Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface>|Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface, stdClass given\\.$#"
count: 1
path: tests/Tracing/HttpClient/TraceableHttpClientTest.php

-
message: "#^Parameter \\#2 \\$responses of static method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableResponse::stream\\(\\) expects iterable<Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableResponse>, array<int, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface> given\\.$#"
count: 1
path: tests/Tracing/HttpClient/TraceableResponseTest.php

-
message: "#^Class Symfony\\\\Component\\\\Debug\\\\Exception\\\\FatalErrorException not found\\.$#"
count: 1
Expand Down
7 changes: 7 additions & 0 deletions tests/Tracing/HttpClient/TraceableHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ public function testStream(): void
$this->assertSame(1, $loopIndex);
}

public function testStreamShouldThrowOnWrongParameterType(): void
{
$this->expectException(\TypeError::class);
$this->expectExceptionMessage('"Sentry\SentryBundle\Tracing\HttpClient\AbstractTraceableHttpClient::stream()" expects parameter 1 to be an iterable of TraceableResponse objects, "stdClass" given.');
$this->httpClient->stream(new \stdClass());
}

public function testSetLoggerShouldBeForwardedToDecoratedInstance(): void
{
$logger = new NullLogger();
Expand Down
10 changes: 10 additions & 0 deletions tests/Tracing/HttpClient/TraceableResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

final class TraceableResponseTest extends TestCase
{
Expand Down Expand Up @@ -130,4 +131,13 @@ public function testToStream(): void

$this->assertSame('foobar', stream_get_contents($response->toStream()));
}

public function testStreamWithWrongObjectsShouldThrow(): void
{
$httpClient = new MockHttpClient(new MockResponse('foobar'));
$response = $this->createMock(ResponseInterface::class);

$this->expectException(\TypeError::class);
iterator_to_array(TraceableResponse::stream($httpClient, [$response], null));
}
}