From 88dd5c226aee4caa93639b71cecdd02575d0d526 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 7 Nov 2024 13:46:41 +0200 Subject: [PATCH 1/2] UHF-10944: Add sentry logger back Raven [README.md](https://git.drupalcode.org/project/raven/-/blob/6.x/README.md?ref_type=heads) asks to disable `filter_backtrace` processor. However, it causes Monolog Lineformatter::format to consume excessive memory when processing log messages with long stack traces. Adding it don't seem to cause any problems, and the processors seem to use drastically less logger memory. --- src/HelfiApiBaseServiceProvider.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/HelfiApiBaseServiceProvider.php b/src/HelfiApiBaseServiceProvider.php index 8957b59..87c7761 100644 --- a/src/HelfiApiBaseServiceProvider.php +++ b/src/HelfiApiBaseServiceProvider.php @@ -33,6 +33,16 @@ public function register(ContainerBuilder $container) : void { $container->setParameter('monolog.channel_handlers', [ 'default' => [ 'handlers' => [ + [ + 'name' => 'drupal.raven', + 'processors' => [ + 'current_user', + 'request_uri', + 'ip', + 'referer', + 'filter_backtrace', + ], + ], [ 'name' => 'default_conditional_handler', 'formatter' => 'drush_or_json', From 540266bb11e8f6f0a7c9554d61f10ac1d3fb1f18 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Fri, 8 Nov 2024 10:19:07 +0200 Subject: [PATCH 2/2] Add comment to raven logger --- src/HelfiApiBaseServiceProvider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/HelfiApiBaseServiceProvider.php b/src/HelfiApiBaseServiceProvider.php index 87c7761..efeac30 100644 --- a/src/HelfiApiBaseServiceProvider.php +++ b/src/HelfiApiBaseServiceProvider.php @@ -34,6 +34,12 @@ public function register(ContainerBuilder $container) : void { 'default' => [ 'handlers' => [ [ + // The Raven logger handler must be added to forward log messages + // to Sentry. We remove the `message_placeholder` processor from + // the default processors, as Raven already handles placeholders. + // NOTE: The `filter_backtrace` processor should be included. + // Without it, logging long backtraces may lead to out-of-memory + // errors. 'name' => 'drupal.raven', 'processors' => [ 'current_user',