-
Notifications
You must be signed in to change notification settings - Fork 902
Add RequestLogger from AutomationEngine #23409
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
Conversation
@miq-bot cross-repo-test ManageIQ/manageiq-automation_engine#569 |
From Pull Request: ManageIQ/manageiq#23409
Okay this is passing cross-repo |
[severity, message, progname] | ||
end | ||
|
||
def info(progname = nil, resource_id: nil, &block) |
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.
NOTE one thing I don't like about this approach is that it requires that the caller modify all calls to the logger, instead of passing it a logger instance that has everything already set up.
If instead we had e.g. a logger instance created with the object we're referencing then we can use normal logger.info
calls. We can also use standard wrapped loggers and pass the request logger into code that otherwise wouldn't have to know about it (aka Floe)
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.
Yeah, that's what we ended up having to do, but I don't think we can actually do the other way around as you're proposing.
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.
Hm that might be a bit of an issue for using this more generally then. I was playing with overriding the automate subclass of this logger to log using this style maybe I go further down that path.
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.
I feel strongly about using a standard interface.
Would really prefer having the resource_id hardcoded in the logger (initializer) Like I did in #23406
This current implementation doesn't work for me
aa1be54
to
51fc110
Compare
No, the way it was built is that it was a single logger than could handle an extra parameter. When the request_id parameter was sent as part of the log message it writes to both the request logs table and the automation log, otherwise it only writes to the automation log. This was because the request code jumps all over the place including different workers, and goes through serialization and deserialization such as through the workspace. As such, the only constant was the request id. I think it would be weird if we had to initialize a new logger with a request id just to call a single info call and then throw it away. |
Yeah no issue with the request_id being the constant because of serialize/deserialize, not sure if instantiating a wrapped logger when you want to use it is weird since having an extra log parameter that changes if it logs to one place or two places is also kinda weird... but if it is too odd then maybe we leave the automate one the way it is and have this one in core work a different way if we had to |
An example might be helpful: https://github.com/ManageIQ/manageiq-automation_engine/blob/master/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb#L91 So here, this is a class method that invokes automate. We have the obj.workspace, and we pull out the miq_request_id out of it, then pass it over to the automation logger. I guess we could put that logger inside the workspace and call |
BTW, I'm not against your idea of flipping it around - it was gross to me at the beginning having to change all these caller in the automation engine to be request-aware, but I couldn't figure it out at the time. |
good news: half of logging asks the This feels like a simple solution to get us closer to using the standard logging interface. For this to happen, we would need to change this logger to setting the |
This pull request is not mergeable. Please rebase and repush. |
Replaced by #23426 |
Add a
Vmdb::Loggers::RequestLogger
based on theAutomationEngine::Logger
Vmdb::Loggers::RequestLogger
automation_log_wrapper
to justlog_wrapper
, drop the.create_log_wrapper
class method since that was hard-coded to use the automation logger and it makes sense to just do this in a subclassrequest_logger.rb
Follow-ups:
Related: