Skip to content

Commit

Permalink
[repo] Simplify preprocessor directives after dropping support for .N…
Browse files Browse the repository at this point in the history
…ET 6 and .NET7 (#5851)

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
  • Loading branch information
Kielek and CodeBlanch committed Sep 20, 2024
1 parent b941f1e commit 86c1d8c
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
#if NET && EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
#endif
using OpenTelemetry.Internal;
Expand All @@ -19,7 +19,7 @@ namespace OpenTelemetry.Logs;
/// Stores attributes to be added to a log message.
/// </summary>
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Logs/LogRecordData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#nullable enable

using System.Diagnostics;
#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
#if NET && EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -16,7 +16,7 @@ namespace OpenTelemetry.Logs;
/// Stores details about a log message.
/// </summary>
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
#if NET && EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs;
/// Describes the severity level of a log record.
/// </summary>
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
#if NET && EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs;
/// Contains extension methods for the <see cref="LogRecordSeverity"/> enum.
/// </summary>
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Api/Logs/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
#if NET && EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs;
/// Logger is the class responsible for creating log records.
/// </summary>
/// <remarks><b>WARNING</b>: This is an experimental API which might change or be removed in the future. Use at your own risk.</remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
10 changes: 5 additions & 5 deletions src/OpenTelemetry.Api/Logs/LoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#if NETSTANDARD2_1_OR_GREATER || NET
using System.Diagnostics.CodeAnalysis;
#endif
#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using OpenTelemetry.Internal;
#endif

Expand All @@ -32,7 +32,7 @@ protected LoggerProvider()
/// </summary>
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
/// <returns><see cref="Logger"/> instance.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -49,7 +49,7 @@ Logger GetLogger()
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
/// <param name="name">Optional name identifying the instrumentation library.</param>
/// <returns><see cref="Logger"/> instance.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -67,7 +67,7 @@ Logger GetLogger(string? name)
/// <param name="name">Optional name identifying the instrumentation library.</param>
/// <param name="version">Optional version of the instrumentation library.</param>
/// <returns><see cref="Logger"/> instance.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -94,7 +94,7 @@ Logger GetLogger(string? name, string? version)
/// <param name="name">Optional name identifying the instrumentation library.</param>
/// <param name="logger"><see cref="Logger"/>.</param>
/// <returns><see langword="true"/> if the logger was created.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
protected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task InvokeAsync(HttpContext httpContext)
if (dataView.Count > 0)
{
response.StatusCode = 200;
#if NET8_0_OR_GREATER
#if NET
response.Headers.Append("Last-Modified", collectionResponse.GeneratedAtUtc.ToString("R"));
#else
response.Headers.Add("Last-Modified", collectionResponse.GeneratedAtUtc.ToString("R"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static ILoggingBuilder AddOpenTelemetry(
/// </remarks>
/// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param>
/// <returns>The supplied <see cref="ILoggingBuilder"/> for call chaining.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -90,7 +90,7 @@ static ILoggingBuilder UseOpenTelemetry(
/// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param>
/// <param name="configure"><see cref="LoggerProviderBuilder"/> configuration action.</param>
/// <returns>The supplied <see cref="ILoggingBuilder"/> for call chaining.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -115,7 +115,7 @@ static ILoggingBuilder UseOpenTelemetry(
/// <param name="configureBuilder">Optional <see cref="LoggerProviderBuilder"/> configuration action.</param>
/// <param name="configureOptions">Optional <see cref="OpenTelemetryLoggerOptions"/> configuration action.</param>
/// <returns>The supplied <see cref="ILoggingBuilder"/> for call chaining.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
8 changes: 4 additions & 4 deletions src/OpenTelemetry/Logs/LogRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
#endif
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -355,7 +355,7 @@ public Exception? Exception
/// known at the source.
/// </summary>
/// <remarks><inheritdoc cref="Sdk.CreateLoggerProviderBuilder" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand All @@ -377,7 +377,7 @@ public Exception? Exception
/// Gets or sets the log <see cref="LogRecordSeverity"/>.
/// </summary>
/// <remarks><inheritdoc cref="Sdk.CreateLoggerProviderBuilder" path="/remarks"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down Expand Up @@ -405,7 +405,7 @@ public Exception? Exception
/// typically the <see cref="Logs.Logger"/> which emitted the <see
/// cref="LogRecord"/> however the value may be different if <see
/// cref="CategoryName"/> is modified.</remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public Logger Logger { get; internal set; } = InstrumentationScopeLogger.Default;
Expand Down
6 changes: 3 additions & 3 deletions src/OpenTelemetry/Metrics/AggregatorStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Collections.Concurrent;
#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand All @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics;

internal sealed class AggregatorStore
{
#if NET8_0_OR_GREATER
#if NET
internal readonly FrozenSet<string>? TagKeysInteresting;
#else
internal readonly HashSet<string>? TagKeysInteresting;
Expand Down Expand Up @@ -96,7 +96,7 @@ internal AggregatorStore(
{
this.updateLongCallback = this.UpdateLongCustomTags;
this.updateDoubleCallback = this.UpdateDoubleCustomTags;
#if NET8_0_OR_GREATER
#if NET
var hs = FrozenSet.ToFrozenSet(metricStreamIdentity.TagKeys, StringComparer.Ordinal);
#else
var hs = new HashSet<string>(metricStreamIdentity.TagKeys, StringComparer.Ordinal);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand All @@ -17,7 +17,7 @@ namespace OpenTelemetry.Metrics;
/// </remarks>
public struct Exemplar
{
#if NET8_0_OR_GREATER
#if NET
internal FrozenSet<string>? ViewDefinedTagKeys;
#else
internal HashSet<string>? ViewDefinedTagKeys;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/Exemplar/ExemplarMeasurement.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics;
/// </summary>
/// <remarks><inheritdoc cref="ExemplarReservoir" path="/remarks/para[@experimental-warning='true']"/></remarks>
/// <typeparam name="T">Measurement type.</typeparam>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/Exemplar/ExemplarReservoir.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
using OpenTelemetry.Internal;
#endif
Expand All @@ -17,7 +17,7 @@ namespace OpenTelemetry.Metrics;
/// Specification: <see
/// href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplarreservoir"/>.
/// </remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
#endif
using OpenTelemetry.Internal;
Expand All @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics;
/// number of <see cref="Exemplar"/>s.
/// </summary>
/// <remarks><inheritdoc cref="ExemplarReservoir" path="/remarks/para[@experimental-warning='true']"/></remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/ThreadStaticStorage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand Down Expand Up @@ -57,7 +57,7 @@ internal void SplitToKeysAndValues(
internal void SplitToKeysAndValues(
ReadOnlySpan<KeyValuePair<string, object?>> tags,
int tagLength,
#if NET8_0_OR_GREATER
#if NET
FrozenSet<string> tagKeysInteresting,
#else
HashSet<string> tagKeysInteresting,
Expand Down
6 changes: 3 additions & 3 deletions src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
#endif
using OpenTelemetry.Internal;
Expand Down Expand Up @@ -116,7 +116,7 @@ public string[]? TagKeys
/// If not set the default
/// MeterProvider cardinality limit of 2000 will apply.
/// </remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.CardinalityLimitExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down Expand Up @@ -151,7 +151,7 @@ public string[]? TagKeys
/// Specification: <see
/// href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#stream-configuration"/>.
/// </remarks>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public Func<ExemplarReservoir?>? ExemplarReservoirFactory { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if NET8_0_OR_GREATER
#if NET
using System.Collections.Frozen;
#endif
using System.Diagnostics;
Expand All @@ -16,7 +16,7 @@ namespace OpenTelemetry;
// prevent accidental boxing.
public readonly struct ReadOnlyFilteredTagCollection
{
#if NET8_0_OR_GREATER
#if NET
private readonly FrozenSet<string>? excludedKeys;
#else
private readonly HashSet<string>? excludedKeys;
Expand All @@ -25,7 +25,7 @@ public readonly struct ReadOnlyFilteredTagCollection
private readonly int count;

internal ReadOnlyFilteredTagCollection(
#if NET8_0_OR_GREATER
#if NET
FrozenSet<string>? excludedKeys,
#else
HashSet<string>? excludedKeys,
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Sdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
#if EXPOSE_EXPERIMENTAL_FEATURES && NET
using System.Diagnostics.CodeAnalysis;
#endif
using OpenTelemetry.Context.Propagation;
Expand Down Expand Up @@ -89,7 +89,7 @@ public static TracerProviderBuilder CreateTracerProviderBuilder()
/// <remarks><b>WARNING</b>: This is an experimental API which might change or be removed in the future. Use at your own risk.</remarks>
/// <returns><see cref="LoggerProviderBuilder"/> instance, which is used
/// to build a <see cref="LoggerProvider"/>.</returns>
#if NET8_0_OR_GREATER
#if NET
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
Expand Down
Loading

0 comments on commit 86c1d8c

Please sign in to comment.