diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 18cfe550d..32b3a2160 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -368,9 +368,9 @@ private function _requestRaw($method, $url, $params, $headers) $hasFile ); - if (isset($rheaders['request-id'])) { + if (isset($rheaders['request-id']) && isset($rheaders['request-id'][0])) { self::$requestTelemetry = new RequestTelemetry( - $rheaders['request-id'], + $rheaders['request-id'][0], Util\Util::currentTimeMillis() - $requestStartMs ); } diff --git a/tests/Stripe/StripeTelemetryTest.php b/tests/Stripe/StripeTelemetryTest.php index 966677138..f248ebc93 100644 --- a/tests/Stripe/StripeTelemetryTest.php +++ b/tests/Stripe/StripeTelemetryTest.php @@ -90,7 +90,7 @@ public function testTelemetrySetIfEnabled() }), $this->anything(), $this->anything() - )->willReturn(array(self::FAKE_VALID_RESPONSE, 200, ["request-id" => "123"])); + )->willReturn(array(self::FAKE_VALID_RESPONSE, 200, ["request-id" => ["req_123"]])); ApiRequestor::setHttpClient($stub); @@ -103,7 +103,7 @@ public function testTelemetrySetIfEnabled() $this->assertArrayHasKey('X-Stripe-Client-Telemetry', $requestheaders); $data = json_decode($requestheaders['X-Stripe-Client-Telemetry'], true); - $this->assertEquals('123', $data['last_request_metrics']['request_id']); + $this->assertEquals('req_123', $data['last_request_metrics']['request_id']); $this->assertNotNull($data['last_request_metrics']['request_duration_ms']); ApiRequestor::setHttpClient(null);