diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/MachineNameUserFactory.cs b/src/NzbDrone.Common/Instrumentation/Sentry/MachineNameUserFactory.cs
new file mode 100644
index 000000000..b9c92c880
--- /dev/null
+++ b/src/NzbDrone.Common/Instrumentation/Sentry/MachineNameUserFactory.cs
@@ -0,0 +1,13 @@
+using System;
+using SharpRaven.Data;
+
+namespace NzbDrone.Common.Instrumentation.Sentry
+{
+ public class MachineNameUserFactory : ISentryUserFactory
+ {
+ public SentryUser Create()
+ {
+ return new SentryUser(Environment.MachineName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs
index a15ec5136..8e3f7b6f7 100644
--- a/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs
+++ b/src/NzbDrone.Common/Instrumentation/Sentry/SentryTarget.cs
@@ -11,23 +11,11 @@ using SharpRaven.Data;
namespace NzbDrone.Common.Instrumentation.Sentry
{
- public class SentryUserFactory : ISentryUserFactory
- {
- public SentryUser Create()
- {
- return new SentryUser((string)null);
- }
- }
-
-
[Target("Sentry")]
public class SentryTarget : TargetWithLayout
{
private readonly RavenClient _client;
- ///
- /// Map of NLog log levels to Raven/Sentry log levels
- ///
private static readonly IDictionary LoggingLevelMap = new Dictionary
{
{LogLevel.Debug, ErrorLevel.Debug},
@@ -42,7 +30,7 @@ namespace NzbDrone.Common.Instrumentation.Sentry
public SentryTarget(string dsn)
{
- _client = new RavenClient(new Dsn(dsn), new JsonPacketFactory(), new SentryRequestFactory(), new SentryUserFactory())
+ _client = new RavenClient(new Dsn(dsn), new SonarrJsonPacketFactory(), new SentryRequestFactory(), new MachineNameUserFactory())
{
Compression = true,
Environment = RuntimeInfo.IsProduction ? "production" : "development",
@@ -103,7 +91,9 @@ namespace NzbDrone.Common.Instrumentation.Sentry
var extras = logEvent.Properties.ToDictionary(x => x.Key.ToString(), x => x.Value.ToString());
_client.Logger = logEvent.LoggerName;
- var sentryMessage = new SentryMessage(Layout.Render(logEvent));
+
+ var sentryMessage = new SentryMessage(logEvent.Message, logEvent.Parameters);
+
var sentryEvent = new SentryEvent(logEvent.Exception)
{
Level = LoggingLevelMap[logEvent.Level],
diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/SonarrJsonPacketFactory.cs b/src/NzbDrone.Common/Instrumentation/Sentry/SonarrJsonPacketFactory.cs
new file mode 100644
index 000000000..fb639fb2f
--- /dev/null
+++ b/src/NzbDrone.Common/Instrumentation/Sentry/SonarrJsonPacketFactory.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using SharpRaven.Data;
+
+namespace NzbDrone.Common.Instrumentation.Sentry
+{
+ public class SonarrJsonPacketFactory : IJsonPacketFactory
+ {
+ private static string ShortenPath(string path)
+ {
+
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ return null;
+ }
+
+ var index = path.IndexOf("\\src\\", StringComparison.Ordinal);
+
+ if (index <= 0)
+ {
+ return path;
+ }
+
+ return path.Substring(index + "\\src".Length);
+ }
+
+ public JsonPacket Create(string project, SentryEvent @event)
+ {
+ var packet = new SonarrSentryPacket(project, @event);
+
+ try
+ {
+ foreach (var exception in packet.Exceptions)
+ {
+ foreach (var frame in exception.Stacktrace.Frames)
+ {
+ frame.Filename = ShortenPath(frame.Filename);
+ }
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+
+ return packet;
+ }
+
+
+ [Obsolete]
+ public JsonPacket Create(string project, SentryMessage message, ErrorLevel level = ErrorLevel.Info, IDictionary tags = null,
+ string[] fingerprint = null, object extra = null)
+ {
+ throw new NotImplementedException();
+ }
+
+ [Obsolete]
+ public JsonPacket Create(string project, Exception exception, SentryMessage message = null, ErrorLevel level = ErrorLevel.Error,
+ IDictionary tags = null, string[] fingerprint = null, object extra = null)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/Instrumentation/Sentry/SonarrSentryPacket.cs b/src/NzbDrone.Common/Instrumentation/Sentry/SonarrSentryPacket.cs
new file mode 100644
index 000000000..8dbfba818
--- /dev/null
+++ b/src/NzbDrone.Common/Instrumentation/Sentry/SonarrSentryPacket.cs
@@ -0,0 +1,29 @@
+using Newtonsoft.Json;
+using SharpRaven.Data;
+
+namespace NzbDrone.Common.Instrumentation.Sentry
+{
+ public class SonarrSentryPacket : JsonPacket
+ {
+ private readonly JsonSerializerSettings _setting;
+
+ public SonarrSentryPacket(string project, SentryEvent @event) :
+ base(project, @event)
+ {
+ _setting = new JsonSerializerSettings
+ {
+ DefaultValueHandling = DefaultValueHandling.Ignore
+ };
+ }
+
+ public override string ToString(Formatting formatting)
+ {
+ return JsonConvert.SerializeObject(this, formatting, _setting);
+ }
+
+ public override string ToString()
+ {
+ return ToString(Formatting.None);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index 565e38036..4346a2610 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -184,6 +184,9 @@
+
+
+