mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-17 10:45:49 +02:00
Sentry will now back-off if it's API key is revoked.
This commit is contained in:
parent
0bdc137093
commit
ed2e4d0f1d
@ -99,7 +99,7 @@ private static void RegisterSentry(bool updateClient)
|
||||
else
|
||||
{
|
||||
dsn = RuntimeInfo.IsProduction
|
||||
? "https://fed3f47e8bea4527831e96edfa02d495:8ed11e4878614d8e87b1e1b15d890dc9@sentry.sonarr.tv/8"
|
||||
? "https://3e8a38b1a4df4de8b0453a724f5a1139:5a708dd75c724b32ae5128b6a895650f@sentry.sonarr.tv/8"
|
||||
: "https://4ee3580e01d8407c96a7430fbc953512:5f2d07227a0b4fde99dea07041a3ff93@sentry.sonarr.tv/10";
|
||||
}
|
||||
|
||||
|
@ -29,5 +29,10 @@ public bool Allowed(IEnumerable<string> fingerPrint)
|
||||
_cache.Set(key, true, _ttl);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using NLog.Common;
|
||||
@ -27,6 +28,8 @@ public class SentryTarget : TargetWithLayout
|
||||
};
|
||||
|
||||
private readonly SentryDebounce _debounce;
|
||||
private bool _unauthorized;
|
||||
|
||||
|
||||
public SentryTarget(string dsn)
|
||||
{
|
||||
@ -37,6 +40,8 @@ public SentryTarget(string dsn)
|
||||
Release = BuildInfo.Release
|
||||
};
|
||||
|
||||
_client.ErrorOnCapture = OnError;
|
||||
|
||||
_client.Tags.Add("osfamily", OsInfo.Os.ToString());
|
||||
_client.Tags.Add("runtime", PlatformInfo.Platform.ToString().ToLower());
|
||||
_client.Tags.Add("culture", Thread.CurrentThread.CurrentCulture.Name);
|
||||
@ -46,6 +51,24 @@ public SentryTarget(string dsn)
|
||||
_debounce = new SentryDebounce();
|
||||
}
|
||||
|
||||
private void OnError(Exception ex)
|
||||
{
|
||||
var webException = ex as WebException;
|
||||
|
||||
if (webException != null)
|
||||
{
|
||||
var response = webException.Response as HttpWebResponse;
|
||||
var statusCode = response?.StatusCode;
|
||||
if (statusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
_unauthorized = true;
|
||||
_debounce.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
InternalLogger.Error(ex, "Unable to send error to Sentry");
|
||||
}
|
||||
|
||||
private static List<string> GetFingerPrint(LogEventInfo logEvent)
|
||||
{
|
||||
var fingerPrint = new List<string>
|
||||
@ -77,7 +100,7 @@ protected override void Write(LogEventInfo logEvent)
|
||||
try
|
||||
{
|
||||
// don't report non-critical events without exceptions
|
||||
if (logEvent.Exception == null)
|
||||
if (logEvent.Exception == null || _unauthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -121,7 +144,7 @@ protected override void Write(LogEventInfo logEvent)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
InternalLogger.Error(e, "Unable to send Sentry request");
|
||||
OnError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user