Skip to content

Commit

Permalink
Merge branch 'feat/4.0.0' into feat/4.0.0-throw-if-no-dsn-2494
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Sep 27, 2023
2 parents 69ebfa1 + 8084c05 commit 5a65707
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 211 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ without native/platform specific bindings and SDKs. See [this ticket for more de

API Changes:
- If `null` has been supplied as DSN when initializing Sentry, and ArgumentNullException is now thrown ([#2655](https://github.com/getsentry/sentry-dotnet/pull/2655))
- IHasBreadcrumbs was removed. Use IEventLike instead. ([#2670](https://github.com/getsentry/sentry-dotnet/pull/2670))
- ISpanContext was removed. Use ITraceContext instead. ([#2668](https://github.com/getsentry/sentry-dotnet/pull/2668))
- Removed IHasTransactionNameSource. Use ITransactionContext instead. ([#2654](https://github.com/getsentry/sentry-dotnet/pull/2654))
- Adding `Distribution` to `IEventLike` ([#2660](https://github.com/getsentry/sentry-dotnet/pull/2660))

### Features

Expand Down
114 changes: 113 additions & 1 deletion src/Sentry/IEventLike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ namespace Sentry;
/// <summary>
/// Models members common between types that represent event-like data.
/// </summary>
public interface IEventLike : IHasBreadcrumbs, IHasTags, IHasExtra
public interface IEventLike : IHasTags, IHasExtra
{
/// <summary>
/// A trail of events which happened prior to an issue.
/// </summary>
/// <seealso href="https://docs.sentry.io/platforms/dotnet/enriching-events/breadcrumbs/"/>
IReadOnlyCollection<Breadcrumb> Breadcrumbs { get; }

/// <summary>
/// Adds a breadcrumb.
/// </summary>
void AddBreadcrumb(Breadcrumb breadcrumb);

/// <summary>
/// The release distribution of the application.
/// </summary>
public string? Distribution { get; set; }

/// <summary>
/// Sentry level.
/// </summary>
Expand Down Expand Up @@ -91,6 +107,102 @@ public interface IEventLike : IHasBreadcrumbs, IHasTags, IHasExtra
[EditorBrowsable(EditorBrowsableState.Never)]
public static class EventLikeExtensions
{
#if !NETFRAMEWORK
/// <summary>
/// Adds a breadcrumb to the object.
/// </summary>
/// <param name="eventLike">The object.</param>
/// <param name="message">The message.</param>
/// <param name="category">The category.</param>
/// <param name="type">The type.</param>
/// <param name="dataPair">The data key-value pair.</param>
/// <param name="level">The level.</param>
public static void AddBreadcrumb(
this IEventLike eventLike,
string message,
string? category,
string? type,
(string, string)? dataPair = null,
BreadcrumbLevel level = default)
{
Dictionary<string, string>? data = null;

if (dataPair != null)
{
data = new Dictionary<string, string>
{
{dataPair.Value.Item1, dataPair.Value.Item2}
};
}

eventLike.AddBreadcrumb(
null,
message,
category,
type,
data,
level);
}
#endif

/// <summary>
/// Adds a breadcrumb to the object.
/// </summary>
/// <param name="eventLike">The object.</param>
/// <param name="message">The message.</param>
/// <param name="category">The category.</param>
/// <param name="type">The type.</param>
/// <param name="data">The data.</param>
/// <param name="level">The level.</param>
public static void AddBreadcrumb(
this IEventLike eventLike,
string message,
string? category = null,
string? type = null,
IReadOnlyDictionary<string, string>? data = null,
BreadcrumbLevel level = default)
{
eventLike.AddBreadcrumb(
null,
message,
category,
type,
data,
level);
}

/// <summary>
/// Adds a breadcrumb to the object.
/// </summary>
/// <remarks>
/// This overload is used for testing.
/// </remarks>
/// <param name="eventLike">The object.</param>
/// <param name="timestamp">The timestamp</param>
/// <param name="message">The message.</param>
/// <param name="category">The category.</param>
/// <param name="type">The type.</param>
/// <param name="data">The data</param>
/// <param name="level">The level.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void AddBreadcrumb(
this IEventLike eventLike,
DateTimeOffset? timestamp,
string message,
string? category = null,
string? type = null,
IReadOnlyDictionary<string, string>? data = null,
BreadcrumbLevel level = default)
{
eventLike.AddBreadcrumb(new Breadcrumb(
timestamp,
message,
type,
data,
category,
level));
}

/// <summary>
/// Whether a <see cref="User"/> has been set to the object with any of its fields non null.
/// </summary>
Expand Down
141 changes: 0 additions & 141 deletions src/Sentry/IHasBreadcrumbs.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Sentry/IHasTransactionNameSource.cs

This file was deleted.

10 changes: 0 additions & 10 deletions src/Sentry/ISpanContext.cs

This file was deleted.

4 changes: 3 additions & 1 deletion src/Sentry/ISpanData.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Sentry.Protocol;

namespace Sentry;

/// <summary>
/// Immutable data belonging to a span.
/// </summary>
public interface ISpanData : ISpanContext, IHasTags, IHasExtra
public interface ISpanData : ITraceContext, IHasTags, IHasExtra
{
/// <summary>
/// Start timestamp.
Expand Down
9 changes: 8 additions & 1 deletion src/Sentry/ITransactionContext.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Sentry.Protocol;

namespace Sentry;

/// <summary>
/// Transaction metadata.
/// </summary>
public interface ITransactionContext : ISpanContext
public interface ITransactionContext : ITraceContext
{
/// <summary>
/// Transaction name.
Expand All @@ -14,4 +16,9 @@ public interface ITransactionContext : ISpanContext
/// Whether the parent transaction of this transaction has been sampled.
/// </summary>
bool? IsParentSampled { get; }

/// <summary>
/// The source of the transaction name.
/// </summary>
TransactionNameSource NameSource { get; }
}
2 changes: 1 addition & 1 deletion src/Sentry/Internal/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void Apply(IEventLike eventLike)
eventLike.Release ??= _options.SettingLocator.GetRelease();

// Distribution
eventLike.WithDistribution(_ => _.Distribution ??= _options.Distribution);
eventLike.Distribution ??= _options.Distribution;

// Environment
eventLike.Environment ??= _options.SettingLocator.GetEnvironment();
Expand Down
26 changes: 0 additions & 26 deletions src/Sentry/Internal/IHasDistribution.cs

This file was deleted.

8 changes: 8 additions & 0 deletions src/Sentry/Internal/NoOpTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public bool? IsParentSampled
set { }
}

public TransactionNameSource NameSource => TransactionNameSource.Custom;

public string? Distribution
{
get => string.Empty;
set { }
}

public SentryLevel? Level
{
get => default;
Expand Down
Loading

0 comments on commit 5a65707

Please sign in to comment.