Skip to content

Commit

Permalink
Obsolete platform and always write csharp (#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored May 3, 2022
1 parent a443a18 commit e15413f
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- Workaround `System.Text.Json` issue with Unity IL2CPP. ([#1583](https://github.com/getsentry/sentry-dotnet/pull/1583))
- Demystify stack traces for exceptions that fire in a `BeforeSend` callback. ([#1587](https://github.com/getsentry/sentry-dotnet/pull/1587))
- Obsolete `Platform` and always write `csharp` ([#1610](https://github.com/getsentry/sentry-dotnet/pull/1610))
- Fix a minor issue in the caching transport related to recovery of files from previous session. ([#1617](https://github.com/getsentry/sentry-dotnet/pull/1617))

## 3.16.0
Expand Down
2 changes: 2 additions & 0 deletions src/Sentry/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace Sentry
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Sentry/IEventLike.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -40,6 +41,7 @@ public interface IEventLike : IHasBreadcrumbs, IHasTags, IHasExtra
/// <summary>
/// The name of the platform.
/// </summary>
[Obsolete("Platform is always csharp, and should not be set by consuming code. This property will be removed in version 4.")]
public string? Platform { get; set; }

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry/Internal/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ public void Apply(IEventLike eventLike)
eventLike.Sdk.AddPackage("nuget:" + SdkVersion.Instance.Name, SdkVersion.Instance.Version);
}

// Platform
eventLike.Platform ??= Sentry.Constants.Platform;

// Release
eventLike.Release ??= ReleaseLocator.Resolve(_options);

Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public User User
}

/// <inheritdoc />
public string? Platform { get; set; }
[Obsolete("Platform is always csharp, and should not be set by consuming code. This property will be removed in version 4.")]
public string? Platform { get; set; } = Constants.Platform;

/// <inheritdoc />
public string? Release { get; set; }
Expand Down Expand Up @@ -360,7 +361,6 @@ public void Apply(IEventLike other)
Request.CopyTo(other.Request);
User.CopyTo(other.User);

other.Platform ??= Platform;
other.Release ??= Release;
other.Environment ??= Environment;
other.TransactionName ??= TransactionName;
Expand Down
8 changes: 3 additions & 5 deletions src/Sentry/SentryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public sealed class SentryEvent : IEventLike, IJsonSerializable
public string? Logger { get; set; }

/// <inheritdoc />
public string? Platform { get; set; }
[Obsolete("Platform is always csharp, and should not be set by consuming code. This property will be removed in version 4.")]
public string? Platform { get; set; } = Constants.Platform;

/// <summary>
/// Identifies the host SDK from which the event was recorded.
Expand Down Expand Up @@ -202,7 +203,6 @@ internal SentryEvent(
Exception = exception;
Timestamp = timestamp ?? DateTimeOffset.UtcNow;
EventId = eventId != default ? eventId : SentryId.Create();
Platform = Constants.Platform;
}

/// <inheritdoc />
Expand Down Expand Up @@ -231,7 +231,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
writer.WriteString("timestamp", Timestamp);
writer.WriteSerializableIfNotNull("logentry", Message, logger);
writer.WriteStringIfNotWhiteSpace("logger", Logger);
writer.WriteStringIfNotWhiteSpace("platform", Platform);
writer.WriteString("platform", Constants.Platform);
writer.WriteStringIfNotWhiteSpace("server_name", ServerName);
writer.WriteStringIfNotWhiteSpace("release", Release);
writer.WriteSerializableIfNotNull("exception", SentryExceptionValues, logger);
Expand Down Expand Up @@ -271,7 +271,6 @@ public static SentryEvent FromJson(JsonElement json)
var timestamp = json.GetPropertyOrNull("timestamp")?.GetDateTimeOffset();
var message = json.GetPropertyOrNull("logentry")?.Pipe(SentryMessage.FromJson);
var logger = json.GetPropertyOrNull("logger")?.GetString();
var platform = json.GetPropertyOrNull("platform")?.GetString();
var serverName = json.GetPropertyOrNull("server_name")?.GetString();
var release = json.GetPropertyOrNull("release")?.GetString();
var exceptionValues = json.GetPropertyOrNull("exception")?.GetPropertyOrNull("values")?.EnumerateArray().Select(SentryException.FromJson).Pipe(v => new SentryValues<SentryException>(v));
Expand All @@ -296,7 +295,6 @@ public static SentryEvent FromJson(JsonElement json)
_modules = modules?.WhereNotNullValue().ToDictionary(),
Message = message,
Logger = logger,
Platform = platform,
ServerName = serverName,
Release = release,
SentryExceptionValues = exceptionValues,
Expand Down
6 changes: 2 additions & 4 deletions src/Sentry/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public SentryId TraceId
public bool? IsParentSampled { get; set; }

/// <inheritdoc />
[Obsolete("Platform is always csharp, and should not be set by consuming code. This property will be removed in version 4.")]
public string? Platform { get; set; } = Constants.Platform;

/// <inheritdoc />
Expand Down Expand Up @@ -210,7 +211,6 @@ public Transaction(ITransaction tracer)
SpanId = tracer.SpanId;
TraceId = tracer.TraceId;
Operation = tracer.Operation;
Platform = tracer.Platform;
Release = tracer.Release;
StartTimestamp = tracer.StartTimestamp;
EndTimestamp = tracer.EndTimestamp;
Expand Down Expand Up @@ -259,7 +259,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
writer.WriteString("type", "transaction");
writer.WriteSerializable("event_id", EventId, logger);
writer.WriteStringIfNotWhiteSpace("level", Level?.ToString().ToLowerInvariant());
writer.WriteStringIfNotWhiteSpace("platform", Platform);
writer.WriteString("platform", Constants.Platform);
writer.WriteStringIfNotWhiteSpace("release", Release);
writer.WriteStringIfNotWhiteSpace("transaction", Name);
writer.WriteString("start_timestamp", StartTimestamp);
Expand Down Expand Up @@ -288,7 +288,6 @@ public static Transaction FromJson(JsonElement json)
var startTimestamp = json.GetProperty("start_timestamp").GetDateTimeOffset();
var endTimestamp = json.GetPropertyOrNull("timestamp")?.GetDateTimeOffset();
var level = json.GetPropertyOrNull("level")?.GetString()?.ParseEnum<SentryLevel>();
var platform = json.GetPropertyOrNull("platform")?.GetString();
var release = json.GetPropertyOrNull("release")?.GetString();
var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson);
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson);
Expand All @@ -310,7 +309,6 @@ public static Transaction FromJson(JsonElement json)
StartTimestamp = startTimestamp,
EndTimestamp = endTimestamp,
Level = level,
Platform = platform,
Release = release,
_request = request,
Contexts = contexts ?? new(),
Expand Down
1 change: 1 addition & 0 deletions src/Sentry/TransactionTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public SentryId TraceId
public bool? IsParentSampled { get; set; }

/// <inheritdoc />
[Obsolete("Platform is always csharp, and should not be set by consuming code. This property will be removed in version 4.")]
public string? Platform { get; set; } = Constants.Platform;

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Type: Exception,
Message: my exception
},
Platform: csharp,
SentryExceptions: [
{
Type: System.Exception,
Expand All @@ -25,7 +24,6 @@
{
Source: {
Name: my transaction,
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Type: Exception,
Message: my exception
},
Platform: csharp,
SentryExceptions: [
{
Type: System.Exception,
Expand All @@ -25,7 +24,6 @@
{
Source: {
Name: my transaction,
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Type: Exception,
Message: my exception
},
Platform: csharp,
SentryExceptions: [
{
Type: System.Exception,
Expand All @@ -25,7 +24,6 @@
{
Source: {
Name: my transaction,
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Type: Exception,
Message: my exception
},
Platform: csharp,
SentryExceptions: [
{
Type: System.Exception,
Expand All @@ -25,7 +24,6 @@
{
Source: {
Name: my transaction,
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Type: Exception,
Message: my exception
},
Platform: csharp,
SentryExceptions: [
{
Type: System.Exception,
Expand All @@ -25,7 +24,6 @@
{
Source: {
Name: my transaction,
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ namespace Sentry
string? Environment { get; set; }
System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
string? Platform { get; set; }
string? Release { get; set; }
Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -307,6 +309,8 @@ namespace Sentry
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
public Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -386,6 +390,8 @@ namespace Sentry
public string? Logger { get; set; }
public Sentry.SentryMessage? Message { get; set; }
public System.Collections.Generic.IDictionary<string, string> Modules { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -804,6 +810,8 @@ namespace Sentry
public string Name { get; }
public string Operation { get; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -857,6 +865,8 @@ namespace Sentry
public string Name { get; set; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ namespace Sentry
string? Environment { get; set; }
System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
string? Platform { get; set; }
string? Release { get; set; }
Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -307,6 +309,8 @@ namespace Sentry
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
public Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -386,6 +390,8 @@ namespace Sentry
public string? Logger { get; set; }
public Sentry.SentryMessage? Message { get; set; }
public System.Collections.Generic.IDictionary<string, string> Modules { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -804,6 +810,8 @@ namespace Sentry
public string Name { get; }
public string Operation { get; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -857,6 +865,8 @@ namespace Sentry
public string Name { get; set; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ namespace Sentry
string? Environment { get; set; }
System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
string? Platform { get; set; }
string? Release { get; set; }
Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -307,6 +309,8 @@ namespace Sentry
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public System.Collections.Generic.IReadOnlyList<string> Fingerprint { get; set; }
public Sentry.SentryLevel? Level { get; set; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -386,6 +390,8 @@ namespace Sentry
public string? Logger { get; set; }
public Sentry.SentryMessage? Message { get; set; }
public System.Collections.Generic.IDictionary<string, string> Modules { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -804,6 +810,8 @@ namespace Sentry
public string Name { get; }
public string Operation { get; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down Expand Up @@ -857,6 +865,8 @@ namespace Sentry
public string Name { get; set; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
[System.Obsolete("Platform is always csharp, and should not be set by consuming code. This property" +
" will be removed in version 4.")]
public string? Platform { get; set; }
public string? Release { get; set; }
public Sentry.Request Request { get; set; }
Expand Down
Loading

0 comments on commit e15413f

Please sign in to comment.