Exceptions are now sent to exceptrack

pull/6/head
kay.one 13 years ago
parent 2b5776acbf
commit aff17f7767

@ -1,37 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace NzbDrone.Common.Contract
{
public class ExceptionReport : ReportBase
{
[JsonProperty("t")]
public string Type { get; set; }
[JsonProperty("l")]
public string Logger { get; set; }
[JsonProperty("lm")]
public string LogMessage { get; set; }
[JsonProperty("s")]
public string String { get; set; }
[JsonProperty("xmessage")]
public string ExceptionMessage { get; set; }
[JsonProperty("stk")]
public string Stack { get; set; }
protected override Dictionary<string, string> GetString()
{
var dic = new Dictionary<string, string>
{
{"ExType", Type.NullSafe()},
{"Logger", Logger.NullSafe()},
{"Message", LogMessage.NullSafe()},
{"Str", String.NullSafe()}
};
return dic;
}
}
}

@ -1,11 +0,0 @@
using System.Linq;
using Newtonsoft.Json;
namespace NzbDrone.Common.Contract
{
public class ExceptionReportResponse
{
[JsonProperty("h")]
public string ExceptionHash { get; set; }
}
}

@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace NzbDrone.Common.Contract
{
public class ExistingExceptionReport : ReportBase
{
[JsonProperty("h")]
public string Hash { get; set; }
[JsonProperty("lm")]
public string LogMessage { get; set; }
protected override Dictionary<string, string> GetString()
{
var dic = new Dictionary<string, string>
{
{"Message", LogMessage.NullSafe()}
};
return dic;
}
}
}

@ -57,13 +57,10 @@
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Contract\ExceptionReportResponse.cs" />
<Compile Include="Contract\ExistingExceptionReport.cs" />
<Compile Include="StringExtention.cs" /> <Compile Include="StringExtention.cs" />
<Compile Include="HttpProvider.cs" /> <Compile Include="HttpProvider.cs" />
<Compile Include="ConfigFileProvider.cs" /> <Compile Include="ConfigFileProvider.cs" />
<Compile Include="ConsoleProvider.cs" /> <Compile Include="ConsoleProvider.cs" />
<Compile Include="Contract\ExceptionReport.cs" />
<Compile Include="Contract\ReportBase.cs" /> <Compile Include="Contract\ReportBase.cs" />
<Compile Include="Contract\ParseErrorReport.cs" /> <Compile Include="Contract\ParseErrorReport.cs" />
<Compile Include="NlogTargets\RemoteTarget.cs" /> <Compile Include="NlogTargets\RemoteTarget.cs" />

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Exceptrack.Driver;
using NLog; using NLog;
using NzbDrone.Common.Contract; using NzbDrone.Common.Contract;
@ -15,8 +16,10 @@ namespace NzbDrone.Common
private const string EXCEPTION_URL = SERVICE_URL + "/ReportException"; private const string EXCEPTION_URL = SERVICE_URL + "/ReportException";
public static RestProvider RestProvider { get; set; } public static RestProvider RestProvider { get; set; }
private static readonly HashSet<string> parserErrorCache = new HashSet<string>(); public static ExceptionClient ExceptrackDriver { get; set; }
private static readonly HashSet<string> parserErrorCache = new HashSet<string>();
public static void ClearCache() public static void ClearCache()
{ {
@ -30,7 +33,7 @@ namespace NzbDrone.Common
{ {
try try
{ {
VerifyRestProvider(); VerifyDependencies();
lock (parserErrorCache) lock (parserErrorCache)
{ {
@ -58,16 +61,15 @@ namespace NzbDrone.Common
{ {
try try
{ {
VerifyRestProvider(); VerifyDependencies();
var report = new ExceptionReport(); var exceptionData = new ExceptionData();
report.LogMessage = logEvent.FormattedMessage;
report.Stack = logEvent.Exception.StackTrace;
report.ExceptionMessage = logEvent.Exception.Message;
report.Logger = logEvent.LoggerName;
report.Type = logEvent.Exception.GetType().FullName;
RestProvider.PostData(EXCEPTION_URL, report); exceptionData.Exception = logEvent.Exception;
exceptionData.Location = logEvent.LoggerName;
exceptionData.UserId = EnvironmentProvider.UGuid.ToString().Replace("-", string.Empty);
ExceptrackDriver.SubmitException(exceptionData);
} }
catch (Exception e) catch (Exception e)
{ {
@ -81,7 +83,16 @@ namespace NzbDrone.Common
} }
} }
private static void VerifyRestProvider()
public static void SetupExceptrackDriver()
{
ExceptrackDriver = new ExceptionClient(
"CB230C312E5C4FF38B4FB9644B05E60D",
new EnvironmentProvider().Version.ToString(),
new Uri("http://api.exceptrack.com/"));
}
private static void VerifyDependencies()
{ {
if (RestProvider == null) if (RestProvider == null)
{ {
@ -95,6 +106,19 @@ namespace NzbDrone.Common
throw new InvalidOperationException("REST Provider wasn't configured correctly."); throw new InvalidOperationException("REST Provider wasn't configured correctly.");
} }
} }
if (ExceptrackDriver == null)
{
if (EnvironmentProvider.IsProduction)
{
logger.Warn("Exceptrack Driver wasn't provided. creating new one!");
SetupExceptrackDriver();
}
else
{
throw new InvalidOperationException("Exceptrack Driver wasn't configured correctly.");
}
}
} }
} }
} }

@ -12,7 +12,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.7.0" newVersion="4.0.7.0" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>

@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.Integeration
[Test] [Test]
public void should_be_able_to_submit_exceptions() public void should_be_able_to_submit_exceptions()
{ {
ReportingService.RestProvider = new RestProvider(new EnvironmentProvider()); ReportingService.SetupExceptrackDriver();
var log = new LogEventInfo(); var log = new LogEventInfo();
log.LoggerName = "LoggerName.LoggerName.LoggerName.LoggerName"; log.LoggerName = "LoggerName.LoggerName.LoggerName.LoggerName";

@ -68,6 +68,7 @@ namespace NzbDrone.Core
{ {
EnvironmentProvider.UGuid = Kernel.Get<ConfigProvider>().UGuid; EnvironmentProvider.UGuid = Kernel.Get<ConfigProvider>().UGuid;
ReportingService.RestProvider = Kernel.Get<RestProvider>(); ReportingService.RestProvider = Kernel.Get<RestProvider>();
ReportingService.SetupExceptrackDriver();
var appId = AnalyticsProvider.DESKMETRICS_TEST_ID; var appId = AnalyticsProvider.DESKMETRICS_TEST_ID;

@ -128,6 +128,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.4.3.0\lib\net40\EntityFramework.dll</HintPath> <HintPath>..\packages\EntityFramework.4.3.0\lib\net40\EntityFramework.dll</HintPath>
</Reference> </Reference>
<Reference Include="Exceptrack.Driver">
<HintPath>..\packages\Exceptrack.Driver.0.1.0.2\lib\net20\Exceptrack.Driver.dll</HintPath>
</Reference>
<Reference Include="Growl.Connector"> <Reference Include="Growl.Connector">
<HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath> <HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
</Reference> </Reference>

@ -3,6 +3,7 @@
<package id="DotNetZip" version="1.9.1.8" /> <package id="DotNetZip" version="1.9.1.8" />
<package id="EntityFramework" version="4.3.0" /> <package id="EntityFramework" version="4.3.0" />
<package id="EntityFramework.SqlServerCompact" version="4.1.8482.2" /> <package id="EntityFramework.SqlServerCompact" version="4.1.8482.2" />
<package id="Exceptrack.Driver" version="0.1.0.2" />
<package id="Growl" version="0.6" /> <package id="Growl" version="0.6" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="1.9" /> <package id="MiniProfiler" version="1.9" />

@ -1,6 +1,5 @@
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Common.Contract;
namespace NzbDrone.Services.Service.Controllers namespace NzbDrone.Services.Service.Controllers
{ {
@ -8,13 +7,13 @@ namespace NzbDrone.Services.Service.Controllers
{ {
[HttpPost] [HttpPost]
public EmptyResult ReportExisting(ExistingExceptionReport existingExceptionReport) public EmptyResult ReportExisting()
{ {
return new EmptyResult(); return new EmptyResult();
} }
[HttpPost] [HttpPost]
public JsonResult ReportNew(ExceptionReport exceptionReport) public JsonResult ReportNew()
{ {
return new JsonResult(); return new JsonResult();
} }

@ -63,9 +63,9 @@ namespace NzbDrone.Services.Service.Controllers
} }
[HttpPost] [HttpPost]
public JsonResult ReportException(ExceptionReport exceptionReport) public JsonResult ReportException()
{ {
return _exceptionController.ReportNew(exceptionReport); return new JsonResult();
} }
} }
} }

@ -39,62 +39,6 @@ namespace NzbDrone.Services.Tests
}; };
} }
private static ExceptionReport CreateExceptionReport()
{
return new ExceptionReport
{
IsProduction = true,
Version = "1.1.2.323456",
UGuid = Guid.NewGuid(),
Logger = "NzbDrone.Logger.Name",
LogMessage = @"Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message",
String = @"Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message
Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message",
Type = typeof(InvalidOperationException).Name
};
}
[Test] [Test]
public void parse_report_should_be_saved() public void parse_report_should_be_saved()
{ {

@ -49,6 +49,8 @@ namespace NzbDrone.Test.Common
MockedRestProvider = new Mock<RestProvider>(); MockedRestProvider = new Mock<RestProvider>();
ReportingService.RestProvider = MockedRestProvider.Object; ReportingService.RestProvider = MockedRestProvider.Object;
ReportingService.SetupExceptrackDriver();
if (Directory.Exists(TempFolder)) if (Directory.Exists(TempFolder))
{ {

@ -62,6 +62,7 @@ namespace NzbDrone.Update
private static void InitLoggers() private static void InitLoggers()
{ {
ReportingService.RestProvider = _kernel.Get<RestProvider>(); ReportingService.RestProvider = _kernel.Get<RestProvider>();
ReportingService.SetupExceptrackDriver();
LogConfiguration.RegisterRemote(); LogConfiguration.RegisterRemote();

@ -3,8 +3,8 @@
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.6.0"/> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>

@ -46,6 +46,7 @@ namespace NzbDrone
var environmentProvider = _kernel.Get<EnvironmentProvider>(); var environmentProvider = _kernel.Get<EnvironmentProvider>();
ReportingService.RestProvider = _kernel.Get<RestProvider>(); ReportingService.RestProvider = _kernel.Get<RestProvider>();
ReportingService.SetupExceptrackDriver();
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info); LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug); LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);

Loading…
Cancel
Save