-
Notifications
You must be signed in to change notification settings - Fork 594
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
[4.x] Add model hydrations to model watcher #1000
[4.x] Add model hydrations to model watcher #1000
Conversation
|
||
Telescope::recordModelEvent($this->hydrationEntries[$modelClass]); | ||
} else { | ||
$this->hydrationEntries[$modelClass]->content['count']++; |
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'm getting an "Illegal string offset 'count'" in this line. I think is because for some reason... content doesn't have an array in some models...
It can be prevent by
if (! is_array($this->hydrationEntries[$modelClass]->content)) {
$this->hydrationEntries[$modelClass]->content = json_decode($this->hydrationEntries[$modelClass]->content, true);
}
$this->hydrationEntries[$modelClass]->content['count']++;
@gboquizosanchez content always seems to be an array. Refer telescope/src/IncomingEntry.php Lines 66 to 82 in de59dbe
Can you open an issue with some steps to replicate your error? |
Yeah, sure, I'll test in a fresh installation with same parameters and if I can reproduce the issue, I'll post it. |
@gboquizosanchez Laravel 8.25.0 I am getting this error: ERROR: Illegal string offset 'count' |
@azaricstefan can you please share the full stack trace? I'm unable to reproduce this. |
Sure, @paras-malhotra. Message Here is the stack trace:
This command is linked to this exception in Telescope: This class SendExceptionNotificationToDevelopers.php takes exception details and send it via email.
I hope this helps in the investigation. |
@azaricstefan can you share what line 71 of |
Sure.
|
@azaricstefan, I am unable to reproduce this. I tried dispatching a job within the It would really help if you can create a reproducible exception on a fresh Laravel install and open a new issue for that. |
Ok, I will try to reproduce it on a clean Laravel project. |
Motivation
Re-attempt of #999 without a separate tab or watcher.
This PR adds the ability to record model hydrations within the Model Watcher (without a separate tab or watcher). This would help to know how many models are being hydrated for a request - something that can have a significant on performance / memory usage. Inspired from a similar popular feature of Debugbar: barryvdh/laravel-debugbar#947.
There are no breaking changes with this PR. To enable recording of model hydrations, we would need to enable the
hydrations
flag in theconfig/telescope.php
file like so:Index Screen (The retrieved is the one for model hydrations)
Preview Screen
Related Entries
Note
This PR would need a re-build and I haven't committed the compiled files (just the source) as per the contribution guidelines.