diff --git a/appveyor-package.sh b/appveyor-package.sh index 406529733..57c61c63e 100755 --- a/appveyor-package.sh +++ b/appveyor-package.sh @@ -35,7 +35,7 @@ PublishSourceMaps() yarn sentry-cli releases new --finalize -p lidarr -p lidarr-ui -p lidarr-update "${APPVEYOR_BUILD_VERSION}-debug" yarn sentry-cli releases -p lidarr-ui files "${APPVEYOR_BUILD_VERSION}-debug" upload-sourcemaps _output/UI/ --rewrite yarn sentry-cli releases set-commits --auto "${APPVEYOR_BUILD_VERSION}-debug" - yarn sentry-cli releases deploys "${APPVEYOR_BUILD_VERSION}-debug" new -e production + yarn sentry-cli releases deploys "${APPVEYOR_BUILD_VERSION}-debug" new -e nightly fi } diff --git a/frontend/src/Store/Middleware/createSentryMiddleware.js b/frontend/src/Store/Middleware/createSentryMiddleware.js index 41109a0c7..27c8b5911 100644 --- a/frontend/src/Store/Middleware/createSentryMiddleware.js +++ b/frontend/src/Store/Middleware/createSentryMiddleware.js @@ -76,15 +76,15 @@ export default function createSentryMiddleware() { sentry.init({ dsn, - environment: isProduction ? 'production' : 'development', + environment: branch, release, sendDefaultPii: true, beforeSend: cleanseData }); sentry.configureScope((scope) => { - scope.setTag('branch', branch); scope.setTag('version', version); + scope.setTag('production', isProduction); }); return createMiddleware(); diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs index 02d226ad7..c6d861d4f 100644 --- a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs +++ b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs @@ -84,6 +84,9 @@ namespace NzbDrone.Common.Instrumentation.Sentry private bool _unauthorized; public bool FilterEvents { get; set; } + public string UpdateBranch { get; set; } + public Version DatabaseVersion { get; set; } + public int DatabaseMigration { get; set; } public SentryTarget(string dsn) { @@ -95,7 +98,6 @@ namespace NzbDrone.Common.Instrumentation.Sentry o.SendDefaultPii = true; o.Debug = false; o.DiagnosticsLevel = SentryLevel.Debug; - o.Environment = RuntimeInfo.IsProduction ? "production" : "development"; o.Release = BuildInfo.Release; o.BeforeSend = x => SentryCleanser.CleanseEvent(x); o.BeforeBreadcrumb = x => SentryCleanser.CleanseBreadcrumb(x); @@ -112,6 +114,7 @@ namespace NzbDrone.Common.Instrumentation.Sentry scope.SetTag("culture", Thread.CurrentThread.CurrentCulture.Name); scope.SetTag("branch", BuildInfo.Branch); scope.SetTag("version", BuildInfo.Version.ToString()); + scope.SetTag("production", RuntimeInfo.IsProduction.ToString()); }); _debounce = new SentryDebounce(); @@ -247,6 +250,7 @@ namespace NzbDrone.Common.Instrumentation.Sentry Level = LoggingLevelMap[logEvent.Level], Logger = logEvent.LoggerName, Message = logEvent.FormattedMessage, + Environment = UpdateBranch }; sentryEvent.SetExtras(extras); @@ -261,6 +265,8 @@ namespace NzbDrone.Common.Instrumentation.Sentry sentryEvent.SetTag("os_name", osName); sentryEvent.SetTag("os_version", $"{osName} {osVersion}"); sentryEvent.SetTag("runtime_version", $"{PlatformInfo.PlatformName} {runTimeVersion}"); + sentryEvent.SetTag("sqlite_version", $"{DatabaseVersion}"); + sentryEvent.SetTag("database_migration", $"{DatabaseMigration}"); SentrySdk.CaptureEvent(sentryEvent); } diff --git a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs index e4cd4c927..9c99dfb02 100644 --- a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs +++ b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs @@ -3,7 +3,6 @@ using System.Linq; using NLog; using NLog.Config; using NzbDrone.Common.Extensions; -using NzbDrone.Common.Instrumentation.Sentry; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Messaging.Events; @@ -41,9 +40,6 @@ namespace NzbDrone.Core.Instrumentation SetMinimumLogLevel(rules, "appFileDebug", minimumLogLevel <= LogLevel.Debug ? LogLevel.Debug : LogLevel.Off); SetMinimumLogLevel(rules, "appFileTrace", minimumLogLevel <= LogLevel.Trace ? LogLevel.Trace : LogLevel.Off); - // Sentry filtering - LogManager.Configuration.FindTargetByName("sentryTarget").FilterEvents = _configFileProvider.FilterSentryEvents; - LogManager.ReconfigExistingLoggers(); } diff --git a/src/NzbDrone.Core/Instrumentation/ReconfigureSentry.cs b/src/NzbDrone.Core/Instrumentation/ReconfigureSentry.cs new file mode 100644 index 000000000..1cd144ec0 --- /dev/null +++ b/src/NzbDrone.Core/Instrumentation/ReconfigureSentry.cs @@ -0,0 +1,39 @@ +using NLog; +using NzbDrone.Common.Instrumentation.Sentry; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Lifecycle; +using NzbDrone.Core.Messaging.Events; + +namespace NzbDrone.Core.Instrumentation +{ + public class ReconfigureSentry : IHandleAsync + { + private readonly IConfigFileProvider _configFileProvider; + private readonly IMainDatabase _database; + + public ReconfigureSentry(IConfigFileProvider configFileProvider, + IMainDatabase database) + { + _configFileProvider = configFileProvider; + _database = database; + } + + public void Reconfigure() + { + // Extended sentry config + var sentry = LogManager.Configuration.FindTargetByName("sentryTarget"); + sentry.FilterEvents = _configFileProvider.FilterSentryEvents; + sentry.UpdateBranch = _configFileProvider.Branch; + sentry.DatabaseVersion = _database.Version; + sentry.DatabaseMigration = _database.Migration; + + LogManager.ReconfigExistingLoggers(); + } + + public void HandleAsync(ApplicationStartedEvent message) + { + Reconfigure(); + } + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 944db1eaf..4e06cad20 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -705,6 +705,7 @@ +