Skip to content

Commit

Permalink
PR feedback - no null for RegisterSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Sep 17, 2024
1 parent b2e3005 commit fe4d9bf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static OpenTelemetry.Context.RuntimeContext.ContextSlotType.set -> void
static OpenTelemetry.Context.RuntimeContext.GetSlot<T>(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot<T>!
static OpenTelemetry.Context.RuntimeContext.GetValue(string! slotName) -> object?
static OpenTelemetry.Context.RuntimeContext.GetValue<T>(string! slotName) -> T?
static OpenTelemetry.Context.RuntimeContext.RegisterSlot<T>(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot<T>?
static OpenTelemetry.Context.RuntimeContext.RegisterSlot<T>(string! slotName) -> OpenTelemetry.Context.RuntimeContextSlot<T>!
static OpenTelemetry.Context.RuntimeContext.SetValue(string! slotName, object? value) -> void
static OpenTelemetry.Context.RuntimeContext.SetValue<T>(string! slotName, T? value) -> void
static OpenTelemetry.Trace.ActivityExtensions.GetStatus(this System.Diagnostics.Activity? activity) -> OpenTelemetry.Trace.Status
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Api/Baggage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace OpenTelemetry;
/// </remarks>
public readonly struct Baggage : IEquatable<Baggage>
{
private static readonly RuntimeContextSlot<BaggageHolder> RuntimeContextSlot = RuntimeContext.RegisterSlot<BaggageHolder>("otel.baggage")!;
private static readonly RuntimeContextSlot<BaggageHolder> RuntimeContextSlot = RuntimeContext.RegisterSlot<BaggageHolder>("otel.baggage");
private static readonly Dictionary<string, string> EmptyBaggage = new();

private readonly Dictionary<string, string> baggage;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Context/RuntimeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static Type ContextSlotType
/// <param name="slotName">The name of the context slot.</param>
/// <typeparam name="T">The type of the underlying value.</typeparam>
/// <returns>The slot registered.</returns>
public static RuntimeContextSlot<T>? RegisterSlot<T>(string slotName)
public static RuntimeContextSlot<T> RegisterSlot<T>(string slotName)
{
Guard.ThrowIfNullOrEmpty(slotName);
RuntimeContextSlot<T>? slot = null;
Expand Down Expand Up @@ -82,7 +82,7 @@ public static Type ContextSlotType
#endif

Slots[slotName] = slot!;
return slot;
return slot!;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Metrics/PullMetricScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace OpenTelemetry.Metrics;

internal sealed class PullMetricScope : IDisposable
{
private static readonly RuntimeContextSlot<bool> Slot = RuntimeContext.RegisterSlot<bool>("otel.pull_metric")!;
private static readonly RuntimeContextSlot<bool> Slot = RuntimeContext.RegisterSlot<bool>("otel.pull_metric");

private readonly bool previousValue;
private bool disposed;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/SuppressInstrumentationScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SuppressInstrumentationScope?> Slot = RuntimeContext.RegisterSlot<SuppressInstrumentationScope?>("otel.suppress_instrumentation")!;
private static readonly RuntimeContextSlot<SuppressInstrumentationScope?> Slot = RuntimeContext.RegisterSlot<SuppressInstrumentationScope?>("otel.suppress_instrumentation");

private readonly SuppressInstrumentationScope? previousScope;
private bool disposed;
Expand Down

0 comments on commit fe4d9bf

Please sign in to comment.