*/ public null|array $headers = null; /** * An array representation of JSON for the response or request * * @var null|string */ public null|string $payload = null; /** * Status code for REST or gRPC methods * * @var null|int|string */ public null|int|string $status = null; /** * The latency in milliseconds * * @var null|int */ public null|int $latency = null; /** * The retry attempt number * * @var null|int */ public null|int $retryAttempt = null; /** * The name of the gRPC method being called * * @var null|string */ public null|string $rpcName = null; /** * The Service Name of the gRPC * * @var null|string $serviceName */ public null|string $serviceName = null; /** * The Process ID for tracing logs * * @var null|int $processId */ public null|int $processId = null; /** * The Request id for tracing logs * * @var null|int $requestId; */ public null|int $requestId = null; /** * Creates an object with all the fields required for logging * Passing a string representation of a timestamp calculates the difference between * these two times and sets the latency field with the result. * * @param null|float $startTime (Optional) Parameter to calculate the latency */ public function __construct(null|float $startTime = null) { $this->timestamp = date(DATE_RFC3339); // Takes the micro time and convets it to millis $this->milliseconds = round(microtime(true) * 1000); if ($startTime) { $this->latency = (int) round($this->milliseconds - $startTime); } } }