-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add MiqQueue#tracking_label #15224
Add MiqQueue#tracking_label #15224
Conversation
d9e21de
to
5383163
Compare
@@ -0,0 +1,5 @@ | |||
class AddLoggingTaskIdToMiqQueue < ActiveRecord::Migration[5.0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this class (and thus file) be named AddRequestUUIDTOMiqQueue
?
5383163
to
d2dd0c9
Compare
@@ -104,6 +104,7 @@ def deliver_queue_message(msg) | |||
|
|||
begin | |||
$_miq_worker_current_msg = msg | |||
Thread.current["request_id"] = msg.task_id || msg.request_uuid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change MiqQueue.put to automatically default request_uuid to task_id? That way this code can just be
Thread.current["request_id"] = msg.request_uuid
Overall I am 👍 on this PR, I just don't like the names...
I originally thought |
@kbrock I think you sent me a new name on Gitter this morning, but I can't find it...what was your suggestion? Something like |
@Fryguy |
As I mentioned above I don't like the uuid in the name because
However, what about just dropping a suffix altogether and going with |
@Fryguy for reference, I was thinking something like https://github.com/theforeman/foreman/blob/develop/lib/middleware/tagged_logging.rb#L8 |
This pull request is not mergeable. Please rebase and repush. |
Database migrations have now been moved to the https://github.com/ManageIQ/manageiq-schema repo. Please see http://talk.manageiq.org/t/new-split-repo-manageiq-schema/2478 for instructions on how to transfer your database migrations. If this PR contains only migrations, I will leave it open for a short time during the transition, after which I will close this if it has not been moved over. |
@mkanoor Also, I like the tracking bit, but you can't have the _id as that implies a Rails foreign key (or rather, when it doesn't as in this case, it's confusing) |
@Fryguy |
d2dd0c9
to
c73f419
Compare
@kbrock |
c73f419
to
e403d6f
Compare
ManageIQ/manageiq-schema#17 merged |
e403d6f
to
baef0ff
Compare
app/models/miq_queue.rb
Outdated
@@ -109,6 +109,7 @@ def self.put(options) | |||
options[:queue_name] ||= create_with_options[:queue_name] || "generic" | |||
options[:msg_timeout] ||= create_with_options[:msg_timeout] || TIMEOUT | |||
options[:task_id] = $_miq_worker_current_msg.try(:task_id) unless options.key?(:task_id) | |||
options[:tracking_label] = Thread.current["tracking_label"] || options[:task_id] unless options.key?(:tracking_label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "tracking_label"
? can it be a symbol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei huh. turns out both will do the same thing.
I can change it, but had already merged this for the vmdb-logger.
It looks like you can use symbols and strings interchangeably.
>Thread.current[:test] = "abc"
>puts Thread.current["test"]
abc
>Thread.current["test"] = "cde"
>puts Thread.current[:test]
cde
many times we add a task_id for logging only. As we are getting away from task_id, we don't want to loose the logging. This allows us to transition away from task_id The tracking_label will be set in the target system, so a single request can be traced through the various systems
baef0ff
to
d2ad01f
Compare
Checked commit kbrock@d2ad01f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@Fryguy please review |
Many times we pass a
task_id
intoMiqQueue.put
for logging only. Especially in automate.This is not the best use of
task_id
as it prevents other workers from working concurrently on these jobs. Also, it is not a mechanism that works across other implementations of queues, so we are trying to phase it out.This gives us a transition path away from using
task_id
, while still keeping the benefits of logging.This also allows us to transition away from the global variable holding the current
MiqQueue
record.related to ManageIQ/manageiq-gems-pending#183
and ManageIQ/manageiq-schema#17
/cc @mkanoor