Skip to content

Commit

Permalink
Merge branch 'main' into unfinished-spans
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Jan 8, 2024
2 parents 3661e3a + f93d62b commit 44d29be
Show file tree
Hide file tree
Showing 40 changed files with 183 additions and 153 deletions.
5 changes: 4 additions & 1 deletion .codecov.yml
Expand Up @@ -3,9 +3,12 @@ coverage:
changes: false
project:
default:
threshold: 5%
informational: true
patch: off
ignore:
- "benchmarks/**/*"
- "modules/**/*"
- "samples/**/*"
- "test/**/*"
range: 0..100
round: down
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -61,6 +61,7 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 2 # default is 1 and codecov needs > 1

# We use macOS for the final publishing build so we we get all the iOS/macCatalyst targets in the packages
- name: Set Environment Variables
Expand Down Expand Up @@ -113,7 +114,10 @@ jobs:
run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true

- name: Test
run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}"
run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" /p:CollectCoverage=true

- name: Upload code coverage
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d

- name: Upload build and test outputs
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,8 @@ codecov.sh
lcov.info
bin/
obj/
**/coverage/*.xml
**/coverage/*.json
.DS_Store
Thumbs.db
**/BenchmarkDotNet.Artifacts/*.log
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,12 @@
- Transactions' spans are no longer automatically finished with status `deadline_exceeded` by the transaction. This is now handled by the [Relay](https://github.com/getsentry/relay).
- Customers self hosting Sentry must use verion 22.12.0 or later ([#3013](https://github.com/getsentry/sentry-dotnet/pull/3013))

### API breaking Changes

#### Changed APIs

- Class renamed `Sentry.User` to `Sentry.SentryUser` ([#3015](https://github.com/getsentry/sentry-dotnet/pull/3015))

### Dependencies

- Bump CLI from v2.23.2 to v2.24.1 ([#3012](https://github.com/getsentry/sentry-dotnet/pull/3012))
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -12,6 +12,7 @@ Sentry SDK for .NET
===========

[![build](https://github.com/getsentry/sentry-dotnet/workflows/build/badge.svg?branch=main)](https://github.com/getsentry/sentry-dotnet/actions?query=branch%3Amain)
[![codecov](https://codecov.io/gh/getsentry/sentry-dotnet/branch/main/graph/badge.svg)](https://codecov.io/gh/getsentry/sentry-dotnet)
[![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K)


Expand Down
2 changes: 1 addition & 1 deletion build.cmd
@@ -1,2 +1,2 @@
dotnet build Sentry.sln -c Release
dotnet test Sentry.sln -c Release --no-build
dotnet test Sentry.sln -c Release --no-build /p:CollectCoverage=true
2 changes: 1 addition & 1 deletion build.sh
@@ -1,2 +1,2 @@
dotnet build Sentry.sln -c Release
dotnet test Sentry.sln -c Release --no-build
dotnet test Sentry.sln -c Release --no-build /p:CollectCoverage=true
2 changes: 1 addition & 1 deletion samples/Sentry.Samples.Android/MainActivity.cs
Expand Up @@ -21,7 +21,7 @@ protected override void OnCreate(Bundle? savedInstanceState)
{
scope.AddBreadcrumb("Custom Breadcrumb");
scope.SetExtra("Test", "Custom Extra Data");
scope.User = new User
scope.User = new SentryUser
{
Username = "SomeUser",
Email = "test@example.com",
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry.AspNetCore/DefaultUserFactory.cs
Expand Up @@ -15,9 +15,9 @@ public DefaultUserFactory(IHttpContextAccessor httpContextAccessor)
_httpContextAccessor = httpContextAccessor;
}

public User? Create() => _httpContextAccessor?.HttpContext is {} httpContext ? Create(httpContext) : null;
public SentryUser? Create() => _httpContextAccessor?.HttpContext is {} httpContext ? Create(httpContext) : null;

public User? Create(HttpContext context)
public SentryUser? Create(HttpContext context)
{
var principal = context.User;
if (principal is null)
Expand Down Expand Up @@ -56,7 +56,7 @@ public DefaultUserFactory(IHttpContextAccessor httpContextAccessor)

return email is null && id is null && username is null && ipAddress is null
? null
: new User
: new SentryUser
{
Id = id,
Email = email,
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Log4Net/SentryAppender.cs
Expand Up @@ -125,7 +125,7 @@ protected override void Append(LoggingEvent loggingEvent)

if (SendIdentity && !string.IsNullOrEmpty(loggingEvent.Identity))
{
evt.User = new User
evt.User = new SentryUser
{
Id = loggingEvent.Identity
};
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry.NLog/SentryTarget.cs
Expand Up @@ -346,7 +346,7 @@ private void InnerWrite(LogEventInfo logEvent)
Level = logEvent.Level.ToSentryLevel(),
Release = Options.Release,
Environment = Options.Environment,
User = GetUser(logEvent) ?? new User(),
User = GetUser(logEvent) ?? new SentryUser(),
};

if (evt.Sdk is { } sdk)
Expand Down Expand Up @@ -439,14 +439,14 @@ private void InnerWrite(LogEventInfo logEvent)
}
}

private User? GetUser(LogEventInfo logEvent)
private SentryUser? GetUser(LogEventInfo logEvent)
{
if (User is null)
{
return null;
}

var user = new User
var user = new SentryUser
{
Id = User.Id?.Render(logEvent),
Username = User.Username?.Render(logEvent),
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/IEventLike.cs
Expand Up @@ -48,7 +48,7 @@ public interface IEventLike : IHasTags, IHasExtra
/// <value>
/// The user.
/// </value>
User User { get; set; }
SentryUser User { get; set; }

/// <summary>
/// The release version of the application.
Expand Down Expand Up @@ -194,7 +194,7 @@ public static class EventLikeExtensions
}

/// <summary>
/// Whether a <see cref="User"/> has been set to the object with any of its fields non null.
/// Whether a <see cref="SentryUser"/> has been set to the object with any of its fields non null.
/// </summary>
public static bool HasUser(this IEventLike eventLike) => eventLike.User.HasAnyData();

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/IScopeObserver.cs
Expand Up @@ -28,5 +28,5 @@ public interface IScopeObserver
/// <summary>
/// Sets the user information.
/// </summary>
void SetUser(User? user);
void SetUser(SentryUser? user);
}
4 changes: 2 additions & 2 deletions src/Sentry/ISentryUserFactory.cs
Expand Up @@ -6,8 +6,8 @@ namespace Sentry;
public interface ISentryUserFactory
{
/// <summary>
/// Creates a Sentry <see cref="User"/> representing the current principal.
/// Creates a Sentry <see cref="SentryUser"/> representing the current principal.
/// </summary>
/// <returns>The protocol user</returns>
public User? Create();
public SentryUser? Create();
}
2 changes: 1 addition & 1 deletion src/Sentry/Internal/NoOpTransaction.cs
Expand Up @@ -51,7 +51,7 @@ public string Name
set { }
}

public User User
public SentryUser User
{
get => new();
set { }
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Internal/ScopeObserver.cs
Expand Up @@ -65,7 +65,7 @@ public void UnsetTag(string key)

public abstract void UnsetTagImpl(string key);

public void SetUser(User? user)
public void SetUser(SentryUser? user)
{
if (user is null)
{
Expand All @@ -82,7 +82,7 @@ public void SetUser(User? user)
}
}

public abstract void SetUserImpl(User user);
public abstract void SetUserImpl(SentryUser user);

public abstract void UnsetUserImpl();
}
2 changes: 1 addition & 1 deletion src/Sentry/Platforms/Android/AndroidScopeObserver.cs
Expand Up @@ -87,7 +87,7 @@ public void UnsetTag(string key)
}
}

public void SetUser(User? user)
public void SetUser(SentryUser? user)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Platforms/Android/Extensions/UserExtensions.cs
Expand Up @@ -5,7 +5,7 @@ internal static class UserExtensions
private static readonly IDictionary<string, string> EmptyDictionary =
new ReadOnlyDictionary<string, string>(new Dictionary<string, string>());

public static User ToUser(this JavaSdk.Protocol.User user) =>
public static SentryUser ToUser(this JavaSdk.Protocol.User user) =>
new()
{
Email = user.Email,
Expand All @@ -16,7 +16,7 @@ internal static class UserExtensions
Other = user.Data ?? EmptyDictionary
};

public static JavaSdk.Protocol.User ToJavaUser(this User user) =>
public static JavaSdk.Protocol.User ToJavaUser(this SentryUser user) =>
new()
{
Email = user.Email,
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs
Expand Up @@ -89,7 +89,7 @@ public void UnsetTag(string key)
}
}

public void SetUser(User? user)
public void SetUser(SentryUser? user)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs
Expand Up @@ -4,7 +4,7 @@ namespace Sentry.Cocoa.Extensions;

internal static class UserExtensions
{
public static User ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger? logger = null) =>
public static SentryUser ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger? logger = null) =>
new()
{
Email = user.Email,
Expand All @@ -15,7 +15,7 @@ internal static class UserExtensions
Other = user.Data.ToStringDictionary(logger)
};

public static CocoaSdk.SentryUser ToCocoaUser(this User user)
public static CocoaSdk.SentryUser ToCocoaUser(this SentryUser user)
{
var cocoaUser = new CocoaSdk.SentryUser
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Platforms/Native/NativeScopeObserver.cs
Expand Up @@ -30,7 +30,7 @@ public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)

public override void UnsetTagImpl(string key) => C.sentry_remove_tag(key);

public override void SetUserImpl(User user)
public override void SetUserImpl(SentryUser user)
{
// see https://develop.sentry.dev/sdk/event-payloads/user/
var cUser = C.sentry_value_new_object();
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Scope.cs
Expand Up @@ -107,7 +107,7 @@ public Contexts Contexts
}

// Internal for testing.
internal Action<User?> UserChanged => user =>
internal Action<SentryUser?> UserChanged => user =>
{
if (Options.EnableScopeSync &&
Options.ScopeObserver is { } observer)
Expand All @@ -116,12 +116,12 @@ public Contexts Contexts
}
};

private User? _user;
private SentryUser? _user;

/// <inheritdoc />
public User User
public SentryUser User
{
get => _user ??= new User
get => _user ??= new SentryUser
{
PropertyChanged = UserChanged
};
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/SentryEvent.cs
Expand Up @@ -139,12 +139,12 @@ public Contexts Contexts
set => _contexts.ReplaceWith(value);
}

private User? _user;
private SentryUser? _user;

/// <inheritdoc />
public User User
public SentryUser User
{
get => _user ??= new User();
get => _user ??= new SentryUser();
set => _user = value;
}

Expand Down Expand Up @@ -304,7 +304,7 @@ internal static SentryEvent FromJson(JsonElement json, Exception? exception)
var transaction = json.GetPropertyOrNull("transaction")?.GetString();
var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson);
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson);
var user = json.GetPropertyOrNull("user")?.Pipe(User.FromJson);
var user = json.GetPropertyOrNull("user")?.Pipe(SentryUser.FromJson);
var environment = json.GetPropertyOrNull("environment")?.GetString();
var sdk = json.GetPropertyOrNull("sdk")?.Pipe(SdkVersion.FromJson) ?? new SdkVersion();
var fingerprint = json.GetPropertyOrNull("fingerprint")?.EnumerateArray().Select(j => j.GetString()).ToArray();
Expand Down
16 changes: 8 additions & 8 deletions src/Sentry/User.cs → src/Sentry/SentryUser.cs
Expand Up @@ -7,9 +7,9 @@ namespace Sentry;
/// An interface which describes the authenticated User for a request.
/// </summary>
/// <see href="https://develop.sentry.dev/sdk/event-payloads/user/"/>
public sealed class User : IJsonSerializable
public sealed class SentryUser : IJsonSerializable
{
internal Action<User>? PropertyChanged { get; set; }
internal Action<SentryUser>? PropertyChanged { get; set; }

private string? _id;
private string? _username;
Expand Down Expand Up @@ -115,17 +115,17 @@ public sealed class User : IJsonSerializable
}

/// <summary>
/// Clones the current <see cref="User"/> instance.
/// Clones the current <see cref="SentryUser"/> instance.
/// </summary>
/// <returns>The cloned user.</returns>
public User Clone()
public SentryUser Clone()
{
var user = new User();
var user = new SentryUser();
CopyTo(user);
return user;
}

internal void CopyTo(User? user)
internal void CopyTo(SentryUser? user)
{
if (user == null)
{
Expand Down Expand Up @@ -169,7 +169,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? _)
/// <summary>
/// Parses from JSON.
/// </summary>
public static User FromJson(JsonElement json)
public static SentryUser FromJson(JsonElement json)
{
var id = json.GetPropertyOrNull("id")?.GetString();
var username = json.GetPropertyOrNull("username")?.GetString();
Expand All @@ -178,7 +178,7 @@ public static User FromJson(JsonElement json)
var segment = json.GetPropertyOrNull("segment")?.GetString();
var other = json.GetPropertyOrNull("other")?.GetStringDictionaryOrNull();

return new User
return new SentryUser
{
Id = id,
Username = username,
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Transaction.cs
Expand Up @@ -134,12 +134,12 @@ public Contexts Contexts
set => _contexts.ReplaceWith(value);
}

private User? _user;
private SentryUser? _user;

/// <inheritdoc />
public User User
public SentryUser User
{
get => _user ??= new User();
get => _user ??= new SentryUser();
set => _user = value;
}

Expand Down Expand Up @@ -369,7 +369,7 @@ public static Transaction FromJson(JsonElement json)
var distribution = json.GetPropertyOrNull("dist")?.GetString();
var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson);
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson) ?? new();
var user = json.GetPropertyOrNull("user")?.Pipe(User.FromJson);
var user = json.GetPropertyOrNull("user")?.Pipe(SentryUser.FromJson);
var environment = json.GetPropertyOrNull("environment")?.GetString();
var sdk = json.GetPropertyOrNull("sdk")?.Pipe(SdkVersion.FromJson) ?? new SdkVersion();
var fingerprint = json.GetPropertyOrNull("fingerprint")?
Expand Down

0 comments on commit 44d29be

Please sign in to comment.