N
N
Nujabes372019-06-26 11:48:09
PHP
Nujabes37, 2019-06-26 11:48:09

How to send and process X-Request-ID correctly?

Hello! In general, I was looking for information on the Internet on how to properly transfer and process requestIdon the server. And to my surprise, I did not find a normal example, if there are those who did this, enlighten me on the following issues.
1. How to correctly generate and transfer requestIdthrough the header to the server?
2. How to correctly register the transferred requestId. This means that it must be processed in PHP and stored somewhere, or should the server (in my case, nginx) do all this?
If I misunderstood the very essence requestId, then you can enlighten me in this)) Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2019-06-26
@Nujabes37

The meaning of requestId is to saddle it in various logs for further analysis of the application.
Usually it is created as early as possible, if we are talking about nginx, then there is already (starting from 1.11.0) the $request_id variable , which needs to be a) written to the nginx log and b) passed further to PHP (using fastcgi_param). You can also give it in the http header to the client.
Further, for good, your PHP application should also save this value in all its logs, as well as transfer it to all other services with which it communicates (databases, other http servers, etc.).

F
FanatPHP, 2019-06-26
@FanatPHP

I haven't done it, but I read the answer on stackoverfloe
Generate uniquely. UUID will do.
Probably pass it through a qveri string - then this id will go into the web server log, in case php completely crashes even before the error handler is launched. Well, or if such accuracy is not particularly critical, then just an additional field in Jason.
Plus, in the PHP error handler, take this value into account and add it to the error message written to the log.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question