-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Additional data with Monolog #1014
Comments
Related to amphp/http-server#310. |
Changing the handler was previously shot down due (and explained) in #844 & #848; TL;DR, we cannot assume what's inside Monolog context, so extracting info bu default could lead to unwanted stuff. There's also https://github.com/B-Galati/monolog-sentry-handler that could help you in getting more information from Monolog. Our handler is final, but you can surely use nested handler to avoid rewriting it. |
I don't see how in this case. |
In the same way that special handler do, decorating the original handler: https://seldaek.github.io/monolog/doc/02-handlers-formatters-processors.html#wrappers--special-handlers |
I managed to get the data through the existing Handler by implementing namespace App\Library\Monolog;
use Monolog\Processor\ProcessorInterface;
final class RequestExtraProcessor implements ProcessorInterface
{
public function __invoke(array $record): array
{
if (array_key_exists('request', $record['context'])) {
$record['context']['extra']['request'] = $record['context']['request'];
}
return $record;
}
} |
For completion; As far as I understand, the solution of registering a monolog processor described in #1014 (comment) does not work with new versions of this bundle, because the sentry-php/src/Monolog/Handler.php Lines 44 to 66 in fafef24
If you want to do this with new versions of this bundle, you need to decorate the monolog handler (or register your own handler) like described in #848 (comment). |
Some of my calls to Monolog contain additional data in the
$context
array. I need to get some of these data into the\Sentry\Event
object. I want to use an event processor for that since it gets both the Event instance and the original$payload
array (see #1010).The issue is that the data I need don't make it into the
$payload
array at the moment. The Monolog Handler only copies the exception but the rest of$record['context']
is thrown away:sentry-php/src/Monolog/Handler.php
Lines 53 to 55 in 97bbca2
Do I have to write my own Monolog Handler for this or can we improve the existing one in this library to pass the data into the payload?
The text was updated successfully, but these errors were encountered: