Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Renamed Contexts, Request, and Package #3121

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

### Fixes

- To resolve conflicting types due to the SDK adding itself to the global usings:
- The class `Sentry.Context` has been renamed to `Sentry.SentryContext` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))
- The class `Sentry.Package` has been renamed to `Sentry.SentryPackage` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))
- The class `Sentry.Request` has been renamed to `Sentry.SentryRequest` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))

### Dependencies

- Bump CLI from v2.27.0 to v2.28.0 ([#3119](https://github.com/getsentry/sentry-dotnet/pull/3119))
Expand All @@ -16,8 +23,8 @@
- The interface `Sentry.ISession` has been renamed to `Sentry.ISentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
- The interface `Sentry.IJsonSerializable` has been renamed to `Sentry.ISentryJsonSerializable` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Session` has been renamed to `Sentry.SentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
- The class `Sentry.Attachment` has been renamed to `Sentry.SentryAttachment` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Hint` has been renamed to `Sentry.SentryHint` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Attachment` has been renamed to `Sentry.SentryAttachment` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Hint` has been renamed to `Sentry.SentryHint` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))

### Dependencies

Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/IEventLike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public interface IEventLike : IHasTags, IHasExtra
/// <value>
/// The HTTP.
/// </value>
Request Request { get; set; }
SentryRequest Request { get; set; }

/// <summary>
/// Gets the structured Sentry context.
/// </summary>
/// <value>
/// The contexts.
/// </value>
Contexts Contexts { get; set; }
SentryContexts Contexts { get; set; }

/// <summary>
/// Gets the user information.
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Internal/MainSentryEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public SentryEvent Process(SentryEvent @event)
return @event;
}

private static void AddMemoryInfo(Contexts contexts)
private static void AddMemoryInfo(SentryContexts contexts)
{
#if NETCOREAPP3_0_OR_GREATER
var memory = GC.GetGCMemoryInfo();
Expand Down Expand Up @@ -192,7 +192,7 @@ private static void AddMemoryInfo(Contexts contexts)
#endif
}

private static void AddThreadPoolInfo(Contexts contexts)
private static void AddThreadPoolInfo(SentryContexts contexts)
{
ThreadPool.GetMinThreads(out var minWorkerThreads, out var minCompletionPortThreads);
ThreadPool.GetMaxThreads(out var maxWorkerThreads, out var maxCompletionPortThreads);
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Internal/NoOpTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public SentryLevel? Level
set { }
}

public Request Request
public SentryRequest Request
{
get => new();
set { }
}

public Contexts Contexts
public SentryContexts Contexts
{
get => new();
set { }
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SentryEvent Process(SentryEvent @event)
if (json != null)
{
var jsonDoc = JsonDocument.Parse(json);
var contexts = Contexts.FromJson(jsonDoc.RootElement);
var contexts = SentryContexts.FromJson(jsonDoc.RootElement);
contexts.CopyTo(@event.Contexts);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Protocol/ProfileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ internal sealed class ProfileInfo : ISentryJsonSerializable

public DebugMeta DebugMeta { get; set; } = new() { Images = new() };

private readonly Contexts _contexts = new();
private readonly SentryContexts _contexts = new();

/// <inheritdoc />
public Contexts Contexts
public SentryContexts Contexts
{
get => _contexts;
set => _contexts.ReplaceWith(value);
Expand Down
10 changes: 5 additions & 5 deletions src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ internal SentryId LastEventId
/// <inheritdoc />
public SentryLevel? Level { get; set; }

private Request? _request;
private SentryRequest? _request;

/// <inheritdoc />
public Request Request
public SentryRequest Request
{
get => _request ??= new Request();
get => _request ??= new SentryRequest();
set => _request = value;
}

private readonly Contexts _contexts = new();
private readonly SentryContexts _contexts = new();

/// <inheritdoc />
public Contexts Contexts
public SentryContexts Contexts
{
get => _contexts;
set => _contexts.ReplaceWith(value);
Expand Down
14 changes: 7 additions & 7 deletions src/Sentry/SdkVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public sealed class SdkVersion : ISentryJsonSerializable

internal static SdkVersion Instance => InstanceLazy.Value;

internal ConcurrentBag<Package> InternalPackages { get; set; } = new();
internal ConcurrentBag<SentryPackage> InternalPackages { get; set; } = new();
internal ConcurrentBag<string> Integrations { get; set; } = new();

/// <summary>
/// SDK packages.
/// </summary>
/// <remarks>This property is not required.</remarks>
public IEnumerable<Package> Packages => InternalPackages;
public IEnumerable<SentryPackage> Packages => InternalPackages;

/// <summary>
/// SDK name.
Expand Down Expand Up @@ -56,9 +56,9 @@ public string? Version
/// <param name="name">The package name.</param>
/// <param name="version">The package version.</param>
public void AddPackage(string name, string version)
=> AddPackage(new Package(name, version));
=> AddPackage(new SentryPackage(name, version));

internal void AddPackage(Package package)
internal void AddPackage(SentryPackage package)
=> InternalPackages.Add(package);

/// <summary>
Expand Down Expand Up @@ -88,8 +88,8 @@ public static SdkVersion FromJson(JsonElement json)
{
// Packages
var packages =
json.GetPropertyOrNull("packages")?.EnumerateArray().Select(Package.FromJson).ToArray()
?? Array.Empty<Package>();
json.GetPropertyOrNull("packages")?.EnumerateArray().Select(SentryPackage.FromJson).ToArray()
?? Array.Empty<SentryPackage>();

// Integrations
var integrations =
Expand All @@ -104,7 +104,7 @@ public static SdkVersion FromJson(JsonElement json)

return new SdkVersion
{
InternalPackages = new ConcurrentBag<Package>(packages),
InternalPackages = new ConcurrentBag<SentryPackage>(packages),
Integrations = new ConcurrentBag<string>(integrations),
Name = name,
Version = version
Expand Down
20 changes: 10 additions & 10 deletions src/Sentry/Contexts.cs → src/Sentry/SentryContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Sentry;
/// Represents Sentry's structured Context.
/// </summary>
/// <seealso href="https://develop.sentry.dev/sdk/event-payloads/contexts/" />
public sealed class Contexts : IDictionary<string, object>, ISentryJsonSerializable
public sealed class SentryContexts : IDictionary<string, object>, ISentryJsonSerializable
{
private readonly ConcurrentDictionary<string, object> _innerDictionary = new(StringComparer.Ordinal);

Expand Down Expand Up @@ -59,16 +59,16 @@ public sealed class Contexts : IDictionary<string, object>, ISentryJsonSerializa
public Trace Trace => _innerDictionary.GetOrCreate<Trace>(Trace.Type);

/// <summary>
/// Initializes an instance of <see cref="Contexts"/>.
/// Initializes an instance of <see cref="SentryContexts"/>.
/// </summary>
public Contexts() { }
public SentryContexts() { }

/// <summary>
/// Creates a deep clone of this context.
/// </summary>
internal Contexts Clone()
internal SentryContexts Clone()
{
var context = new Contexts();
var context = new SentryContexts();

CopyTo(context);

Expand All @@ -78,7 +78,7 @@ internal Contexts Clone()
/// <summary>
/// Copies the items of the context while cloning the known types.
/// </summary>
internal void CopyTo(Contexts to)
internal void CopyTo(SentryContexts to)
{
foreach (var kv in this)
{
Expand Down Expand Up @@ -126,9 +126,9 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
/// <summary>
/// Parses from JSON.
/// </summary>
public static Contexts FromJson(JsonElement json)
public static SentryContexts FromJson(JsonElement json)
{
var result = new Contexts();
var result = new SentryContexts();

foreach (var (name, value) in json.EnumerateObject())
{
Expand Down Expand Up @@ -181,7 +181,7 @@ public static Contexts FromJson(JsonElement json)
return result;
}

internal void ReplaceWith(Contexts? contexts)
internal void ReplaceWith(SentryContexts? contexts)
{
Clear();

Expand All @@ -196,7 +196,7 @@ internal void ReplaceWith(Contexts? contexts)
}
}

internal Contexts? NullIfEmpty() => _innerDictionary.IsEmpty ? null : this;
internal SentryContexts? NullIfEmpty() => _innerDictionary.IsEmpty ? null : this;

/// <inheritdoc/>
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _innerDictionary.GetEnumerator();
Expand Down
14 changes: 7 additions & 7 deletions src/Sentry/SentryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ public List<DebugImage>? DebugImages
/// <inheritdoc />
public string? TransactionName { get; set; }

private Request? _request;
private SentryRequest? _request;

/// <inheritdoc />
public Request Request
public SentryRequest Request
{
get => _request ??= new Request();
get => _request ??= new SentryRequest();
set => _request = value;
}

private readonly Contexts _contexts = new();
private readonly SentryContexts _contexts = new();

/// <inheritdoc />
public Contexts Contexts
public SentryContexts Contexts
{
get => _contexts;
set => _contexts.ReplaceWith(value);
Expand Down Expand Up @@ -301,8 +301,8 @@ internal static SentryEvent FromJson(JsonElement json, Exception? exception)
var threadValues = json.GetPropertyOrNull("threads")?.GetPropertyOrNull("values")?.EnumerateArray().Select(SentryThread.FromJson).ToList().Pipe(v => new SentryValues<SentryThread>(v));
var level = json.GetPropertyOrNull("level")?.GetString()?.ParseEnum<SentryLevel>();
var transaction = json.GetPropertyOrNull("transaction")?.GetString();
var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson);
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson);
var request = json.GetPropertyOrNull("request")?.Pipe(SentryRequest.FromJson);
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(SentryContexts.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();
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/SentryGraphQLHttpFailedRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected internal override void DoEnsureSuccessfulResponse([NotNull] HttpReques
var @event = new SentryEvent(exception);
var hint = new SentryHint(HintTypes.HttpResponseMessage, response);

var sentryRequest = new Request
var sentryRequest = new SentryRequest
{
QueryString = request.RequestUri?.Query,
Method = request.Method.Method.ToUpperInvariant(),
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/SentryHttpFailedRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected internal override void DoEnsureSuccessfulResponse([NotNull] HttpReques
var hint = new SentryHint(HintTypes.HttpResponseMessage, response);

var uri = response.RequestMessage?.RequestUri;
var sentryRequest = new Request
var sentryRequest = new SentryRequest
{
QueryString = uri?.Query,
Method = response.RequestMessage?.Method.Method.ToUpperInvariant()
Expand Down
12 changes: 6 additions & 6 deletions src/Sentry/Package.cs → src/Sentry/SentryPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sentry;
/// <summary>
/// Represents a package used to compose the SDK.
/// </summary>
public sealed class Package : ISentryJsonSerializable
public sealed class SentryPackage : ISentryJsonSerializable
{
/// <summary>
/// The name of the package.
Expand All @@ -26,11 +26,11 @@ public sealed class Package : ISentryJsonSerializable
public string Version { get; }

/// <summary>
/// Creates a new instance of a <see cref="Package"/>.
/// Creates a new instance of a <see cref="SentryPackage"/>.
/// </summary>
/// <param name="name">The package name.</param>
/// <param name="version">The package version.</param>
public Package(string name, string version)
public SentryPackage(string name, string version)
{
Name = name;
Version = version;
Expand All @@ -50,12 +50,12 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
/// <summary>
/// Parses from JSON.
/// </summary>
public static Package FromJson(JsonElement json)
public static SentryPackage FromJson(JsonElement json)
{
var name = json.GetProperty("name").GetStringOrThrow();
var version = json.GetProperty("version").GetStringOrThrow();

return new Package(name, version);
return new SentryPackage(name, version);
}

/// <inheritdoc />
Expand All @@ -75,7 +75,7 @@ public override bool Equals(object? obj)
return true;
}

if (obj is Package package)
if (obj is SentryPackage package)
{
return Name == package.Name && Version == package.Version;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Sentry/Request.cs → src/Sentry/SentryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Sentry;
/// }
/// </example>
/// <see href="https://develop.sentry.dev/sdk/event-payloads/request/"/>
public sealed class Request : ISentryJsonSerializable
public sealed class SentryRequest : ISentryJsonSerializable
{
internal Dictionary<string, string>? InternalEnv { get; private set; }

Expand Down Expand Up @@ -113,16 +113,16 @@ internal void AddHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>>
/// This is a shallow copy.
/// References like <see cref="Data"/> could hold a mutable, non-thread-safe object.
/// </remarks>
public Request Clone()
public SentryRequest Clone()
{
var request = new Request();
var request = new SentryRequest();

CopyTo(request);

return request;
}

internal void CopyTo(Request? request)
internal void CopyTo(SentryRequest? request)
{
if (request == null)
{
Expand Down Expand Up @@ -161,7 +161,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
/// <summary>
/// Parses from JSON.
/// </summary>
public static Request FromJson(JsonElement json)
public static SentryRequest FromJson(JsonElement json)
{
var env = json.GetPropertyOrNull("env")?.GetStringDictionaryOrNull();
var other = json.GetPropertyOrNull("other")?.GetStringDictionaryOrNull();
Expand All @@ -172,7 +172,7 @@ public static Request FromJson(JsonElement json)
var query = json.GetPropertyOrNull("query_string")?.GetString();
var cookies = json.GetPropertyOrNull("cookies")?.GetString();

return new Request
return new SentryRequest
{
InternalEnv = env?.WhereNotNullValue().ToDict(),
InternalOther = other?.WhereNotNullValue().ToDict(),
Expand Down
Loading
Loading