Skip to content

Commit

Permalink
updated OpenTelemetry.Api files to use file scoped namespaces (#4663)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-lt committed Jul 18, 2023
1 parent bb45af2 commit 67bd46d
Show file tree
Hide file tree
Showing 54 changed files with 4,793 additions and 4,847 deletions.
23 changes: 11 additions & 12 deletions src/OpenTelemetry.Api/ActivityContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@
// same namespace as Activity to prevent name collisions in the future.
// The OpenTelemetry namespace is used because ActivityContext applies to all types
// of telemetry data - i.e. traces, metrics, and logs.
namespace OpenTelemetry
namespace OpenTelemetry;

/// <summary>
/// Extension methods on ActivityContext.
/// </summary>
public static class ActivityContextExtensions
{
/// <summary>
/// Extension methods on ActivityContext.
/// Returns a bool indicating if a ActivityContext is valid or not.
/// </summary>
public static class ActivityContextExtensions
/// <param name="ctx">ActivityContext.</param>
/// <returns>whether the context is a valid one or not.</returns>
public static bool IsValid(this ActivityContext ctx)
{
/// <summary>
/// Returns a bool indicating if a ActivityContext is valid or not.
/// </summary>
/// <param name="ctx">ActivityContext.</param>
/// <returns>whether the context is a valid one or not.</returns>
public static bool IsValid(this ActivityContext ctx)
{
return ctx != default;
}
return ctx != default;
}
}
597 changes: 298 additions & 299 deletions src/OpenTelemetry.Api/Baggage.cs

Large diffs are not rendered by default.

45 changes: 22 additions & 23 deletions src/OpenTelemetry.Api/BaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,33 @@
// limitations under the License.
// </copyright>

namespace OpenTelemetry
namespace OpenTelemetry;

/// <summary>
/// Contains logic shared by all OpenTelemetry providers.
/// </summary>
public abstract class BaseProvider : IDisposable
{
/// <summary>
/// Contains logic shared by all OpenTelemetry providers.
/// Finalizes an instance of the <see cref="BaseProvider"/> class.
/// </summary>
public abstract class BaseProvider : IDisposable
~BaseProvider()
{
/// <summary>
/// Finalizes an instance of the <see cref="BaseProvider"/> class.
/// </summary>
~BaseProvider()
{
this.Dispose(false);
}
this.Dispose(false);
}

/// <inheritdoc/>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
/// <inheritdoc/>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Releases the unmanaged resources used by this class and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
}
/// <summary>
/// Releases the unmanaged resources used by this class and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
}
}
65 changes: 32 additions & 33 deletions src/OpenTelemetry.Api/Context/AsyncLocalRuntimeContextSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,44 @@

using System.Runtime.CompilerServices;

namespace OpenTelemetry.Context
namespace OpenTelemetry.Context;

/// <summary>
/// The async local implementation of context slot.
/// </summary>
/// <typeparam name="T">The type of the underlying value.</typeparam>
public class AsyncLocalRuntimeContextSlot<T> : RuntimeContextSlot<T>, IRuntimeContextSlotValueAccessor
{
private readonly AsyncLocal<T> slot;

/// <summary>
/// The async local implementation of context slot.
/// Initializes a new instance of the <see cref="AsyncLocalRuntimeContextSlot{T}"/> class.
/// </summary>
/// <typeparam name="T">The type of the underlying value.</typeparam>
public class AsyncLocalRuntimeContextSlot<T> : RuntimeContextSlot<T>, IRuntimeContextSlotValueAccessor
/// <param name="name">The name of the context slot.</param>
public AsyncLocalRuntimeContextSlot(string name)
: base(name)
{
private readonly AsyncLocal<T> slot;

/// <summary>
/// Initializes a new instance of the <see cref="AsyncLocalRuntimeContextSlot{T}"/> class.
/// </summary>
/// <param name="name">The name of the context slot.</param>
public AsyncLocalRuntimeContextSlot(string name)
: base(name)
{
this.slot = new AsyncLocal<T>();
}
this.slot = new AsyncLocal<T>();
}

/// <inheritdoc/>
public object Value
{
get => this.slot.Value;
set => this.slot.Value = (T)value;
}
/// <inheritdoc/>
public object Value
{
get => this.slot.Value;
set => this.slot.Value = (T)value;
}

/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override T Get()
{
return this.slot.Value;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override T Get()
{
return this.slot.Value;
}

/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Set(T value)
{
this.slot.Value = value;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Set(T value)
{
this.slot.Value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
// limitations under the License.
// </copyright>

namespace OpenTelemetry.Context
namespace OpenTelemetry.Context;

/// <summary>
/// Describes a type of <see cref="RuntimeContextSlot{T}"/> which can expose its value as an <see cref="object"/>.
/// </summary>
public interface IRuntimeContextSlotValueAccessor
{
/// <summary>
/// Describes a type of <see cref="RuntimeContextSlot{T}"/> which can expose its value as an <see cref="object"/>.
/// Gets or sets the value of the slot as an <see cref="object"/>.
/// </summary>
public interface IRuntimeContextSlotValueAccessor
{
/// <summary>
/// Gets or sets the value of the slot as an <see cref="object"/>.
/// </summary>
object Value { get; set; }
}
object Value { get; set; }
}

0 comments on commit 67bd46d

Please sign in to comment.