Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Add support for fingerprinting
Browse files Browse the repository at this point in the history
Fixes GH-72
  • Loading branch information
mattrobenolt committed Oct 9, 2015
1 parent 54d15f0 commit dac96ee
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/app/SharpRaven/Data/JsonPacket.cs
Expand Up @@ -254,6 +254,12 @@ private JsonPacket()
[JsonProperty(PropertyName = "release", NullValueHandling = NullValueHandling.Ignore)]
public string Release { get; set; }

/// <summary>
/// Gets or sets the fingerprint used for custom grouping
/// </summary>
[JsonProperty(PropertyName = "fingerprint", NullValueHandling = NullValueHandling.Ignore)]
public List<string> Fingerprint { get; set; }

/// <summary>
/// A map or list of tags for this event.
/// </summary>
Expand Down
16 changes: 10 additions & 6 deletions src/app/SharpRaven/Data/JsonPacketFactory.cs
Expand Up @@ -2,21 +2,21 @@

// Copyright (c) 2014 The Sentry Team and individual contributors.
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
//
// 3. Neither the name of the Sentry nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
Expand Down Expand Up @@ -56,6 +56,7 @@ public class JsonPacketFactory : IJsonPacketFactory
SentryMessage message,
ErrorLevel level = ErrorLevel.Info,
IDictionary<string, string> tags = null,
List<string> fingerprint = null,
object extra = null)
{
var json = new JsonPacket(project)
Expand All @@ -64,6 +65,7 @@ public class JsonPacketFactory : IJsonPacketFactory
MessageObject = message,
Level = level,
Tags = tags,
Fingerprint = fingerprint,
Extra = extra
};

Expand Down Expand Up @@ -96,6 +98,7 @@ public class JsonPacketFactory : IJsonPacketFactory
SentryMessage message = null,
ErrorLevel level = ErrorLevel.Error,
IDictionary<string, string> tags = null,
List<string> fingerprint = null,
object extra = null)
{
var json = new JsonPacket(project, exception)
Expand All @@ -104,6 +107,7 @@ public class JsonPacketFactory : IJsonPacketFactory
MessageObject = message,
Level = level,
Tags = tags,
Fingerprint = fingerprint,
Extra = extra
};

Expand All @@ -124,4 +128,4 @@ protected virtual JsonPacket OnCreate(JsonPacket jsonPacket)
return jsonPacket;
}
}
}
}
26 changes: 18 additions & 8 deletions src/app/SharpRaven/RavenClient.cs
Expand Up @@ -2,21 +2,21 @@

// Copyright (c) 2014 The Sentry Team and individual contributors.
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
//
// 3. Neither the name of the Sentry nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
Expand Down Expand Up @@ -101,7 +101,7 @@ public Dsn CurrentDsn
}

/// <summary>
/// Interface for providing a 'log scrubber' that removes
/// Interface for providing a 'log scrubber' that removes
/// sensitive information from exceptions sent to sentry.
/// </summary>
public IScrubber LogScrubber { get; set; }
Expand Down Expand Up @@ -138,6 +138,7 @@ public Dsn CurrentDsn
/// <param name="message">The optional messge to capture. Default: <see cref="Exception.Message" />.</param>
/// <param name="level">The <see cref="ErrorLevel" /> of the captured <paramref name="exception" />. Default: <see cref="ErrorLevel.Error" />.</param>
/// <param name="tags">The tags to annotate the captured <paramref name="exception" /> with.</param>
/// <param name="fingerprint">The custom fingerprint to annotate the captured <paramref name="message" /> with.</param>
/// <param name="extra">The extra metadata to send with the captured <paramref name="exception" />.</param>
/// <returns>
/// The <see cref="JsonPacket.EventID" /> of the successfully captured <paramref name="exception" />, or <c>null</c> if it fails.
Expand All @@ -146,6 +147,7 @@ public Dsn CurrentDsn
SentryMessage message = null,
ErrorLevel level = ErrorLevel.Error,
IDictionary<string, string> tags = null,
List<string> fingerprint = null,
object extra = null)
{
try
Expand All @@ -155,6 +157,7 @@ public Dsn CurrentDsn
message,
level,
tags,
fingerprint,
extra);
return Send(packet, CurrentDsn);
}
Expand All @@ -171,18 +174,25 @@ public Dsn CurrentDsn
/// <param name="message">The message to capture.</param>
/// <param name="level">The <see cref="ErrorLevel" /> of the captured <paramref name="message" />. Default <see cref="ErrorLevel.Info" />.</param>
/// <param name="tags">The tags to annotate the captured <paramref name="message" /> with.</param>
/// <param name="fingerprint">The custom fingerprint to annotate the captured <paramref name="message" /> with.</param>
/// <param name="extra">The extra metadata to send with the captured <paramref name="message" />.</param>
/// <returns>
/// The <see cref="JsonPacket.EventID" /> of the successfully captured <paramref name="message" />, or <c>null</c> if it fails.
/// </returns>
public string CaptureMessage(SentryMessage message,
ErrorLevel level = ErrorLevel.Info,
Dictionary<string, string> tags = null,
List<string> fingerprint = null,
object extra = null)
{
try
{
JsonPacket packet = this.jsonPacketFactory.Create(CurrentDsn.ProjectID, message, level, tags, extra);
JsonPacket packet = this.jsonPacketFactory.Create(CurrentDsn.ProjectID,
message,
level,
tags,
fingerprint,
extra);
return Send(packet, CurrentDsn);
}
catch (Exception sendException)
Expand Down Expand Up @@ -331,4 +341,4 @@ public string CaptureEvent(Exception e, Dictionary<string, string> tags)

#endregion
}
}
}

0 comments on commit dac96ee

Please sign in to comment.