|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Data.SQLite;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NLog.Common;
|
|
|
|
|
using NLog.Targets;
|
|
|
|
@ -17,6 +18,21 @@ namespace NzbDrone.Common.Instrumentation.Sentry
|
|
|
|
|
[Target("Sentry")]
|
|
|
|
|
public class SentryTarget : TargetWithLayout
|
|
|
|
|
{
|
|
|
|
|
// don't report uninformative SQLite exceptions
|
|
|
|
|
// busy/locked are benign https://forums.sonarr.tv/t/owin-sqlite-error-5-database-is-locked/5423/11
|
|
|
|
|
// The others will be user configuration problems and silt up Sentry
|
|
|
|
|
private static readonly HashSet<SQLiteErrorCode> FilteredSQLiteErrors = new HashSet<SQLiteErrorCode> {
|
|
|
|
|
SQLiteErrorCode.Busy,
|
|
|
|
|
SQLiteErrorCode.Locked,
|
|
|
|
|
SQLiteErrorCode.Perm,
|
|
|
|
|
SQLiteErrorCode.ReadOnly,
|
|
|
|
|
SQLiteErrorCode.IoErr,
|
|
|
|
|
SQLiteErrorCode.Corrupt,
|
|
|
|
|
SQLiteErrorCode.Full,
|
|
|
|
|
SQLiteErrorCode.CantOpen,
|
|
|
|
|
SQLiteErrorCode.Auth
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// use string and not Type so we don't need a reference to the project
|
|
|
|
|
// where these are defined
|
|
|
|
|
private static readonly HashSet<string> FilteredExceptionTypeNames = new HashSet<string> {
|
|
|
|
@ -218,6 +234,12 @@ namespace NzbDrone.Common.Instrumentation.Sentry
|
|
|
|
|
{
|
|
|
|
|
if (FilterEvents)
|
|
|
|
|
{
|
|
|
|
|
var sqlEx = logEvent.Exception as SQLiteException;
|
|
|
|
|
if (sqlEx != null && FilteredSQLiteErrors.Contains(sqlEx.ResultCode))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (FilteredExceptionTypeNames.Contains(logEvent.Exception.GetType().Name))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|