-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate unique identifier for each request and pass to upsteram as a header #1086
Comments
This would be the easiest plugin to make. Beginners welcome. |
any requirements for the ID? The easy answer is uuid, but that is slow. Will something like 'host-name + WorkerPID + counter' do? |
The most important requirement would be true, guaranteed uniqueness, at least for some platforms which heavily rely on such a feature (for example tracking a money transaction from its request id). This could be configurable. Also if we are worried about speed, we could benchmark a uuid C binding vs an FFI implementation.
|
which requires good random algorithms, which are not cheap How about generating a uuid once per worker process and append a counter value. |
I could see that work, it is also nice because since it is a per-worker state, the counter can simply live as a non-global in the module. |
👍 could be two different plugins too, user can pick what level of performance / accuracy they want by making choice of plugin to use. (this true to any existing or future plugins) |
Re: UUID, I've seen this (a C impl), this and this (pure Lua), and this and this (ffi). Presuming Kong's I would like to discuss how one might configure the plugin. This is to get stylistic issues out of the way before I start hacking at a POC. Example 1
Now the big question: how to specify combinations of generators, and especially sub-options, like "I only want one UUID per worker". Example 2
This is where I'd especially like feedback: Example 3
So, to recap: I'm trying to think of this from the point of view of the administrator configuring the plugin, so I'd like feedback before putting pen to paper. Lastly, a correlation-id works better with logging, so in the spirit of the Unix philosophy one can just suggest this plugin be used with one of the logging plugins so you can send |
Nothing too fancy. "UUID" and "UUID-counter" are enough. Not sure about the naming for the second one but it doesn't matter much. As for the format, something like "uuid#counter" is probably suitable. It would be easier to parse for users than a dash like uuid's, so one can distinguish the worker's uuid from the counter easily. |
@ahmadnassri @thibaultcha if there is an header [Kong-Request-ID] already present, the plugin should pass the Kong-Request-ID as is without modification , this would help in tracing api to api calls . |
Yes, this would be user-specified, e.g.: @ajayk Noted! |
No I think you are over complicating this though... |
I agree, looks to complicated to me too. Just an option to switch between a uuid-per-request or a uuid-per-worker+timestamp/counter should do. |
Sure, with a hard-coded So, to confirm, the user of the plugin has 2 options when choosing a generator: For "unique uuid for every request":
For "unique uuid per worker process, with a counter, delimited by a
|
All, please review my latest changes. I've made a note in my tests about relying on one worker process for some things. Once you're happy, I'll squash and PR. |
Code lgtm generally, some minor nit picks. But the changes to kong/tools/database_cache.lua can/should be reverted no? |
I've reverted the changes to the cache, and will look at the commit comments, thank you. |
Can you please open a PR so the review process is easier and centralized? Thanks. |
@thibaultcha Done: #1094 |
Impement request tracking via headers through UUIDs and a combination of UUIDs and worker ids for performance concerns. fix #1086 Signed-off-by: Thibault Charbonnier <[email protected]>
Just manually merged the patch from #1094. Now applying the documentation. Thanks a lot! We'll try to include this in 0.8 very soon. |
being able to trace requests coming through Kong with some sort of unique identifier would be helpful for further tracking in the upstream, a suggested header name can be:
Kong-Request-ID
(in accordance with #324)The text was updated successfully, but these errors were encountered: