Skip to content

Commit 1992c55

Browse files
perf: log slow DNS operations
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 8398c32 commit 1992c55

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/private/Http/Client/DnsPinMiddleware.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
*/
99
namespace OC\Http\Client;
1010

11+
use OC\Diagnostics\TLogSlowOperation;
1112
use OC\Net\IpAddressClassifier;
1213
use OCP\Http\Client\LocalServerException;
1314
use Psr\Http\Message\RequestInterface;
15+
use Psr\Log\LoggerInterface;
1416

1517
class DnsPinMiddleware {
1618

19+
use TLogSlowOperation;
20+
1721
public function __construct(
1822
private NegativeDnsCache $negativeDnsCache,
1923
private IpAddressClassifier $ipAddressClassifier,
24+
private LoggerInterface $logger,
2025
) {
2126
}
2227

@@ -88,7 +93,11 @@ private function dnsResolve(string $target, int $recursionCount) : array {
8893
* Wrapper for dns_get_record
8994
*/
9095
protected function dnsGetRecord(string $hostname, int $type): array|false {
91-
return \dns_get_record($hostname, $type);
96+
return $this->monitorAndLog(
97+
$this->logger,
98+
'dns_get_record',
99+
fn () => \dns_get_record($hostname, $type),
100+
);
92101
}
93102

94103
public function addDnsPinning(): callable {

0 commit comments

Comments
 (0)