From 7d3a494da9c1121d64c2ddb8847893a7e8df8875 Mon Sep 17 00:00:00 2001 From: hectorhammett Date: Tue, 10 Dec 2024 00:32:19 +0000 Subject: [PATCH] Change the httpHandler requestId fallback to a hash --- src/HttpHandler/Guzzle6HttpHandler.php | 4 ++-- src/Logging/LoggingTrait.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HttpHandler/Guzzle6HttpHandler.php b/src/HttpHandler/Guzzle6HttpHandler.php index 89f3bbf71..95926d3a5 100644 --- a/src/HttpHandler/Guzzle6HttpHandler.php +++ b/src/HttpHandler/Guzzle6HttpHandler.php @@ -68,7 +68,7 @@ public function __invoke(RequestInterface $request, array $options = []) $requestEvent->retryAttempt = $options['retryAttempt'] ?? null; $requestEvent->serviceName = $options['serviceName'] ?? null; $requestEvent->processId = getmypid(); - $requestEvent->requestId = $options['requestId'] ?? spl_object_id($request); + $requestEvent->requestId = $options['requestId'] ?? crc32((string) spl_object_id($request) . getmypid()); $this->logRequest($requestEvent); } @@ -112,7 +112,7 @@ public function async(RequestInterface $request, array $options = []) $requestEvent->retryAttempt = $options['retryAttempt'] ?? null; $requestEvent->serviceName = $options['serviceName'] ?? null; $requestEvent->processId = getmypid(); - $requestEvent->requestId = $options['requestId'] ?? spl_object_id($request); + $requestEvent->requestId = $options['requestId'] ?? crc32((string) spl_object_id($request) . getmypid()); $this->logRequest($requestEvent); } diff --git a/src/Logging/LoggingTrait.php b/src/Logging/LoggingTrait.php index d6d0422a4..f42dd8daa 100644 --- a/src/Logging/LoggingTrait.php +++ b/src/Logging/LoggingTrait.php @@ -74,7 +74,7 @@ private function logResponse(RpcLogEvent $event): void $debugEvent = [ 'timestamp' => $event->timestamp, 'severity' => strtoupper(LogLevel::DEBUG), - 'processId' => $event->processId, + 'processId' => $event->processId ?? null, 'requestId' => $event->requestId ?? null, 'jsonPayload' => [ 'response.headers' => $event->headers,