Skip to content

Commit bb71eaf

Browse files
authored
feat: Renamed Sentry.Runtime to SentryRuntime (#3016)
1 parent 089fb75 commit bb71eaf

22 files changed

+211
-213
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#### Changed APIs
1313

1414
- Class renamed `Sentry.User` to `Sentry.SentryUser` ([#3015](https://github.com/getsentry/sentry-dotnet/pull/3015))
15+
- Class renamed `Sentry.Runtime` to `Sentry.SentryRuntime` ([#3016](https://github.com/getsentry/sentry-dotnet/pull/3016))
16+
- Class renamed `Sentry.Span` to `Sentry.SentrySpan` ([#3021](https://github.com/getsentry/sentry-dotnet/pull/3021))
1517

1618
### Dependencies
1719

src/Sentry/Integrations/NetFxInstallationsIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public void Register(IHub hub, SentryOptions options)
1010
{
1111
try
1212
{
13-
if (!Runtime.Current.IsMono())
13+
if (!SentryRuntime.Current.IsMono())
1414
{
1515
options.AddEventProcessor(new NetFxInstallationsEventProcessor(options));
1616
}

src/Sentry/Internal/Enricher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class Enricher
1212

1313
private readonly Lazy<Runtime> _runtimeLazy = new(() =>
1414
{
15-
var current = PlatformAbstractions.Runtime.Current;
15+
var current = PlatformAbstractions.SentryRuntime.Current;
1616
return new Runtime
1717
{
1818
Name = current.Name,
@@ -36,7 +36,7 @@ public void Apply(IEventLike eventLike)
3636
if (!eventLike.Contexts.ContainsKey(OperatingSystem.Type))
3737
{
3838
// RuntimeInformation.OSDescription is throwing on Mono 5.12
39-
if (!PlatformAbstractions.Runtime.Current.IsMono())
39+
if (!PlatformAbstractions.SentryRuntime.Current.IsMono())
4040
{
4141
#if NETFRAMEWORK
4242
// RuntimeInformation.* throws on .NET Framework on macOS/Linux

src/Sentry/PlatformAbstractions/RuntimeInfo.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,53 @@ internal static class RuntimeInfo
1313
/// Gets the current runtime.
1414
/// </summary>
1515
/// <returns>A new instance for the current runtime</returns>
16-
internal static Runtime GetRuntime()
16+
internal static SentryRuntime GetRuntime()
1717
{
1818
var runtime = GetFromRuntimeInformation();
1919
runtime ??= GetFromMonoRuntime();
2020
runtime ??= GetFromEnvironmentVariable();
2121
return runtime.WithAdditionalProperties();
2222
}
2323

24-
internal static Runtime WithAdditionalProperties(this Runtime runtime)
24+
internal static SentryRuntime WithAdditionalProperties(this SentryRuntime runtime)
2525
{
2626
#if NETFRAMEWORK
2727
GetNetFxInstallationAndVersion(runtime, out var inst, out var ver);
2828
var version = runtime.Version ?? ver;
2929
var installation = runtime.FrameworkInstallation ?? inst;
30-
return new Runtime(runtime.Name, version, installation, runtime.Raw);
30+
return new SentryRuntime(runtime.Name, version, installation, runtime.Raw);
3131
#elif NET5_0_OR_GREATER
3232
var version = runtime.Version ?? GetNetCoreVersion(runtime);
3333
var identifier = runtime.Identifier ?? GetRuntimeIdentifier(runtime);
34-
return new Runtime(runtime.Name, version, runtime.Raw, identifier);
34+
return new SentryRuntime(runtime.Name, version, runtime.Raw, identifier);
3535
#else
3636
var version = runtime.Version ?? GetNetCoreVersion(runtime);
37-
return new Runtime(runtime.Name, version, runtime.Raw);
37+
return new SentryRuntime(runtime.Name, version, runtime.Raw);
3838
#endif
3939
}
4040

41-
internal static Runtime? Parse(string? rawRuntimeDescription, string? name = null)
41+
internal static SentryRuntime? Parse(string? rawRuntimeDescription, string? name = null)
4242
{
4343
if (rawRuntimeDescription == null)
4444
{
45-
return name == null ? null : new Runtime(name);
45+
return name == null ? null : new SentryRuntime(name);
4646
}
4747

4848
var match = RuntimeParseRegex.Match(rawRuntimeDescription);
4949
if (match.Success)
5050
{
51-
return new Runtime(
51+
return new SentryRuntime(
5252
name ?? (match.Groups["name"].Value == string.Empty ? null : match.Groups["name"].Value.Trim()),
5353
match.Groups["version"].Value == string.Empty ? null : match.Groups["version"].Value.Trim(),
5454
raw: rawRuntimeDescription);
5555
}
5656

57-
return new Runtime(name, raw: rawRuntimeDescription);
57+
return new SentryRuntime(name, raw: rawRuntimeDescription);
5858
}
5959

6060
#if NETFRAMEWORK
6161
internal static void GetNetFxInstallationAndVersion(
62-
Runtime runtime,
62+
SentryRuntime runtime,
6363
out FrameworkInstallation? frameworkInstallation,
6464
out string? version)
6565
{
@@ -85,7 +85,7 @@ internal static void GetNetFxInstallationAndVersion(
8585
}
8686
}
8787
#else
88-
private static string? GetNetCoreVersion(Runtime runtime)
88+
private static string? GetNetCoreVersion(SentryRuntime runtime)
8989
{
9090
var description = RuntimeInformation.FrameworkDescription;
9191
return RemovePrefixOrNull(description, ".NET Core")
@@ -101,7 +101,7 @@ internal static void GetNetFxInstallationAndVersion(
101101
#endif
102102

103103
#if NET5_0_OR_GREATER
104-
internal static string? GetRuntimeIdentifier(Runtime runtime)
104+
internal static string? GetRuntimeIdentifier(SentryRuntime runtime)
105105
{
106106
try
107107
{
@@ -114,7 +114,7 @@ internal static void GetNetFxInstallationAndVersion(
114114
}
115115
#endif
116116

117-
private static Runtime? GetFromRuntimeInformation()
117+
private static SentryRuntime? GetFromRuntimeInformation()
118118
{
119119
try
120120
{
@@ -132,7 +132,7 @@ internal static void GetNetFxInstallationAndVersion(
132132
}
133133
}
134134

135-
private static Runtime? GetFromMonoRuntime()
135+
private static SentryRuntime? GetFromMonoRuntime()
136136
=> Type.GetType("Mono.Runtime", false)
137137
?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static)
138138
?.Invoke(null, null) is string monoVersion
@@ -146,7 +146,7 @@ internal static void GetNetFxInstallationAndVersion(
146146
: null;
147147

148148
// This should really only be used on .NET 1.0, 1.1, 2.0, 3.0, 3.5 and 4.0
149-
private static Runtime GetFromEnvironmentVariable()
149+
private static SentryRuntime GetFromEnvironmentVariable()
150150
{
151151
// Environment.Version: NET Framework 4, 4.5, 4.5.1, 4.5.2 = 4.0.30319.xxxxx
152152
// .NET Framework 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 = 4.0.30319.42000
@@ -158,6 +158,6 @@ private static Runtime GetFromEnvironmentVariable()
158158
1 => "",
159159
_ => version.ToString()
160160
};
161-
return new Runtime(".NET Framework", friendlyVersion, raw: "Environment.Version=" + version);
161+
return new SentryRuntime(".NET Framework", friendlyVersion, raw: "Environment.Version=" + version);
162162
}
163163
}

src/Sentry/PlatformAbstractions/Runtime.cs renamed to src/Sentry/PlatformAbstractions/SentryRuntime.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ namespace Sentry.PlatformAbstractions;
33
/// <summary>
44
/// Details of the runtime
55
/// </summary>
6-
public class Runtime : IEquatable<Runtime>
6+
public class SentryRuntime : IEquatable<SentryRuntime>
77
{
8-
private static Lazy<Runtime> _currentRuntime = new(RuntimeInfo.GetRuntime);
8+
private static Lazy<SentryRuntime> _currentRuntime = new(RuntimeInfo.GetRuntime);
99

1010
/// <summary>
1111
/// Gets the current runtime
1212
/// </summary>
1313
/// <value>
1414
/// The current runtime.
1515
/// </value>
16-
public static Runtime Current => _currentRuntime.Value;
16+
public static SentryRuntime Current => _currentRuntime.Value;
1717

1818
/// <summary>
1919
/// The name of the runtime
@@ -62,7 +62,7 @@ public class Runtime : IEquatable<Runtime>
6262
/// Creates a new Runtime instance
6363
/// </summary>
6464
#if NETFRAMEWORK
65-
public Runtime(
65+
public SentryRuntime(
6666
string? name = null,
6767
string? version = null,
6868
FrameworkInstallation? frameworkInstallation = null,
@@ -75,7 +75,7 @@ public Runtime(
7575
Identifier = null;
7676
}
7777
#else
78-
public Runtime(
78+
public SentryRuntime(
7979
string? name = null,
8080
string? version = null,
8181
string? raw = null,
@@ -113,7 +113,7 @@ public Runtime(
113113
/// </summary>
114114
/// <param name="other">The instance to compare against.</param>
115115
/// <returns>True if the instances are equal by reference or its state.</returns>
116-
public bool Equals(Runtime? other)
116+
public bool Equals(SentryRuntime? other)
117117
{
118118
if (other is null)
119119
{
@@ -157,7 +157,7 @@ public override bool Equals(object? obj)
157157
return false;
158158
}
159159

160-
return Equals((Runtime)obj);
160+
return Equals((SentryRuntime)obj);
161161
}
162162

163163
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
namespace Sentry.PlatformAbstractions;
22

33
/// <summary>
4-
/// Extension method to the <see cref="Runtime"/> class.
4+
/// Extension method to the <see cref="SentryRuntime"/> class.
55
/// </summary>
66
[EditorBrowsable(EditorBrowsableState.Never)]
7-
public static class RuntimeExtensions
7+
public static class SentryRuntimeExtensions
88
{
99
/// <summary>
1010
/// Is the runtime instance .NET Framework.
1111
/// </summary>
1212
/// <param name="runtime">The runtime instance to check.</param>
1313
/// <returns>True if it's .NET Framework, otherwise false.</returns>
14-
public static bool IsNetFx(this Runtime runtime) => runtime.StartsWith(".NET Framework");
14+
public static bool IsNetFx(this SentryRuntime runtime) => runtime.StartsWith(".NET Framework");
1515

1616
/// <summary>
1717
/// Is the runtime instance .NET Core (or .NET).
1818
/// </summary>
1919
/// <param name="runtime">The runtime instance to check.</param>
2020
/// <returns>True if it's .NET Core (or .NET), otherwise false.</returns>
21-
public static bool IsNetCore(this Runtime runtime) =>
21+
public static bool IsNetCore(this SentryRuntime runtime) =>
2222
runtime.StartsWith(".NET Core") ||
2323
(runtime.StartsWith(".NET") && !runtime.StartsWith(".NET Framework"));
2424

@@ -27,16 +27,16 @@ public static bool IsNetCore(this Runtime runtime) =>
2727
/// </summary>
2828
/// <param name="runtime">The runtime instance to check.</param>
2929
/// <returns>True if it's Mono, otherwise false.</returns>
30-
public static bool IsMono(this Runtime runtime) => runtime.StartsWith("Mono");
30+
public static bool IsMono(this SentryRuntime runtime) => runtime.StartsWith("Mono");
3131

3232
/// <summary>
3333
/// Is the runtime instance Browser Web Assembly.
3434
/// </summary>
3535
/// <param name="runtime">The runtime instance to check.</param>
3636
/// <returns>True if it's Browser WASM, otherwise false.</returns>
37-
internal static bool IsBrowserWasm(this Runtime runtime) => runtime.Identifier == "browser-wasm";
37+
internal static bool IsBrowserWasm(this SentryRuntime runtime) => runtime.Identifier == "browser-wasm";
3838

39-
private static bool StartsWith(this Runtime? runtime, string runtimeName) =>
39+
private static bool StartsWith(this SentryRuntime? runtime, string runtimeName) =>
4040
runtime?.Name?.StartsWith(runtimeName, StringComparison.OrdinalIgnoreCase) == true ||
4141
runtime?.Raw?.StartsWith(runtimeName, StringComparison.OrdinalIgnoreCase) == true;
4242
}

src/Sentry/Protocol/SampleProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
3030
writer.WriteEndObject();
3131

3232
#if NETFRAMEWORK
33-
if (PlatformAbstractions.Runtime.Current.IsMono())
33+
if (PlatformAbstractions.SentryRuntime.Current.IsMono())
3434
{
3535
// STJ doesn't like HashableGrowableArray on Mono, failing with:
3636
// Invalid IL code in (wrapper dynamic-method) object:.ctor (): IL_0005: ret

src/Sentry/SentryOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool IsGlobalModeEnabled
6868
/// </summary>
6969
public bool IsGlobalModeEnabled
7070
{
71-
get => _isGlobalModeEnabled ??= Runtime.Current.IsBrowserWasm();
71+
get => _isGlobalModeEnabled ??= SentryRuntime.Current.IsBrowserWasm();
7272
set => _isGlobalModeEnabled = value;
7373
}
7474
#endif
@@ -938,7 +938,7 @@ public StackTraceMode StackTraceMode
938938
{
939939
// from 3.0.0 uses Enhanced (Ben.Demystifier) by default which is a breaking change
940940
// unless you are using .NET Native which isn't compatible with Ben.Demystifier.
941-
_stackTraceMode = Runtime.Current.Name == ".NET Native"
941+
_stackTraceMode = SentryRuntime.Current.Name == ".NET Native"
942942
? StackTraceMode.Original
943943
: StackTraceMode.Enhanced;
944944
}

src/Sentry/Span.cs renamed to src/Sentry/SentrySpan.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Sentry;
99
/// <summary>
1010
/// Transaction span.
1111
/// </summary>
12-
public class Span : ISpanData, IJsonSerializable
12+
public class SentrySpan : ISpanData, IJsonSerializable
1313
{
1414
/// <inheritdoc />
1515
public SpanId SpanId { get; private set; }
@@ -75,9 +75,9 @@ public void SetExtra(string key, object? value) =>
7575
(_extra ??= new Dictionary<string, object?>())[key] = value;
7676

7777
/// <summary>
78-
/// Initializes an instance of <see cref="Span"/>.
78+
/// Initializes an instance of <see cref="SentrySpan"/>.
7979
/// </summary>
80-
public Span(SpanId? parentSpanId, string operation)
80+
public SentrySpan(SpanId? parentSpanId, string operation)
8181
{
8282
SpanId = SpanId.Create();
8383
ParentSpanId = parentSpanId;
@@ -86,9 +86,9 @@ public Span(SpanId? parentSpanId, string operation)
8686
}
8787

8888
/// <summary>
89-
/// Initializes an instance of <see cref="Span"/>.
89+
/// Initializes an instance of <see cref="SentrySpan"/>.
9090
/// </summary>
91-
public Span(ISpan tracer)
91+
public SentrySpan(ISpan tracer)
9292
: this(tracer.ParentSpanId, tracer.Operation)
9393
{
9494
SpanId = tracer.SpanId;
@@ -141,7 +141,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
141141
/// <summary>
142142
/// Parses a span from JSON.
143143
/// </summary>
144-
public static Span FromJson(JsonElement json)
144+
public static SentrySpan FromJson(JsonElement json)
145145
{
146146
var spanId = json.GetPropertyOrNull("span_id")?.Pipe(SpanId.FromJson) ?? SpanId.Empty;
147147
var parentSpanId = json.GetPropertyOrNull("parent_span_id")?.Pipe(SpanId.FromJson);
@@ -156,7 +156,7 @@ public static Span FromJson(JsonElement json)
156156
var measurements = json.GetPropertyOrNull("measurements")?.GetDictionaryOrNull(Measurement.FromJson);
157157
var data = json.GetPropertyOrNull("data")?.GetDictionaryOrNull()?.ToDict();
158158

159-
return new Span(parentSpanId, operation)
159+
return new SentrySpan(parentSpanId, operation)
160160
{
161161
SpanId = spanId,
162162
TraceId = traceId,

src/Sentry/Transaction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ public IReadOnlyList<string> Fingerprint
184184
public IReadOnlyDictionary<string, string> Tags => _tags;
185185

186186
// Not readonly because of deserialization
187-
private Span[] _spans = Array.Empty<Span>();
187+
private SentrySpan[] _spans = Array.Empty<SentrySpan>();
188188

189189
/// <summary>
190190
/// Flat list of spans within this transaction.
191191
/// </summary>
192-
public IReadOnlyCollection<Span> Spans => _spans;
192+
public IReadOnlyCollection<SentrySpan> Spans => _spans;
193193

194194
/// <inheritdoc />
195195
public bool IsFinished => EndTimestamp is not null;
@@ -265,7 +265,7 @@ public Transaction(ITransactionTracer tracer)
265265
_tags = tracer.Tags.ToDict();
266266
_spans = tracer.Spans
267267
.Where(s => s is not SpanTracer { IsSentryRequest: true }) // Filter sentry requests created by Sentry.OpenTelemetry.SentrySpanProcessor
268-
.Select(s => new Span(s)).ToArray();
268+
.Select(s => new SentrySpan(s)).ToArray();
269269
_measurements = tracer.Measurements.ToDict();
270270

271271
// Some items are not on the interface, but we only ever pass in a TransactionTracer anyway.
@@ -383,7 +383,7 @@ public static Transaction FromJson(JsonElement json)
383383
var measurements = json.GetPropertyOrNull("measurements")?
384384
.GetDictionaryOrNull(Measurement.FromJson) ?? new();
385385
var spans = json.GetPropertyOrNull("spans")?
386-
.EnumerateArray().Select(Span.FromJson).ToArray() ?? Array.Empty<Span>();
386+
.EnumerateArray().Select(SentrySpan.FromJson).ToArray() ?? Array.Empty<SentrySpan>();
387387

388388
return new Transaction(name, nameSource)
389389
{

0 commit comments

Comments
 (0)