-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e947d8
commit 370acc1
Showing
60 changed files
with
2,393 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Sentry.Extensibility; | ||
|
||
/// <summary> | ||
/// Process a SentryEvent during the prepare phase. | ||
/// </summary> | ||
public interface ISentryEventProcessorWithHint: ISentryEventProcessor | ||
{ | ||
/// <summary> | ||
/// Process the <see cref="SentryEvent"/> | ||
/// </summary> | ||
/// <param name="event">The event to process</param> | ||
/// <param name="hint">A <see cref="Hint"/> with context that may be useful prior to sending the event</param> | ||
/// <return>The processed event or <c>null</c> if the event was dropped.</return> | ||
/// <remarks> | ||
/// The event returned can be the same instance received or a new one. | ||
/// Returning null will stop the processing pipeline so that the event will neither be processed by | ||
/// additional event processors or sent to Sentry. | ||
/// </remarks> | ||
SentryEvent? Process(SentryEvent @event, Hint hint); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Sentry/Extensibility/ISentryTransactionProcessorWithHint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Sentry.Extensibility; | ||
|
||
/// <summary> | ||
/// Process a <see cref="Transaction"/> during the prepare phase. | ||
/// </summary> | ||
public interface ISentryTransactionProcessorWithHint: ISentryTransactionProcessor | ||
{ | ||
/// <summary> | ||
/// Process the <see cref="Transaction"/> | ||
/// </summary> | ||
/// <param name="transaction">The Transaction to process</param> | ||
/// <param name="hint">A <see cref="Hint"/> with context that may be useful prior to sending the transaction</param> | ||
/// <remarks> | ||
/// The transaction returned can be the same instance received or a new one. | ||
/// Returning null will stop the processing pipeline. | ||
/// Meaning the transaction should no longer be processed nor send. | ||
/// </remarks> | ||
Transaction? Process(Transaction transaction, Hint hint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
namespace Sentry; | ||
|
||
/// <summary> | ||
/// A hint that can be provided when capturing a <see cref="SentryEvent"/> or when adding a <see cref="Breadcrumb"/>. | ||
/// Hints can be used to filter or modify events, transactions, or breadcrumbs before they are sent to Sentry. | ||
/// </summary> | ||
public class Hint | ||
{ | ||
private readonly List<Attachment> _attachments = new(); | ||
private readonly Dictionary<string, object?> _items = new(); | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="Hint"/>. | ||
/// </summary> | ||
public Hint() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new hint containing a single item. | ||
/// </summary> | ||
/// <param name="key">The key of the hint item.</param> | ||
/// <param name="value">The value of the hint item.</param> | ||
public Hint(string key, object? value) | ||
: this() | ||
{ | ||
_items[key] = value; | ||
} | ||
|
||
/// <summary> | ||
/// The Java SDK has some logic so that certain Hint types do not copy attachments from the Scope. | ||
/// This provides a location that allows us to do the same in the .NET SDK in the future. | ||
/// </summary> | ||
/// <param name="scope">The <see cref="Scope"/> that the attachments should be copied from</param> | ||
internal void AddAttachmentsFromScope(Scope scope) => _attachments.AddRange(scope.Attachments); | ||
|
||
/// <summary> | ||
/// Attachments added to the Hint. | ||
/// </summary> | ||
/// <remarks> | ||
/// This collection represents all of the attachments that will be sent to Sentry with the corresponding event. | ||
/// You can add or remove attachments from this collection as needed. | ||
/// </remarks> | ||
public ICollection<Attachment> Attachments => _attachments; | ||
|
||
/// <summary> | ||
/// A dictionary of arbitrary items provided with the Hint. | ||
/// </summary> | ||
/// <remarks> | ||
/// These are not sent to Sentry, but rather they are available during processing, such as when using | ||
/// BeforeSend and others. | ||
/// </remarks> | ||
public IDictionary<string, object?> Items => _items; | ||
|
||
/// <summary> | ||
/// Creates a new Hint with one or more attachments. | ||
/// </summary> | ||
/// <param name="attachments">The attachment(s) to add.</param> | ||
/// <returns>A Hint having the attachment(s).</returns> | ||
public static Hint WithAttachments(params Attachment[] attachments) => WithAttachments(attachments.AsEnumerable()); | ||
|
||
/// <summary> | ||
/// Creates a new Hint with attachments. | ||
/// </summary> | ||
/// <param name="attachments">The attachments to add.</param> | ||
/// <returns>A Hint having the attachments.</returns> | ||
public static Hint WithAttachments(IEnumerable<Attachment> attachments) | ||
{ | ||
var hint = new Hint(); | ||
hint._attachments.AddRange(attachments); | ||
return hint; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Sentry; | ||
|
||
/// <summary> | ||
/// Constants used to name Hints generated by the Sentry SDK | ||
/// </summary> | ||
public static class HintTypes | ||
{ | ||
/// <summary> | ||
/// Used for HttpResponseMessage hints | ||
/// </summary> | ||
public const string HttpResponseMessage = "http-response-message"; | ||
} |
Oops, something went wrong.