From f395117885546464abe7be35650fbf8a7a4a7b0c Mon Sep 17 00:00:00 2001 From: Qstick Date: Thu, 26 Sep 2019 21:41:52 -0400 Subject: [PATCH] Fixed: More Sentry Filtering --- .../Extensions/LoggerExtensions.cs | 1 - .../Instrumentation/InitializeLogger.cs | 2 +- .../Instrumentation/NzbDroneLogger.cs | 3 ++- .../Instrumentation/Sentry/SentryTarget.cs | 22 +++++++++++++++++++ src/NzbDrone.Common/Radarr.Common.csproj | 3 +++ .../DecisionEngine/DownloadDecisionMaker.cs | 4 ++-- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Common/Instrumentation/Extensions/LoggerExtensions.cs b/src/NzbDrone.Common/Instrumentation/Extensions/LoggerExtensions.cs index ca62cb9f0..0f4773bd3 100644 --- a/src/NzbDrone.Common/Instrumentation/Extensions/LoggerExtensions.cs +++ b/src/NzbDrone.Common/Instrumentation/Extensions/LoggerExtensions.cs @@ -1,5 +1,4 @@ using NLog; -using NLog.Fluent; namespace NzbDrone.Common.Instrumentation.Extensions { diff --git a/src/NzbDrone.Common/Instrumentation/InitializeLogger.cs b/src/NzbDrone.Common/Instrumentation/InitializeLogger.cs index e962f5dbb..aa7696204 100644 --- a/src/NzbDrone.Common/Instrumentation/InitializeLogger.cs +++ b/src/NzbDrone.Common/Instrumentation/InitializeLogger.cs @@ -25,4 +25,4 @@ public void Initialize() } } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs index ef0fdd8f9..934d79b24 100644 --- a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs +++ b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs @@ -62,6 +62,7 @@ public static void Register(IStartupContext startupContext, bool updateApp, bool private static void RegisterSentry(bool updateClient) { + string dsn; if (updateClient) @@ -82,7 +83,7 @@ private static void RegisterSentry(bool updateClient) Layout = "${message}" }; - var loggingRule = new LoggingRule("*", updateClient ? LogLevel.Trace : LogLevel.Warn, target); + var loggingRule = new LoggingRule("*", updateClient ? LogLevel.Trace : LogLevel.Debug, target); LogManager.Configuration.AddTarget("sentryTarget", target); LogManager.Configuration.LoggingRules.Add(loggingRule); diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs index 47085e41f..15b2956c9 100644 --- a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs +++ b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs @@ -4,6 +4,7 @@ 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 FilteredSQLiteErrors = new HashSet { + 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 FilteredExceptionTypeNames = new HashSet { @@ -218,6 +234,12 @@ public bool IsSentryMessage(LogEventInfo logEvent) { 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; diff --git a/src/NzbDrone.Common/Radarr.Common.csproj b/src/NzbDrone.Common/Radarr.Common.csproj index e5b932a32..f206c8d45 100644 --- a/src/NzbDrone.Common/Radarr.Common.csproj +++ b/src/NzbDrone.Common/Radarr.Common.csproj @@ -13,6 +13,9 @@ + + ..\Libraries\Sqlite\System.Data.SQLite.dll + diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 57b5dce09..cf82d886f 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -208,8 +208,8 @@ private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteMovie re { e.Data.Add("report", remoteMovie.Release.ToJson()); e.Data.Add("parsed", remoteMovie.ParsedMovieInfo.ToJson()); - _logger.Error(e, "Couldn't evaluate decision on " + remoteMovie.Release.Title + ", with spec: " + spec.GetType().Name); - return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message));//TODO UPDATE SPECS! + _logger.Error(e, "Couldn't evaluate decision on {0}, with spec: {1}", remoteMovie.Release.Title, spec.GetType().Name); + return new Rejection($"{spec.GetType().Name}: {e.Message}"); } return null;