phptek / silverstripe-sentry

Flexible Sentry compatible bug aggregation client for Silverstripe applications.
BSD 3-Clause "New" or "Revised" License
12 stars 22 forks source link

Configure event filtering #41

Open phptek opened 4 years ago

phptek commented 4 years ago

Sometimes Sentry itself will become flooded with messages caused by the same underlying issue, which for - reasons - can take some time to resolve. Due to the way Sentry itself works, a slight change in the data payload and it thinks a particular error is completely new - even though as humans we can see it's almost exactly the same as any number of previous ones.

Therefore it would be useful to be able to add a one-line change to a file and have the Sentry SDK ignore messages that match these criteria, by hooking into the `before_send' event config option. See here: https://docs.sentry.io/error-reporting/configuration/filtering/?platform=php.

This could be done using YML as per the below, but it would require a commit+push+deployment to achieve. Instead, a suitable fix for this issue could take an uploaded file via a dedicated tab in the admin UI lavelled "Sentry" with an UploadField so that config could simply be uploaded to the F/S. Alternatively, a separate DataObject subclass could perform the same job - although we're moving away from Sentry itself being the sole arbiter of configuration here.

Either way, the config would use a regular expression to match for incoming data against a given field e.g. the "title":

PhpTek\Sentry\Log\SentryLogger:
  filter:
    title: "WARNING: E_WARNING: chdir(): Permission denied (errno 13"

The above config would instruct the module to return null which means the Sentry SDK will ignore the message.

If going with the upload-able config,