-
-
Notifications
You must be signed in to change notification settings - Fork 363
[18.0][IMP] server logs and profiling #589
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
base: 18.0
Are you sure you want to change the base?
[18.0][IMP] server logs and profiling #589
Conversation
This allows to use the same syntax than the existing one from rest.log.active to define other config parameters.
Werkzeug logs are only generated when Odoo answers HTTP requests, whereas this will allow to know whenever a request is dispatched through rest services.
Leverage ir.profile machinery to track what happens when a user calls some rest services. Since profiling can be done only for a single user at a time the system parameter rest.log.profiling.uid has to be defined with the ID from res.users whose calls need to be profiled. Moreover, system parameter rest.log.profiling.conf can be defined using the syntax from rest.log.active to fine tune which requests will trigger the profiling for the user defined by the previous parameter. To note, once a request is identified to start the profiling, all incoming requests from the user will be profiled until the timeout duration defined by rest.log.profiling.duration is reached.
|
Hi @simahawk, |
simahawk
left a comment
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.
early review, to be tested.
| _log_calls_in_db = False | ||
|
|
||
| def dispatch(self, method_name, *args, params=None): | ||
| if self._server_debug_logging_active(method_name): |
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 wonder if we really need an IF here. All in all we can control this with debug levels.
| profiling_duration = 10 | ||
| try: | ||
| profiling_duration = int( | ||
| self.env["ir.config_parameter"] |
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.
Do we really need to take care of such params?
We can simply set base.profiling_enabled_until when we set the other params.
We'll reduce complexity here. In fact, we could simply check if profiling is enable by calling ir.profile._enabled_until()
| _logger.warning( | ||
| "System parameter rest.log.profiling.duration is not defined. Profiling will be active for the next 10 minutes" | ||
| ) | ||
| profiling_enabled_until = fields.Datetime.now() + relativedelta( |
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.
missing imports
[REF] rest_log: Add hooks to read configuration from system params
This allows to use the same syntax than the existing one from
rest.log.active to define other config parameters.
[IMP] rest_log: Allow printing server logs on incoming requests
Werkzeug logs are only generated when Odoo answers HTTP requests,
whereas this will allow to know whenever a request is dispatched
through rest services.
[IMP] rest_log: Allow to profile requests through rest services
Leverage ir.profile machinery to track what happens when a user
calls some rest services.
Since profiling can be done only for a single user at a time the
system parameter rest.log.profiling.uid has to be defined with
the ID from res.users whose calls need to be profiled.
Moreover, system parameter rest.log.profiling.conf can be defined
using the syntax from rest.log.active to fine tune which requests
will trigger the profiling for the user defined by the previous
parameter.
To note, once a request is identified to start the profiling, all
incoming requests from the user will be profiled until the timeout
duration defined by rest.log.profiling.duration is reached.