2 ms·
this is awesome! how do you do this? a new header with a unique id... generated by something like lua+nginx. but then how do you pass this request from one serv
by sandGorgon 10y ago
this is awesome!
how do you do this? a new header with a unique id... generated by something like lua+nginx. but then how do you pass this request from one service to another?
- amatix 10y agoFor us, a `X-Request-ID` header is generated by any app if it doesn't receive it from upstream -- but normally nginx or the CDN will generate it. There's a few nginx modules to do it, we use https://github.com/newobj/nginx-x-rid-header https://github.com/newobj/nginx-x-rid-header Most languages/logging frameworks have some sort of per-thread context (eg. Filters in Python, MDC in log4j, etc) to be able to tag log messages with. If you're using postgresql, you can call `SET application_name='{requestID}';` and that can be output as part of logs too.
- foxylion 10y agoWe do the same in our setup. A Apache HTTPd assignes a unique id (mod_unique_id) as a http request and response header. So any downstream system will get the request header and can attach it to the logs. (In our case we write json log and one field is the request id)
- gdubya 10y agoThere are quite a few monitoring products being built to solve this problem. Many of them are based around Zipkin (http://zipkin.io/ http://zipkin.io/)
- caniszczyk 10y agoI strongly suggest people look at the OpenTracing work too: http://opentracing.io/ http://opentracing.io/