mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-25 23:55:56 +03:00
[GH-ISSUE #1208] RavenHandler: check if exception capturing succeeded, and send a normal message if it has not #503
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#503
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zerkms on GitHub (Oct 25, 2018).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1208
At the moment the
RavenHandlercapturing messages is implemented like this:basically, if it's an exception - try to capture it, otherwise capture it as a message.
So far so good.
Sentry API accepts data json-encoded, so sentry client JSON-encodes everything that is to be sent.
A serialised exception contains the complete stack trace including arguments.
The problem is that those arguments sometimes are strings with binary data, which is more often than not is not valid UTF8, hence cannot be json-encoded.
If you open the official sentry client you'd find this line somewhere near
Client.php:1047If
$datais exception details, then it would simply returnfalseand set$this->_lasterroras something likemalformed utf-8.Then the data is attempted to be sent with
$this->send_remote($this->server, $message, $headers);few lines below it.There is unfortunately no way to detect if the
SentryClient::send_remotecompleted unsuccessfully due to how they designed their API.But in the monolog
RavenHandlerwe could at least try our best, and here is how:If right before
$this->ravenClient->captureException($record['context']['exception'], $options);weand then after
$this->ravenClient->captureException(...)checkwe then are 100% confident the data for some reason was not successfully sent.
What I propose is that - in case if it was not sent, we would run
as a fallback.
Incomplete error (just a message won't contain the stack trace) is still better than no error, since at least you're informed. Additionally we could add something like
[extras][monolog] = Could not serialise exception, an incomplete error.But at least it would be something.
Thoughts?
@Seldaek commented on GitHub (Nov 4, 2018):
Sounds good to me. More reliability is definitely good. Missing exceptions entirely sucks.
@zerkms commented on GitHub (Nov 4, 2018):
Awesome, I will allocate some time to prototype it after I return from a parental leave
@zerkms commented on GitHub (Nov 15, 2018):
I have found that there might be a better solution, using a concept of raven message processors:
I will send a suggestion to the
raven-phpproject a bit later, but at the moment I think this solution is much more clear than what I initially suggested here above.