From fe4d9bf9e1740bdd673aa0ae68281d1678f39bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 17 Sep 2024 10:45:29 +0200 Subject: [PATCH] PR feedback - no null for RegisterSlot --- src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt | 2 +- src/OpenTelemetry.Api/Baggage.cs | 2 +- src/OpenTelemetry.Api/Context/RuntimeContext.cs | 4 ++-- src/OpenTelemetry/Metrics/PullMetricScope.cs | 2 +- src/OpenTelemetry/SuppressInstrumentationScope.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt index 42297162a89..a91d4359e52 100644 --- a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt @@ -205,7 +205,7 @@ static OpenTelemetry.Context.RuntimeContext.ContextSlotType.set -> void static OpenTelemetry.Context.RuntimeContext.GetSlot(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot! static OpenTelemetry.Context.RuntimeContext.GetValue(string! slotName) -> object? static OpenTelemetry.Context.RuntimeContext.GetValue(string! slotName) -> T? -static OpenTelemetry.Context.RuntimeContext.RegisterSlot(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot? +static OpenTelemetry.Context.RuntimeContext.RegisterSlot(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot! static OpenTelemetry.Context.RuntimeContext.SetValue(string! slotName, object? value) -> void static OpenTelemetry.Context.RuntimeContext.SetValue(string! slotName, T? value) -> void static OpenTelemetry.Trace.ActivityExtensions.GetStatus(this System.Diagnostics.Activity? activity) -> OpenTelemetry.Trace.Status diff --git a/src/OpenTelemetry.Api/Baggage.cs b/src/OpenTelemetry.Api/Baggage.cs index 7722dc06a84..bfd607e835d 100644 --- a/src/OpenTelemetry.Api/Baggage.cs +++ b/src/OpenTelemetry.Api/Baggage.cs @@ -15,7 +15,7 @@ namespace OpenTelemetry; /// public readonly struct Baggage : IEquatable { - private static readonly RuntimeContextSlot RuntimeContextSlot = RuntimeContext.RegisterSlot("otel.baggage")!; + private static readonly RuntimeContextSlot RuntimeContextSlot = RuntimeContext.RegisterSlot("otel.baggage"); private static readonly Dictionary EmptyBaggage = new(); private readonly Dictionary baggage; diff --git a/src/OpenTelemetry.Api/Context/RuntimeContext.cs b/src/OpenTelemetry.Api/Context/RuntimeContext.cs index 539b301f77d..3acc0cd21c2 100644 --- a/src/OpenTelemetry.Api/Context/RuntimeContext.cs +++ b/src/OpenTelemetry.Api/Context/RuntimeContext.cs @@ -53,7 +53,7 @@ public static Type ContextSlotType /// The name of the context slot. /// The type of the underlying value. /// The slot registered. - public static RuntimeContextSlot? RegisterSlot(string slotName) + public static RuntimeContextSlot RegisterSlot(string slotName) { Guard.ThrowIfNullOrEmpty(slotName); RuntimeContextSlot? slot = null; @@ -82,7 +82,7 @@ public static Type ContextSlotType #endif Slots[slotName] = slot!; - return slot; + return slot!; } } diff --git a/src/OpenTelemetry/Metrics/PullMetricScope.cs b/src/OpenTelemetry/Metrics/PullMetricScope.cs index d445cb42bd4..89f624cca30 100644 --- a/src/OpenTelemetry/Metrics/PullMetricScope.cs +++ b/src/OpenTelemetry/Metrics/PullMetricScope.cs @@ -7,7 +7,7 @@ namespace OpenTelemetry.Metrics; internal sealed class PullMetricScope : IDisposable { - private static readonly RuntimeContextSlot Slot = RuntimeContext.RegisterSlot("otel.pull_metric")!; + private static readonly RuntimeContextSlot Slot = RuntimeContext.RegisterSlot("otel.pull_metric"); private readonly bool previousValue; private bool disposed; diff --git a/src/OpenTelemetry/SuppressInstrumentationScope.cs b/src/OpenTelemetry/SuppressInstrumentationScope.cs index f46b90a1f50..68168bc79d1 100644 --- a/src/OpenTelemetry/SuppressInstrumentationScope.cs +++ b/src/OpenTelemetry/SuppressInstrumentationScope.cs @@ -15,7 +15,7 @@ public sealed class SuppressInstrumentationScope : IDisposable // * null: instrumentation is not suppressed // * Depth = [int.MinValue, -1]: instrumentation is always suppressed // * Depth = [1, int.MaxValue]: instrumentation is suppressed in a reference-counting mode - private static readonly RuntimeContextSlot Slot = RuntimeContext.RegisterSlot("otel.suppress_instrumentation")!; + private static readonly RuntimeContextSlot Slot = RuntimeContext.RegisterSlot("otel.suppress_instrumentation"); private readonly SuppressInstrumentationScope? previousScope; private bool disposed;