-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature to calculate db_payload_size and response_payload_size #3
Conversation
…name method reset_allocated_memory to reset_db_payload_size
…sponse payload size before convert to json in render
…e#payload_size_in_kb
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.
LGTM! I decided to merge #4 because I reviewed it earlier, your approaches are almost same 🙂 I listed you as a solution author on the Cult and will put it to the readme and changelog now.
May I ask you to port your code related to #add_notification?
Yeah, of course, I will create new PR and will integrate #add_notification |
@DmitryTsepelev |
Got it! Thanks for the hard work again, and please let me know if you have any other ideas for the lib! |
Hello, @DmitryTsepelev !
#1
Here I add railties for adding logs about Db payload size and response payload size. And we`ll see in logs like this
Also, this information (db_payload_size and response_payload_size) added to 'process_action.action_controller' of ActiveNotification
I patched ActiveRecord::Relation and ActiveRecord::Calculations, for calculate bytes of result (AR extension)
DB payload size
For response_body I added railtie ControllerResponsePayloadSize and calculate response_body before render
For calculating I used
Marchal.dump(some_object).size
If result contains AR object (#<Transaction id: ..., token: ....>), that means more allocated memory, and we will calculate this, not only rows data.
Difference between (for example)
and
Before, I also tried to use
ObjectSpace.memsize_of
, but this is not performance, because we need to find all related objects and caculate themif ratio less than threshold, will send notificaion (of log, dependencies configuration) with message 'I/O to response payload ratio is ratio, while threshold is threshold'
Also, we can configure own notifications, by using add_notification, for example
For monitoring data, include to controller
And, I am ready for fixing code, if needed)