parent
cd7e208efa
commit
0bdc137093
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<string, string> 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<string, string> tags = null, string[] fingerprint = null, object extra = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue