mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using SharpRaven.Data;
|
|
|
|
namespace NzbDrone.Common.Instrumentation.Sentry
|
|
{
|
|
public class RadarrJsonPacketFactory : IJsonPacketFactory
|
|
{
|
|
private readonly SentryPacketCleanser _cleanser;
|
|
|
|
public RadarrJsonPacketFactory()
|
|
{
|
|
_cleanser = new SentryPacketCleanser();
|
|
}
|
|
|
|
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 RadarrSentryPacket(project, @event);
|
|
|
|
try
|
|
{
|
|
foreach (var exception in packet.Exceptions)
|
|
{
|
|
foreach (var frame in exception.Stacktrace.Frames)
|
|
{
|
|
frame.Filename = ShortenPath(frame.Filename);
|
|
}
|
|
}
|
|
|
|
_cleanser.CleansePacket(packet);
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
}
|