diff options
author | Robin Appelman <robin@icewind.nl> | 2023-05-09 17:15:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-09 17:15:27 +0200 |
commit | 904fdf3aa3e55ec61943178e1fe28b0f89f8ef4f (patch) | |
tree | eb9b0c16708a5bff1e173529b271cc60d49542bf /tests | |
parent | 416f632280a4eccc53e09c691ae0cfbc66c0ffd8 (diff) | |
parent | e7ab30f5d8da574979f4c5b233f0cbd6827ecd90 (diff) | |
download | nextcloud-server-904fdf3aa3e55ec61943178e1fe28b0f89f8ef4f.tar.gz nextcloud-server-904fdf3aa3e55ec61943178e1fe28b0f89f8ef4f.zip |
Merge pull request #37838 from nextcloud/event-logger-http
log performance events for http requests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Http/Client/ClientServiceTest.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/lib/Http/Client/ClientServiceTest.php b/tests/lib/Http/Client/ClientServiceTest.php index ed1165236aa..72281a0453c 100644 --- a/tests/lib/Http/Client/ClientServiceTest.php +++ b/tests/lib/Http/Client/ClientServiceTest.php @@ -14,12 +14,15 @@ namespace Test\Http\Client; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\HandlerStack; use GuzzleHttp\Handler\CurlHandler; +use GuzzleHttp\Middleware; use OC\Http\Client\Client; use OC\Http\Client\ClientService; use OC\Http\Client\DnsPinMiddleware; +use OCP\Diagnostics\IEventLogger; use OCP\ICertificateManager; use OCP\IConfig; use OCP\Security\IRemoteHostValidator; +use Psr\Http\Message\RequestInterface; /** * Class ClientServiceTest @@ -37,17 +40,24 @@ class ClientServiceTest extends \Test\TestCase { ->willReturn(function () { }); $remoteHostValidator = $this->createMock(IRemoteHostValidator::class); + $eventLogger = $this->createMock(IEventLogger::class); $clientService = new ClientService( $config, $certificateManager, $dnsPinMiddleware, - $remoteHostValidator + $remoteHostValidator, + $eventLogger ); $handler = new CurlHandler(); $stack = HandlerStack::create($handler); $stack->push($dnsPinMiddleware->addDnsPinning()); + $stack->push(Middleware::tap(function (RequestInterface $request) use ($eventLogger) { + $eventLogger->start('http:request', $request->getMethod() . " request to " . $request->getRequestTarget()); + }, function () use ($eventLogger) { + $eventLogger->end('http:request'); + }), 'event logger'); $guzzleClient = new GuzzleClient(['handler' => $stack]); $this->assertEquals( |