diff --git a/.github/workflows/Component.BuildTest.yml b/.github/workflows/Component.BuildTest.yml index 557817de73a..99f95049997 100644 --- a/.github/workflows/Component.BuildTest.yml +++ b/.github/workflows/Component.BuildTest.yml @@ -24,7 +24,7 @@ on: required: false type: string tfm-list: - default: '[ "net462", "net8.0", "net9.0", "net10.0" ]' + default: '[ "net462", "net10.0", "net11.0" ]' required: false type: string trigger: @@ -75,8 +75,7 @@ jobs: uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0 with: dotnet-version: | - 8.0.x - 9.0.x + 10.0.x - name: Setup .NET uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82ba7376da8..00217c208c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,7 +170,7 @@ jobs: strategy: fail-fast: ${{ github.event_name == 'merge_group' }} matrix: - version: [ net8.0, net9.0, net10.0 ] + version: [ net10.0, net11.0 ] env: FRAMEWORK_VERSION: ${{ matrix.version }} steps: @@ -198,7 +198,7 @@ jobs: strategy: fail-fast: ${{ github.event_name == 'merge_group' }} matrix: - version: [ net8.0, net9.0, net10.0 ] + version: [ net10.0, net11.0 ] steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -240,7 +240,7 @@ jobs: - name: Run benchmarks shell: pwsh run: | - $runtimes = @("net10.0") + $runtimes = @("net11.0") if ($IsWindows) { $runtimes += "net462" } diff --git a/.github/workflows/concurrency-tests.yml b/.github/workflows/concurrency-tests.yml index b16fd91468d..34c9b220dff 100644 --- a/.github/workflows/concurrency-tests.yml +++ b/.github/workflows/concurrency-tests.yml @@ -24,7 +24,7 @@ jobs: - ubuntu-24.04 # renovate: datasource=github-runners depType=github-runner - windows-2025 - version: [ net8.0, net10.0 ] + version: [ net10.0, net11.0 ] project: [ OpenTelemetry.Tests, OpenTelemetry.Api.Tests ] runs-on: ${{ matrix.os }} diff --git a/.github/workflows/verifyaotcompat.yml b/.github/workflows/verifyaotcompat.yml index c6b5d274511..de48729c997 100644 --- a/.github/workflows/verifyaotcompat.yml +++ b/.github/workflows/verifyaotcompat.yml @@ -22,7 +22,7 @@ jobs: - ubuntu-24.04 # renovate: datasource=github-runners depType=github-runner - windows-2025 - version: [ net8.0, net9.0, net10.0 ] + version: [ net10.0, net11.0 ] runs-on: ${{ matrix.os }} steps: diff --git a/AGENTS.md b/AGENTS.md index 2827d725ffb..b28f339e403 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,7 +29,7 @@ dotnet test test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj --filter "FullyQ **Test for a specific TFM** (Windows also supports `net462`): ```sh -dotnet test --framework net10.0 +dotnet test --framework net11.0 ``` **Check code formatting:** diff --git a/Directory.Packages.props b/Directory.Packages.props index 93c36b9acd1..be2c1804663 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,27 +12,13 @@ --> - - - - - + + + + + - - - - - - - - - - - - - - @@ -40,6 +26,13 @@ + + + + + + + - + - - - + preview true $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName) $(MSBuildThisFileDirectory)OpenTelemetry.snk.base64 @@ -97,19 +98,19 @@ finally net481;net48;net472;net471;net47;net462 - net10.0;net9.0;net8.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net10.0;net9.0;net8.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net10.0;net9.0;net8.0 + net11.0;net10.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net11.0;net10.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net11.0;net10.0 netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net10.0;net9.0;net8.0 - net10.0;net9.0;net8.0 - net10.0;net9.0;net8.0 + net11.0;net10.0 + net11.0;net10.0 + net11.0;net10.0 $(TargetFrameworksForDocs);$(NetFrameworkSupportedVersions) - net10.0;net9.0;net8.0 + net11.0;net10.0 $(TargetFrameworksForTests);$(NetFrameworkMinimumSupportedVersion) diff --git a/build/docker-compose.net10.0.yml b/build/docker-compose.net10.0.yml index 70429a07f5d..48daaa7b834 100644 --- a/build/docker-compose.net10.0.yml +++ b/build/docker-compose.net10.0.yml @@ -4,4 +4,4 @@ services: args: PUBLISH_FRAMEWORK: net10.0 TEST_SDK_VERSION: "10.0" - BUILD_SDK_VERSION: "10.0" + BUILD_SDK_VERSION: "11.0" diff --git a/build/docker-compose.net11.0.yml b/build/docker-compose.net11.0.yml new file mode 100644 index 00000000000..b05e860ccee --- /dev/null +++ b/build/docker-compose.net11.0.yml @@ -0,0 +1,7 @@ +services: + tests: + build: + args: + PUBLISH_FRAMEWORK: net11.0 + TEST_SDK_VERSION: "11.0" + BUILD_SDK_VERSION: "11.0" diff --git a/build/docker-compose.net8.0.yml b/build/docker-compose.net8.0.yml deleted file mode 100644 index 930c9f138fb..00000000000 --- a/build/docker-compose.net8.0.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - tests: - build: - args: - PUBLISH_FRAMEWORK: net8.0 - TEST_SDK_VERSION: "8.0" - BUILD_SDK_VERSION: "10.0" diff --git a/build/docker-compose.net9.0.yml b/build/docker-compose.net9.0.yml deleted file mode 100644 index 10a6dc5cf2c..00000000000 --- a/build/docker-compose.net9.0.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - tests: - build: - args: - PUBLISH_FRAMEWORK: net9.0 - TEST_SDK_VERSION: "9.0" - BUILD_SDK_VERSION: "10.0" diff --git a/examples/MicroserviceExample/Utils/Utils.csproj b/examples/MicroserviceExample/Utils/Utils.csproj index 1c95380e4c9..8681d956453 100644 --- a/examples/MicroserviceExample/Utils/Utils.csproj +++ b/examples/MicroserviceExample/Utils/Utils.csproj @@ -4,7 +4,6 @@ - diff --git a/examples/MicroserviceExample/WebApi/Dockerfile b/examples/MicroserviceExample/WebApi/Dockerfile index 12e3943eb62..7af0dade2cb 100644 --- a/examples/MicroserviceExample/WebApi/Dockerfile +++ b/examples/MicroserviceExample/WebApi/Dockerfile @@ -1,18 +1,16 @@ -ARG SDK_VERSION=10.0 -FROM mcr.microsoft.com/dotnet/sdk:8.0.423@sha256:89ce6291bde9acdf59594e79fb8277c6d84c46e4b1f5bf126a4f18766e4bd597 AS dotnet-sdk-8.0 -FROM mcr.microsoft.com/dotnet/sdk:9.0.316@sha256:ee0d20fbc3dfc60ae2d9d9115a9b750c18576a47f24073119dd09d93e072cb89 AS dotnet-sdk-9.0 +ARG SDK_VERSION=11.0 FROM mcr.microsoft.com/dotnet/sdk:10.0.302@sha256:ed034a8bf0b24ded0cbbac07e17825d8e9ebfe21e308191d0f7421eaf5ad4664 AS dotnet-sdk-10.0 +FROM mcr.microsoft.com/dotnet/sdk:11.0.100-preview.6@sha256:030c48b4cf79d68d5cae35afb9e529ce66bc7d40397ac11a8a52fc8e14ced226 AS dotnet-sdk-11.0 FROM dotnet-sdk-${SDK_VERSION} AS build ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net10.0 +ARG PUBLISH_FRAMEWORK=net11.0 WORKDIR /app COPY . ./ RUN dotnet publish ./examples/MicroserviceExample/WebApi -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true -FROM mcr.microsoft.com/dotnet/aspnet:8.0.29@sha256:9822a6201c64c9f38b8a190832a7ae21cd30150d509b3ea170fd83b4f4e6166a AS dotnet-aspnet-8.0 -FROM mcr.microsoft.com/dotnet/aspnet:9.0.18@sha256:8b9f90e53d41154d42e537517aef22e8fe497baabd43e423d5f2edafd06f04f6 AS dotnet-aspnet-9.0 FROM mcr.microsoft.com/dotnet/aspnet:10.0.10@sha256:1fa23fc4872d95fd71c2833ebe65d7e84a43b2d51a31d119516852f13d9505a7 AS dotnet-aspnet-10.0 +FROM mcr.microsoft.com/dotnet/aspnet:11.0.0-preview.6@sha256:b2ebd23166ecc80db02c1086ccfdf266ce738d315036f44303bd2e03bd9d7907 AS dotnet-aspnet-11.0 FROM dotnet-aspnet-${SDK_VERSION} AS runtime WORKDIR /app diff --git a/examples/MicroserviceExample/WorkerService/Dockerfile b/examples/MicroserviceExample/WorkerService/Dockerfile index 62b19187081..7ff9a78d148 100644 --- a/examples/MicroserviceExample/WorkerService/Dockerfile +++ b/examples/MicroserviceExample/WorkerService/Dockerfile @@ -1,19 +1,17 @@ -ARG SDK_VERSION=10.0 +ARG SDK_VERSION=11.0 -FROM mcr.microsoft.com/dotnet/sdk:8.0.423@sha256:89ce6291bde9acdf59594e79fb8277c6d84c46e4b1f5bf126a4f18766e4bd597 AS dotnet-sdk-8.0 -FROM mcr.microsoft.com/dotnet/sdk:9.0.316@sha256:ee0d20fbc3dfc60ae2d9d9115a9b750c18576a47f24073119dd09d93e072cb89 AS dotnet-sdk-9.0 FROM mcr.microsoft.com/dotnet/sdk:10.0.302@sha256:ed034a8bf0b24ded0cbbac07e17825d8e9ebfe21e308191d0f7421eaf5ad4664 AS dotnet-sdk-10.0 +FROM mcr.microsoft.com/dotnet/sdk:11.0.100-preview.6@sha256:030c48b4cf79d68d5cae35afb9e529ce66bc7d40397ac11a8a52fc8e14ced226 AS dotnet-sdk-11.0 FROM dotnet-sdk-${SDK_VERSION} AS build ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net10.0 +ARG PUBLISH_FRAMEWORK=net11.0 WORKDIR /app COPY . ./ RUN dotnet publish ./examples/MicroserviceExample/WorkerService -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /out -p:IntegrationBuild=true -FROM mcr.microsoft.com/dotnet/aspnet:8.0.29@sha256:9822a6201c64c9f38b8a190832a7ae21cd30150d509b3ea170fd83b4f4e6166a AS dotnet-aspnet-8.0 -FROM mcr.microsoft.com/dotnet/aspnet:9.0.18@sha256:8b9f90e53d41154d42e537517aef22e8fe497baabd43e423d5f2edafd06f04f6 AS dotnet-aspnet-9.0 FROM mcr.microsoft.com/dotnet/aspnet:10.0.10@sha256:1fa23fc4872d95fd71c2833ebe65d7e84a43b2d51a31d119516852f13d9505a7 AS dotnet-aspnet-10.0 +FROM mcr.microsoft.com/dotnet/aspnet:11.0.0-preview.6@sha256:b2ebd23166ecc80db02c1086ccfdf266ce738d315036f44303bd2e03bd9d7907 AS dotnet-aspnet-11.0 FROM dotnet-aspnet-${SDK_VERSION} AS runtime WORKDIR /app diff --git a/global.json b/global.json index 5dfc94c8e99..f27c3c0cb0c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "allowPrerelease": false, - "version": "10.0.302" + "version": "11.0.100-preview.6.26359.118" } } diff --git a/src/OpenTelemetry.Api/CompatibilitySuppressions.xml b/src/OpenTelemetry.Api/CompatibilitySuppressions.xml new file mode 100644 index 00000000000..c720e262130 --- /dev/null +++ b/src/OpenTelemetry.Api/CompatibilitySuppressions.xml @@ -0,0 +1,31 @@ + + + + CP0008 + T:OpenTelemetry.Trace.SpanKind + lib/net8.0/OpenTelemetry.Api.dll + lib/netstandard2.0/OpenTelemetry.Api.dll + true + + + CP0008 + T:OpenTelemetry.Trace.StatusCode + lib/net8.0/OpenTelemetry.Api.dll + lib/netstandard2.0/OpenTelemetry.Api.dll + true + + + CP0008 + T:OpenTelemetry.Trace.SpanKind + lib/net9.0/OpenTelemetry.Api.dll + lib/netstandard2.0/OpenTelemetry.Api.dll + true + + + CP0008 + T:OpenTelemetry.Trace.StatusCode + lib/net9.0/OpenTelemetry.Api.dll + lib/netstandard2.0/OpenTelemetry.Api.dll + true + + diff --git a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs index e14931943e2..db4feeae7cd 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs @@ -38,7 +38,7 @@ public sealed class B3Propagator : TextMapPropagator private static readonly HashSet AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags]; - private static readonly HashSet SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue }; + private static readonly HashSet SampledValues = [with(StringComparer.Ordinal), SampledValue, LegacySampledValue]; private readonly bool singleHeader; diff --git a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs index 145213af1fb..adac5d7c8f7 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs @@ -243,7 +243,7 @@ internal static bool TryExtractBaggage( continue; } - baggageDictionary ??= new(StringComparer.Ordinal); + baggageDictionary ??= [with(StringComparer.Ordinal)]; baggageDictionary[key] = value; } } diff --git a/src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs index 7e79c61d80d..0e08ab6ac12 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs @@ -142,8 +142,6 @@ static void WriteTraceParentIntoSpan(Span destination, ActivityContext con context.SpanId.ToHexString().CopyTo(destination.Slice(36)); - // https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3867 - // will change this code to use ActivityTraceFlags.RandomTraceId instead of 2. // If new enum values are added in the future the Fallback path will ensure // that the handling is functionally correct, but the condition should be updated // to include the new value(s) for better readability and performance where possible. @@ -151,11 +149,11 @@ static void WriteTraceParentIntoSpan(Span destination, ActivityContext con { "-01".CopyTo(destination[52..]); } - else if (context.TraceFlags == (ActivityTraceFlags)2) + else if (context.TraceFlags == ActivityTraceFlags.RandomTraceId) { "-02".CopyTo(destination[52..]); } - else if (context.TraceFlags == (ActivityTraceFlags.Recorded | (ActivityTraceFlags)2)) + else if (context.TraceFlags == (ActivityTraceFlags.Recorded | ActivityTraceFlags.RandomTraceId)) { "-03".CopyTo(destination[52..]); } @@ -170,8 +168,6 @@ static void WriteTraceParentIntoSpan(Span destination, ActivityContext con #else static string FormatActivityTraceFlags(ActivityTraceFlags flags) { - // https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3867 - // will change this code to use ActivityTraceFlags.RandomTraceId instead of 2. // If new enum values are added in the future the Fallback path will ensure // that the handling is functionally correct, but the switch should be updated // to include the new value(s) for better readability and performance where possible. @@ -179,8 +175,8 @@ static string FormatActivityTraceFlags(ActivityTraceFlags flags) { ActivityTraceFlags.None => "-00", ActivityTraceFlags.Recorded => "-01", - (ActivityTraceFlags)2 => "-02", - ActivityTraceFlags.Recorded | (ActivityTraceFlags)2 => "-03", + ActivityTraceFlags.RandomTraceId => "-02", + ActivityTraceFlags.Recorded | ActivityTraceFlags.RandomTraceId => "-03", _ => Fallback((byte)flags), }; @@ -281,9 +277,7 @@ internal static bool TryExtractTraceparent(string traceparent, out ActivityTrace if ((optionsLowByte & 2) == 2) { - // https://github.com/open-telemetry/opentelemetry-dotnet/pull/6899 - // will change this to use ActivityTraceFlags.RandomTraceId instead. - traceOptions |= (ActivityTraceFlags)2; + traceOptions |= ActivityTraceFlags.RandomTraceId; } if ((!bestAttempt) && (traceparent.Length != VersionAndTraceIdAndSpanIdLength + OptionsLength)) diff --git a/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs b/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs index 07ede6141e6..9614b123c7e 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs @@ -251,7 +251,7 @@ public readonly Enumerator GetEnumerator() Debug.Assert(readonlyCount <= 8, "Invalid size detected."); - attributeStorage ??= new List>(OverflowAdditionalCapacity); + attributeStorage ??= [with(OverflowAdditionalCapacity)]; // TODO: Perf test this, adjust as needed. attributeStorage.Add(this.attribute1); @@ -305,7 +305,7 @@ private void MoveAttributesToTheOverflowList() { Debug.Assert(this.Count - 1 == OverflowMaxCount, "count did not match OverflowMaxCount"); - var attributes = this.OverflowAttributes ??= new(OverflowAdditionalCapacity); + var attributes = this.OverflowAttributes ??= [with(OverflowAdditionalCapacity)]; Debug.Assert(attributes.Count == 0, "Overflow attributes should be empty before transfer."); attributes.Add(this.attribute1); diff --git a/src/OpenTelemetry.Api/OpenTelemetry.Api.csproj b/src/OpenTelemetry.Api/OpenTelemetry.Api.csproj index e5179ba4c08..4ba22fb05e7 100644 --- a/src/OpenTelemetry.Api/OpenTelemetry.Api.csproj +++ b/src/OpenTelemetry.Api/OpenTelemetry.Api.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/OpenTelemetry.Exporter.Console/CompatibilitySuppressions.xml b/src/OpenTelemetry.Exporter.Console/CompatibilitySuppressions.xml new file mode 100644 index 00000000000..4c221b3c7c8 --- /dev/null +++ b/src/OpenTelemetry.Exporter.Console/CompatibilitySuppressions.xml @@ -0,0 +1,17 @@ + + + + CP0008 + T:OpenTelemetry.Exporter.ConsoleExporterOutputTargets + lib/net8.0/OpenTelemetry.Exporter.Console.dll + lib/netstandard2.0/OpenTelemetry.Exporter.Console.dll + true + + + CP0008 + T:OpenTelemetry.Exporter.ConsoleExporterOutputTargets + lib/net9.0/OpenTelemetry.Exporter.Console.dll + lib/netstandard2.0/OpenTelemetry.Exporter.Console.dll + true + + diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CompatibilitySuppressions.xml b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CompatibilitySuppressions.xml new file mode 100644 index 00000000000..91e3830eb6f --- /dev/null +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CompatibilitySuppressions.xml @@ -0,0 +1,31 @@ + + + + CP0008 + T:OpenTelemetry.Exporter.OtlpExportCompression + lib/net8.0/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + lib/netstandard2.1/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + true + + + CP0008 + T:OpenTelemetry.Exporter.OtlpExportProtocol + lib/net8.0/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + lib/netstandard2.1/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + true + + + CP0008 + T:OpenTelemetry.Exporter.OtlpExportCompression + lib/net9.0/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + lib/netstandard2.1/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + true + + + CP0008 + T:OpenTelemetry.Exporter.OtlpExportProtocol + lib/net9.0/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + lib/netstandard2.1/OpenTelemetry.Exporter.OpenTelemetryProtocol.dll + true + + diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpCertificateManager.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpCertificateManager.cs index 1568ab90336..e4741608d5a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpCertificateManager.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpCertificateManager.cs @@ -80,11 +80,7 @@ public static X509Certificate2 LoadClientCertificate( // Try to load as PKCS#12 first, then as PEM try { -#if NET9_0_OR_GREATER clientCertificate = X509CertificateLoader.LoadPkcs12FromFile(clientCertificatePath, null); -#else - clientCertificate = new X509Certificate2(clientCertificatePath); -#endif } catch (Exception ex) when (ex is CryptographicException or InvalidDataException or FormatException) { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj index 47186a8c5c4..1a8ca8cce20 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj @@ -20,11 +20,6 @@ $(NoWarn);SYSLIB1100;SYSLIB1101 - - - - - diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs index 2a5fb55611b..ad55cfceb1f 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs @@ -198,7 +198,9 @@ internal static Uri AppendPathIfNotPresent(this Uri uri, string path) var absoluteUri = uri.AbsoluteUri; var separator = string.Empty; -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET11_0_OR_GREATER + if (absoluteUri.EndsWith('/', StringComparison.Ordinal)) +#elif NET || NETSTANDARD2_1_OR_GREATER if (absoluteUri.EndsWith('/')) #else if (absoluteUri.EndsWith("/", StringComparison.Ordinal)) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/FileBlob.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/FileBlob.cs index 47336e8ae24..1f3bfafe223 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/FileBlob.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/FileBlob.cs @@ -93,7 +93,12 @@ protected override bool OnTryLease(int leasePeriodMilliseconds) var leaseTimestamp = DateTime.UtcNow + TimeSpan.FromMilliseconds(leasePeriodMilliseconds); if (path.EndsWith(".lock", StringComparison.OrdinalIgnoreCase)) { - path = path.Substring(0, path.LastIndexOf('@')); + path = +#if NET11_0_OR_GREATER + path.Substring(0, path.LastIndexOf('@', StringComparison.Ordinal)); +#else + path.Substring(0, path.LastIndexOf('@')); +#endif } path += $"@{leaseTimestamp:yyyy-MM-ddTHHmmss.fffffffZ}.lock"; diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/PersistentStorageHelper.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/PersistentStorageHelper.cs index 148f1e6e5cc..10a3425218e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/PersistentStorageHelper.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/PersistentStorage/PersistentStorageHelper.cs @@ -40,7 +40,12 @@ internal static bool RemoveExpiredLease(DateTime leaseDeadline, string filePath) var fileDateTime = GetDateTimeFromLeaseName(filePath); if (fileDateTime < leaseDeadline) { +#if NET11_0_OR_GREATER + var atSignIndex = filePath.LastIndexOf('@', StringComparison.Ordinal); +#else var atSignIndex = filePath.LastIndexOf('@'); +#endif + if (atSignIndex == -1) { return false; @@ -148,7 +153,13 @@ internal static string CreateSubdirectory(string path) internal static DateTime GetDateTimeFromBlobName(string filePath) { var fileName = GetFileNameWithoutExtension(filePath); + +#if NET11_0_OR_GREATER + var dashIndex = fileName.LastIndexOf('-', StringComparison.Ordinal); +#else var dashIndex = fileName.LastIndexOf('-'); +#endif + if (dashIndex == -1) { return DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc); @@ -162,7 +173,15 @@ internal static DateTime GetDateTimeFromBlobName(string filePath) internal static DateTime GetDateTimeFromLeaseName(string filePath) { var fileName = GetFileNameWithoutExtension(filePath); - var startIndex = fileName.LastIndexOf('@') + 1; + + var startIndex = +#if NET11_0_OR_GREATER + fileName.LastIndexOf('@', StringComparison.Ordinal) +#else + fileName.LastIndexOf('@') +#endif + + 1; + var timestamp = fileName.Substring(startIndex); return Parse(timestamp); @@ -177,7 +196,11 @@ private static string GetFileNameWithoutExtension(string filePath) { // Non-Windows platforms will treat the entire path as the file name if it contains Windows // path separators, so we need to extract the file name manually from after the last \ character. +#if NET11_0_OR_GREATER + var startIndex = fileName.LastIndexOf('\\', StringComparison.Ordinal); +#else var startIndex = fileName.LastIndexOf('\\'); +#endif if (startIndex > -1) { fileName = fileName.Substring(startIndex + 1); diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterApplicationBuilderExtensions.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterApplicationBuilderExtensions.cs index 92bef6f1b59..8ce1e09838e 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterApplicationBuilderExtensions.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterApplicationBuilderExtensions.cs @@ -116,7 +116,11 @@ public static IApplicationBuilder UseOpenTelemetryPrometheusScrapingEndpoint( path = options.ScrapeEndpointPath ?? PrometheusAspNetCoreOptions.DefaultScrapeEndpointPath; } +#if NET11_0_OR_GREATER + if (!path.StartsWith('/', StringComparison.Ordinal)) +#else if (!path.StartsWith('/')) +#endif { path = $"/{path}"; } diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterEndpointRouteBuilderExtensions.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterEndpointRouteBuilderExtensions.cs index 6604935ebf0..5e33ec056dc 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterEndpointRouteBuilderExtensions.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterEndpointRouteBuilderExtensions.cs @@ -86,7 +86,11 @@ public static IEndpointConventionBuilder MapPrometheusScrapingEndpoint( path = options.ScrapeEndpointPath ?? PrometheusAspNetCoreOptions.DefaultScrapeEndpointPath; } +#if NET11_0_OR_GREATER + if (!path.StartsWith('/', StringComparison.Ordinal)) +#else if (!path.StartsWith('/')) +#endif { path = $"/{path}"; } diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs index 4a01270518b..3da023a5afe 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs @@ -660,7 +660,7 @@ private List GetMetricStates(TextFormatSerializer serializer, in Ba if (metadataState.Type != prometheusMetric.Type) { - droppedMetricNames ??= new(StringComparer.Ordinal); + droppedMetricNames ??= [with(StringComparer.Ordinal)]; droppedMetricNames.Add(metadataName); PrometheusExporterEventSource.Log.ConflictingType(metadataName, metadataState.Type, prometheusMetric.Type); } diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs index 0e5512322de..e995ed51e8c 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs @@ -34,7 +34,9 @@ public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListene var path = options.ScrapeEndpointPath ?? PrometheusHttpListenerOptions.DefaultScrapeEndpointPath; -#if NET +#if NET11_0_OR_GREATER + if (!path.StartsWith('/', StringComparison.Ordinal)) +#elif NET if (!path.StartsWith('/')) #else if (!path.StartsWith("/", StringComparison.Ordinal)) @@ -43,7 +45,9 @@ public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListene path = $"/{path}"; } -#if NET +#if NET11_0_OR_GREATER + if (!path.EndsWith('/', StringComparison.Ordinal)) +#elif NET if (!path.EndsWith('/')) #else if (!path.EndsWith("/", StringComparison.Ordinal)) diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinEndpointLruCache.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinEndpointLruCache.cs index 90de02552f4..49ab8e9c92e 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinEndpointLruCache.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinEndpointLruCache.cs @@ -17,7 +17,7 @@ public ZipkinEndpointLruCache(int capacity) Guard.ThrowIfOutOfRange(capacity, min: 1); this.capacity = capacity; - this.cache = new Dictionary>(StringComparer.Ordinal); + this.cache = [with(StringComparer.Ordinal)]; } public int Count diff --git a/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs b/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs index 6e480439808..f3d6f0b555d 100644 --- a/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs +++ b/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs @@ -38,7 +38,7 @@ public sealed class B3Propagator : TextMapPropagator private static readonly HashSet AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags]; - private static readonly HashSet SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue }; + private static readonly HashSet SampledValues = [with(StringComparer.Ordinal), SampledValue, LegacySampledValue]; private readonly bool singleHeader; diff --git a/src/OpenTelemetry/CompatibilitySuppressions.xml b/src/OpenTelemetry/CompatibilitySuppressions.xml new file mode 100644 index 00000000000..5d12c209898 --- /dev/null +++ b/src/OpenTelemetry/CompatibilitySuppressions.xml @@ -0,0 +1,115 @@ + + + + CP0008 + T:OpenTelemetry.ExportProcessorType + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.ExportResult + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.AggregationTemporality + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.ExemplarFilterType + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.ExportModes + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.MetricReaderTemporalityPreference + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.MetricType + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Trace.SamplingDecision + lib/net8.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.ExportProcessorType + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.ExportResult + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.AggregationTemporality + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.ExemplarFilterType + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.ExportModes + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.MetricReaderTemporalityPreference + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Metrics.MetricType + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + + CP0008 + T:OpenTelemetry.Trace.SamplingDecision + lib/net9.0/OpenTelemetry.dll + lib/netstandard2.1/OpenTelemetry.dll + true + + diff --git a/src/OpenTelemetry/Logs/LogRecord.cs b/src/OpenTelemetry/Logs/LogRecord.cs index 45fb4ba85c2..4461b9f7bba 100644 --- a/src/OpenTelemetry/Logs/LogRecord.cs +++ b/src/OpenTelemetry/Logs/LogRecord.cs @@ -514,7 +514,7 @@ private void BufferLogAttributes() return; } - var attributeStorage = this.AttributeStorage ??= new List>(attributes.Count); + var attributeStorage = this.AttributeStorage ??= [with(attributes.Count)]; // Note: AddRange here will copy all of the KeyValuePairs from // attributes to AttributeStorage. This "captures" the state and @@ -538,7 +538,7 @@ private void BufferLogScopes() return; } - var scopeStorage = this.ScopeStorage ??= new List(LogRecordPoolHelper.DefaultMaxNumberOfScopes); + var scopeStorage = this.ScopeStorage ??= [with(LogRecordPoolHelper.DefaultMaxNumberOfScopes)]; scopeProvider.ForEachScope(AddScopeToBufferedList, scopeStorage); diff --git a/src/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs b/src/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs index 93332f21bdb..82e93bfe8e4 100644 --- a/src/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs +++ b/src/OpenTelemetry/Metrics/Reader/MetricReaderExt.cs @@ -13,7 +13,7 @@ namespace OpenTelemetry.Metrics; /// public abstract partial class MetricReader { - private readonly Dictionary metricStreamNames = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary metricStreamNames = [with(StringComparer.OrdinalIgnoreCase)]; private readonly ConcurrentDictionary instrumentIdentityToMetric = new(); private readonly Lock instrumentCreationLock = new(); private readonly ConcurrentQueue availableMetricIndices = new(); diff --git a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderSdk.cs b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderSdk.cs index a0253d35d17..e92393bffc3 100644 --- a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderSdk.cs +++ b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderSdk.cs @@ -33,7 +33,7 @@ public TracerProviderBuilderSdk(IServiceProvider serviceProvider) public List Sources { get; } = []; - public HashSet LegacyActivityOperationNames { get; } = new(StringComparer.OrdinalIgnoreCase); + public HashSet LegacyActivityOperationNames { get; } = [with(StringComparer.OrdinalIgnoreCase)]; public Sampler? Sampler { get; private set; } diff --git a/src/Shared/Shims/Lock.cs b/src/Shared/Shims/Lock.cs index a51d4eb4db1..ac7ae5e469b 100644 --- a/src/Shared/Shims/Lock.cs +++ b/src/Shared/Shims/Lock.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if !NET9_0_OR_GREATER +#if !NET namespace OpenTelemetry; // Note: .NET 9 added the System.Threading.Lock class. The goal here is when diff --git a/test/Benchmarks/README.md b/test/Benchmarks/README.md index 6e7b1589688..6b1384e8537 100644 --- a/test/Benchmarks/README.md +++ b/test/Benchmarks/README.md @@ -3,12 +3,12 @@ Navigate to `./test/Benchmarks` directory and run the following command: ```sh -dotnet run -c Release -f net10.0 -- -m +dotnet run -c Release -f net11.0 -- -m ``` [How to use console arguments](https://benchmarkdotnet.org/articles/guides/console-args.html) - `-m` enables MemoryDiagnoser and prints memory statistics - `-f` allows you to filter the benchmarks by their full name using glob patterns - - Run all benchmarks in a class: `dotnet run -c Release -f net10.0 -- -f '*LogBenchmarks*'` - - Run a single benchmark: `dotnet run -c Release -f net10.0 -- -f '*LogBenchmarks.OneProcessor'` + - Run all benchmarks in a class: `dotnet run -c Release -f net11.0 -- -f '*LogBenchmarks*'` + - Run a single benchmark: `dotnet run -c Release -f net11.0 -- -f '*LogBenchmarks.OneProcessor'` diff --git a/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/B3PropagatorFuzzTests.cs b/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/B3PropagatorFuzzTests.cs index 0aa68e8e792..c2464ce1bcd 100644 --- a/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/B3PropagatorFuzzTests.cs +++ b/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/B3PropagatorFuzzTests.cs @@ -21,7 +21,7 @@ public class B3PropagatorFuzzTests private const string SampledHeader = "X-B3-Sampled"; [Property(MaxTest = MaxTests)] - public Property MultipleHeaderInjectExtractRoundTripPreservesTraceContext() => Prop.ForAll(Generators.ActivityContextArbitrary(), (activityContext) => + public Property MultipleHeaderInjectExtractRoundTripPreservesTraceContext() => Prop.ForAll(Generators.ActivityContextArbitrary(supportsRandomTraceId: false), (activityContext) => { try { @@ -47,7 +47,7 @@ public Property MultipleHeaderInjectExtractRoundTripPreservesTraceContext() => P }); [Property(MaxTest = MaxTests)] - public Property SingleHeaderInjectExtractRoundTripPreservesTraceContext() => Prop.ForAll(Generators.ActivityContextArbitrary(), (activityContext) => + public Property SingleHeaderInjectExtractRoundTripPreservesTraceContext() => Prop.ForAll(Generators.ActivityContextArbitrary(supportsRandomTraceId: false), (activityContext) => { try { diff --git a/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/Generators.cs b/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/Generators.cs index 79470c58d8e..c7f3e2fcc31 100644 --- a/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/Generators.cs +++ b/test/OpenTelemetry.Api.FuzzTests/Context/Propagation/Generators.cs @@ -21,7 +21,7 @@ internal static class Generators private static readonly Gen OpaqueValueChar = Gen.Elements("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 \t!@#$%^&*()_-+=[]{}|;:',.<>/?`~\u0000\u0001\u007f\u0080".ToCharArray()); private static readonly Gen HeaderValueChar = Gen.Elements("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=,;: ./@".ToCharArray()); - public static Arbitrary ActivityContextArbitrary() + public static Arbitrary ActivityContextArbitrary(bool supportsRandomTraceId = true) { #if NET var allTraceFlags = Enum.GetValues(); @@ -29,6 +29,11 @@ public static Arbitrary ActivityContextArbitrary() var allTraceFlags = Enum.GetValues(typeof(ActivityTraceFlags)).OfType().ToArray(); #endif + if (!supportsRandomTraceId) + { + allTraceFlags = [.. allTraceFlags.Where(flag => flag != ActivityTraceFlags.RandomTraceId)]; + } + var gen = from traceFlags in Gen .SubListOf(allTraceFlags) diff --git a/test/OpenTelemetry.Api.Tests/ActivityTraceFlagsTests.cs b/test/OpenTelemetry.Api.Tests/ActivityTraceFlagsTests.cs index 8823bc275d8..ac1c46975fd 100644 --- a/test/OpenTelemetry.Api.Tests/ActivityTraceFlagsTests.cs +++ b/test/OpenTelemetry.Api.Tests/ActivityTraceFlagsTests.cs @@ -20,6 +20,6 @@ public static void ActivityTraceFlags_MembersAreKnown() // If this test fails, new members have been added to the ActivityTraceFlags // enum. Review the code for any changes that are needed to accommodate the // new value(s) and then update this test to include them. - Assert.Equal([ActivityTraceFlags.None, ActivityTraceFlags.Recorded], actual); + Assert.Equal([ActivityTraceFlags.None, ActivityTraceFlags.Recorded, ActivityTraceFlags.RandomTraceId], actual); } } diff --git a/test/OpenTelemetry.Api.Tests/Context/Propagation/EnvironmentVariableCarrierTests.cs b/test/OpenTelemetry.Api.Tests/Context/Propagation/EnvironmentVariableCarrierTests.cs index 6047354c5d8..1385297d7dc 100644 --- a/test/OpenTelemetry.Api.Tests/Context/Propagation/EnvironmentVariableCarrierTests.cs +++ b/test/OpenTelemetry.Api.Tests/Context/Propagation/EnvironmentVariableCarrierTests.cs @@ -214,10 +214,8 @@ public void Set_TargetsEnvironmentCopyWithoutMutatingProcessEnvironment() [Theory] [InlineData(ActivityTraceFlags.None, "00")] [InlineData(ActivityTraceFlags.Recorded, "01")] - //// https://github.com/open-telemetry/opentelemetry-dotnet/pull/6899 - //// will change this to use ActivityTraceFlags.RandomTraceId instead. - [InlineData((ActivityTraceFlags)2, "02")] - [InlineData((ActivityTraceFlags)2 | ActivityTraceFlags.Recorded, "03")] + [InlineData(ActivityTraceFlags.RandomTraceId, "02")] + [InlineData(ActivityTraceFlags.RandomTraceId | ActivityTraceFlags.Recorded, "03")] public void TraceContextPropagator_RoundTripsThroughEnvironmentVariableCarrier( ActivityTraceFlags flags, string expectedSuffix) @@ -314,7 +312,7 @@ private static void AssertBaggageEqual(IReadOnlyDictionary expec private sealed class DictionaryOnlyCarrier : IDictionary { - private readonly Dictionary inner = new(StringComparer.Ordinal); + private readonly Dictionary inner = [with(StringComparer.Ordinal)]; public ICollection Keys => this.inner.Keys; diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile index c343950d7b8..cbfc5c675e3 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile @@ -2,15 +2,14 @@ # This should be run from the root of the repo: # docker build --file test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile -ARG BUILD_SDK_VERSION=10.0 -ARG TEST_SDK_VERSION=10.0 -FROM mcr.microsoft.com/dotnet/sdk:8.0.423@sha256:89ce6291bde9acdf59594e79fb8277c6d84c46e4b1f5bf126a4f18766e4bd597 AS dotnet-sdk-8.0 -FROM mcr.microsoft.com/dotnet/sdk:9.0.316@sha256:ee0d20fbc3dfc60ae2d9d9115a9b750c18576a47f24073119dd09d93e072cb89 AS dotnet-sdk-9.0 +ARG BUILD_SDK_VERSION=11.0 +ARG TEST_SDK_VERSION=11.0 FROM mcr.microsoft.com/dotnet/sdk:10.0.302@sha256:ed034a8bf0b24ded0cbbac07e17825d8e9ebfe21e308191d0f7421eaf5ad4664 AS dotnet-sdk-10.0 +FROM mcr.microsoft.com/dotnet/sdk:11.0.100-preview.6@sha256:030c48b4cf79d68d5cae35afb9e529ce66bc7d40397ac11a8a52fc8e14ced226 AS dotnet-sdk-11.0 FROM dotnet-sdk-${BUILD_SDK_VERSION} AS build ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net10.0 +ARG PUBLISH_FRAMEWORK=net11.0 WORKDIR /repo COPY . ./ WORKDIR "/repo/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests" diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpSecureHttpClientFactoryTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpSecureHttpClientFactoryTests.cs index f62f6af0802..e34d2f75cc8 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpSecureHttpClientFactoryTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpSecureHttpClientFactoryTests.cs @@ -319,13 +319,8 @@ private static X509Certificate2 CreateSelfSignedCertificate() var cert = req.CreateSelfSigned( DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddDays(30)); -#if NET9_0_OR_GREATER + return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static X509Certificate2 CreateCertificateAuthority() @@ -347,13 +342,7 @@ private static X509Certificate2 CreateCertificateAuthority() DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddYears(1)); -#if NET9_0_OR_GREATER return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static X509Certificate2 CreateServerCertificate(X509Certificate2 issuer) @@ -384,13 +373,7 @@ private static X509Certificate2 CreateServerCertificate(X509Certificate2 issuer) DateTimeOffset.UtcNow.AddDays(30), serialNumber); -#if NET9_0_OR_GREATER return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static X509Certificate2 CreateExpiredCertificate() @@ -408,13 +391,7 @@ private static X509Certificate2 CreateExpiredCertificate() DateTimeOffset.UtcNow.AddDays(-30), DateTimeOffset.UtcNow.AddDays(-1)); -#if NET9_0_OR_GREATER return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static string ExportCertificateWithPrivateKey(X509Certificate2 certificate) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTlsOptionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTlsOptionsTests.cs index 4329a65e91f..1b48dc1700b 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTlsOptionsTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTlsOptionsTests.cs @@ -176,13 +176,8 @@ private static X509Certificate2 CreateSelfSignedCertificate() var cert = req.CreateSelfSigned( DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddDays(30)); -#if NET9_0_OR_GREATER + return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static X509Certificate2 CreateCertificateAuthority() @@ -204,13 +199,7 @@ private static X509Certificate2 CreateCertificateAuthority() DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddYears(1)); -#if NET9_0_OR_GREATER return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static X509Certificate2 CreateServerCertificate(X509Certificate2 issuer) @@ -241,13 +230,7 @@ private static X509Certificate2 CreateServerCertificate(X509Certificate2 issuer) DateTimeOffset.UtcNow.AddDays(30), serialNumber); -#if NET9_0_OR_GREATER return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx), null, X509KeyStorageFlags.Exportable); -#else -#pragma warning disable SYSLIB0057 - return new X509Certificate2(cert.Export(X509ContentType.Pfx), (string?)null, X509KeyStorageFlags.Exportable); -#pragma warning restore SYSLIB0057 -#endif } private static string ExportCertificateWithPrivateKey(X509Certificate2 certificate) diff --git a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusIntegrationTests.cs b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusIntegrationTests.cs index b0ec0ce778e..2458d3099b9 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusIntegrationTests.cs +++ b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusIntegrationTests.cs @@ -5,7 +5,9 @@ using System.Diagnostics.Metrics; using System.IO.Compression; using System.Net; +#if !NET11_0_OR_GREATER using System.Net.Http.Json; +#endif using System.Text.Json; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/snapshots/PrometheusSerializer.WriteMetricPrefixesScopeAttributesAndDropsConflictingScopeAttributeNames.DotNet11_0.verified.txt b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/snapshots/PrometheusSerializer.WriteMetricPrefixesScopeAttributesAndDropsConflictingScopeAttributeNames.DotNet11_0.verified.txt new file mode 100644 index 00000000000..38601f5919d --- /dev/null +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/snapshots/PrometheusSerializer.WriteMetricPrefixesScopeAttributesAndDropsConflictingScopeAttributeNames.DotNet11_0.verified.txt @@ -0,0 +1,2 @@ +# TYPE test_gauge gauge +test_gauge{otel_scope_name="test_meter",otel_scope_version="1.0.0",otel_scope_schema_url="https://opentelemetry.io/schemas/1.0.0",otel_scope_library_mascot="dotnetbot",metric_tag="value"} 123 diff --git a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryServicesExtensionsTests.cs b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryServicesExtensionsTests.cs index 810ef1a9b7a..5a03826c3a5 100644 --- a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryServicesExtensionsTests.cs +++ b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryServicesExtensionsTests.cs @@ -186,7 +186,11 @@ public void AddOpenTelemetry_WithTracing_NestedResolutionUsingConfigureTest() deferredTracerProviderBuilder.Configure((sp, builder) => { innerTestExecuted = true; +#if NET10_0 Assert.Throws(() => sp.GetService()); +#else + Assert.Throws(() => sp.GetService()); +#endif }); } }); @@ -309,7 +313,11 @@ public void AddOpenTelemetry_WithMetrics_NestedResolutionUsingConfigureTest() deferredMeterProviderBuilder.Configure((sp, builder) => { innerTestExecuted = true; +#if NET10_0 Assert.Throws(() => sp.GetService()); +#else + Assert.Throws(() => sp.GetService()); +#endif }); } }); @@ -426,7 +434,11 @@ public void AddOpenTelemetry_WithLogging_NestedResolutionUsingConfigureTest() deferredLoggerProviderBuilder.Configure((sp, builder) => { innerTestExecuted = true; +#if NET10_0 Assert.Throws(() => sp.GetService()); +#else + Assert.Throws(() => sp.GetService()); +#endif }); } }); diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile index 39f206712f9..70371927bd8 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile @@ -2,16 +2,15 @@ # This should be run from the root of the repo: # docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile . -ARG BUILD_SDK_VERSION=10.0 -ARG TEST_SDK_VERSION=10.0 +ARG BUILD_SDK_VERSION=11.0 +ARG TEST_SDK_VERSION=11.0 -FROM mcr.microsoft.com/dotnet/sdk:8.0.423-azurelinux3.0@sha256:661310ba6e276622419fb814634778623b11fd0fc28a02cd5516edf50b0672aa AS dotnet-sdk-8.0 -FROM mcr.microsoft.com/dotnet/sdk:9.0.316-azurelinux3.0@sha256:ff06e00ec2cc3b87b7f383dda323c92f52ac6e284e8c04ae4930f04a035d44e0 AS dotnet-sdk-9.0 FROM mcr.microsoft.com/dotnet/sdk:10.0.302-azurelinux3.0@sha256:675817acabaae7140642e228aa4c795dfa30c960c4daa3776b2e749305ffd3bb AS dotnet-sdk-10.0 +FROM mcr.microsoft.com/dotnet/sdk:11.0.100-preview.6-azurelinux3.0@sha256:a3dc851a4b82d071bbd7c093153f2ee5dedb0044a0c557706ca615b62657b001 AS dotnet-sdk-11.0 FROM dotnet-sdk-${BUILD_SDK_VERSION} AS build ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net10.0 +ARG PUBLISH_FRAMEWORK=net11.0 # renovate: datasource=github-digest depName=w3c/trace-context packageName=w3c/trace-context currentValue=main ENV W3C_TRACE_CONTEXT_SHA="acab820be9db7b3433668baa5cdd43f57f4c4be0" diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj index d776a2c91fe..300d53feacb 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj @@ -6,7 +6,6 @@ - diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs index 909f284084c..10a4f2ffb33 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs @@ -152,7 +152,13 @@ private static string ParseLastLine(string output) } // The output ends with '\n', which should be ignored. - var lastNewLineCharacterPos = output.LastIndexOf('\n', output.Length - 2); + var lastNewLineCharacterPos = +#if NET11_0_OR_GREATER + output.LastIndexOf('\n', output.Length - 2, StringComparison.Ordinal); +#else + output.LastIndexOf('\n', output.Length - 2); +#endif + return output.Substring(lastNewLineCharacterPos + 1); } diff --git a/test/OpenTelemetry.Tests.Stress.Logs/README.md b/test/OpenTelemetry.Tests.Stress.Logs/README.md index b9a7b37d61f..2dd4bcdbffb 100644 --- a/test/OpenTelemetry.Tests.Stress.Logs/README.md +++ b/test/OpenTelemetry.Tests.Stress.Logs/README.md @@ -3,21 +3,22 @@ This is Stress Test specifically for logging, and is based on the [OpenTelemetry.Tests.Stress](../OpenTelemetry.Tests.Stress/README.md). -* [Running the stress test](#running-the-stress-test) +- [OpenTelemetry Stress Tests for Logs](#opentelemetry-stress-tests-for-logs) + - [Running the stress test](#running-the-stress-test) ## Running the stress test Open a console, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release +dotnet run --framework net11.0 --configuration Release ``` To see command line options available, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release -- --help +dotnet run --framework net11.0 --configuration Release -- --help ``` The help output includes settings and their explanations: diff --git a/test/OpenTelemetry.Tests.Stress.Metrics/README.md b/test/OpenTelemetry.Tests.Stress.Metrics/README.md index d383fa41a36..fd7b7011684 100644 --- a/test/OpenTelemetry.Tests.Stress.Metrics/README.md +++ b/test/OpenTelemetry.Tests.Stress.Metrics/README.md @@ -3,21 +3,22 @@ This stress test is specifically for Metrics SDK, and is based on the [OpenTelemetry.Tests.Stress](../OpenTelemetry.Tests.Stress/README.md). -* [Running the stress test](#running-the-stress-test) +- [OpenTelemetry Stress Tests for Metrics](#opentelemetry-stress-tests-for-metrics) + - [Running the stress test](#running-the-stress-test) ## Running the stress test Open a console, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release +dotnet run --framework net11.0 --configuration Release ``` To see command line options available, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release -- --help +dotnet run --framework net11.0 --configuration Release -- --help ``` The help output includes settings and their explanations: diff --git a/test/OpenTelemetry.Tests.Stress.Traces/README.md b/test/OpenTelemetry.Tests.Stress.Traces/README.md index be8d5d6c8d6..9924b223387 100644 --- a/test/OpenTelemetry.Tests.Stress.Traces/README.md +++ b/test/OpenTelemetry.Tests.Stress.Traces/README.md @@ -3,21 +3,22 @@ This Stress Test is specifically for tracing, and it is based on the [OpenTelemetry.Tests.Stress](../OpenTelemetry.Tests.Stress/README.md). -* [Running the stress test](#running-the-stress-test) +- [OpenTelemetry Stress Tests for Traces](#opentelemetry-stress-tests-for-traces) + - [Running the stress test](#running-the-stress-test) ## Running the stress test Open a console, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release +dotnet run --framework net11.0 --configuration Release ``` To see command line options available, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release -- --help +dotnet run --framework net11.0 --configuration Release -- --help ``` The help output includes settings and their explanations: diff --git a/test/OpenTelemetry.Tests.Stress/README.md b/test/OpenTelemetry.Tests.Stress/README.md index d1618290d8d..0d36363a203 100644 --- a/test/OpenTelemetry.Tests.Stress/README.md +++ b/test/OpenTelemetry.Tests.Stress/README.md @@ -1,16 +1,17 @@ # OpenTelemetry Stress Tests -* [Why would you need stress test](#why-would-you-need-stress-test) -* [Running the demo](#running-the-demo) -* [Writing your own stress test](#writing-your-own-stress-test) -* [Understanding the results](#understanding-the-results) +- [OpenTelemetry Stress Tests](#opentelemetry-stress-tests) + - [Why would you need stress test](#why-would-you-need-stress-test) + - [Running the demo](#running-the-demo) + - [Writing your own stress test](#writing-your-own-stress-test) + - [Understanding the results](#understanding-the-results) ## Why would you need stress test -* It helps you to understand performance. -* You can keep it running for days and nights to verify stability. -* You can use it to generate lots of load to your backend system. -* You can use it with other stress tools (e.g. a memory limiter) to verify how +- It helps you to understand performance. +- You can keep it running for days and nights to verify stability. +- You can use it to generate lots of load to your backend system. +- You can use it with other stress tools (e.g. a memory limiter) to verify how your code reacts to certain resource constraints. ## Running the demo @@ -18,14 +19,14 @@ Open a console, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release +dotnet run --framework net11.0 --configuration Release ``` To see command line options available, run the following command from the current folder: ```sh -dotnet run --framework net10.0 --configuration Release -- --help +dotnet run --framework net11.0 --configuration Release -- --help ``` The help output includes settings and their explanations: @@ -44,11 +45,9 @@ the console window title and the console window itself. While a test is running... -* Use the `SPACE` key to toggle the console output, which is on by default. - -* Use the `ENTER` key to print the latest performance statistics. - -* Use the `ESC` key to exit the stress test. +- Use the `SPACE` key to toggle the console output, which is on by default. +- Use the `ENTER` key to print the latest performance statistics. +- Use the `ESC` key to exit the stress test. Example output while a test is running: @@ -165,26 +164,26 @@ public static class Program Some useful notes: -* It is generally best practice to run the stress test for code compiled in +- It is generally best practice to run the stress test for code compiled in `Release` configuration rather than `Debug` configuration. `Debug` builds typically are not optimized and contain extra code which will change the performance characteristics of the logic under test. The stress test will write a warning message to the console when starting if compiled with `Debug` configuration. -* You can specify the concurrency using `-c` or `--concurrency` command line +- You can specify the concurrency using `-c` or `--concurrency` command line argument, the default value if not specified is the number of CPU cores. Keep in mind that concurrency level does not equal to the number of threads. -* You can use the duration `-d` or `--duration` command line argument to run the +- You can use the duration `-d` or `--duration` command line argument to run the stress test for a specific time period. This is useful when comparing changes across multiple runs. ## Understanding the results -* `Loops` represent the total number of `Run()` invocations that are completed. -* `Loops/Second` represents the rate of `Run()` invocations based on a small +- `Loops` represent the total number of `Run()` invocations that are completed. +- `Loops/Second` represents the rate of `Run()` invocations based on a small sliding window of few hundreds of milliseconds. -* `CPU Cycles/Loop` represents the average CPU cycles for each `Run()` +- `CPU Cycles/Loop` represents the average CPU cycles for each `Run()` invocation, based on a small sliding window of few hundreds of milliseconds. -* `Total Running Time` represents the running time (seconds) since the test started. -* `GC Total Allocated Bytes` (not available on .NET Framework) shows the total +- `Total Running Time` represents the running time (seconds) since the test started. +- `GC Total Allocated Bytes` (not available on .NET Framework) shows the total amount of memory allocated while the test was running. diff --git a/test/OpenTelemetry.Tests/Logs/LogRecordSharedPoolTests.cs b/test/OpenTelemetry.Tests/Logs/LogRecordSharedPoolTests.cs index 8b1753aa1ef..e66093b714e 100644 --- a/test/OpenTelemetry.Tests/Logs/LogRecordSharedPoolTests.cs +++ b/test/OpenTelemetry.Tests/Logs/LogRecordSharedPoolTests.cs @@ -116,12 +116,13 @@ public void ClearTests() var pool = LogRecordSharedPool.Current; var logRecord1 = pool.Rent(); - logRecord1.AttributeStorage = new List>(16) - { + logRecord1.AttributeStorage = + [ + with(16), new("key1", "value1"), new("key2", "value2"), - }; - logRecord1.ScopeStorage = new List(8) { null, null }; + ]; + logRecord1.ScopeStorage = [with(8), null, null]; pool.Return(logRecord1); diff --git a/test/OpenTelemetry.Tests/Logs/LogRecordThreadStaticPoolTests.cs b/test/OpenTelemetry.Tests/Logs/LogRecordThreadStaticPoolTests.cs index 127189e5c49..98e821bfbf6 100644 --- a/test/OpenTelemetry.Tests/Logs/LogRecordThreadStaticPoolTests.cs +++ b/test/OpenTelemetry.Tests/Logs/LogRecordThreadStaticPoolTests.cs @@ -35,12 +35,13 @@ public void RentReturnTests() public void ClearTests() { var logRecord1 = LogRecordThreadStaticPool.Instance.Rent(); - logRecord1.AttributeStorage = new List>(16) - { + logRecord1.AttributeStorage = + [ + with(16), new("key1", "value1"), new("key2", "value2"), - }; - logRecord1.ScopeStorage = new List(8) { null, null }; + ]; + logRecord1.ScopeStorage = [with(8), null, null]; LogRecordThreadStaticPool.Instance.Return(logRecord1); diff --git a/test/OpenTelemetry.Tests/Trace/ExportProcessorTests.cs b/test/OpenTelemetry.Tests/Trace/ExportProcessorTests.cs index fa0d3bd5fef..0789545d354 100644 --- a/test/OpenTelemetry.Tests/Trace/ExportProcessorTests.cs +++ b/test/OpenTelemetry.Tests/Trace/ExportProcessorTests.cs @@ -29,7 +29,7 @@ public void ExportProcessorIgnoresActivityWhenDropped() { Assert.NotNull(activity); Assert.False(activity.IsAllDataRequested); - Assert.Equal(ActivityTraceFlags.None, activity.ActivityTraceFlags); + Assert.Equal(ActivityTraceFlags.RandomTraceId, activity.ActivityTraceFlags); } Assert.Empty(processor.ExportedItems); @@ -55,7 +55,7 @@ public void ExportProcessorIgnoresActivityMarkedAsRecordOnly() { Assert.NotNull(activity); Assert.True(activity.IsAllDataRequested); - Assert.Equal(ActivityTraceFlags.None, activity.ActivityTraceFlags); + Assert.Equal(ActivityTraceFlags.RandomTraceId, activity.ActivityTraceFlags); } Assert.Empty(processor.ExportedItems); @@ -81,7 +81,7 @@ public void ExportProcessorExportsActivityMarkedAsRecordAndSample() { Assert.NotNull(activity); Assert.True(activity.IsAllDataRequested); - Assert.Equal(ActivityTraceFlags.Recorded, activity.ActivityTraceFlags); + Assert.Equal(ActivityTraceFlags.Recorded | ActivityTraceFlags.RandomTraceId, activity.ActivityTraceFlags); } Assert.Single(processor.ExportedItems); diff --git a/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTests.cs b/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTests.cs index d7ff335a872..3c50f1c91f1 100644 --- a/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTests.cs +++ b/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTests.cs @@ -78,10 +78,7 @@ public void RandomTraceId() Assert.Equal(ActivityTraceId.CreateFromString(TraceId.AsSpan()), context.ActivityContext.TraceId); Assert.Equal(ActivitySpanId.CreateFromString(SpanId.AsSpan()), context.ActivityContext.SpanId); - - // https://github.com/open-telemetry/opentelemetry-dotnet/pull/6899 - // will change this to use ActivityTraceFlags.RandomTraceId instead. - Assert.Equal((ActivityTraceFlags)2, context.ActivityContext.TraceFlags); + Assert.Equal(ActivityTraceFlags.RandomTraceId, context.ActivityContext.TraceFlags); Assert.True(context.ActivityContext.IsValid()); } @@ -101,10 +98,7 @@ public void RandomTraceIdAndRecorded() Assert.Equal(ActivitySpanId.CreateFromString(SpanId.AsSpan()), context.ActivityContext.SpanId); Assert.True(context.ActivityContext.TraceFlags.HasFlag(ActivityTraceFlags.Recorded)); - - // https://github.com/open-telemetry/opentelemetry-dotnet/pull/6899 - // will change this to use ActivityTraceFlags.RandomTraceId instead. - Assert.True(context.ActivityContext.TraceFlags.HasFlag((ActivityTraceFlags)2)); + Assert.True(context.ActivityContext.TraceFlags.HasFlag(ActivityTraceFlags.RandomTraceId)); Assert.True(context.ActivityContext.IsValid()); } @@ -428,9 +422,7 @@ public void Inject_WithRandomTraceId() { TraceState, $"congo=lZWRzIHRoNhcm5hbCBwbGVhc3VyZS4,rojo=00-{traceId}-00f067aa0ba902b7-02" }, }; - // https://github.com/open-telemetry/opentelemetry-dotnet/pull/6899 - // will change this to use ActivityTraceFlags.RandomTraceId instead. - var activityContext = new ActivityContext(traceId, spanId, (ActivityTraceFlags)2, expectedHeaders[TraceState]); + var activityContext = new ActivityContext(traceId, spanId, ActivityTraceFlags.RandomTraceId, expectedHeaders[TraceState]); var propagationContext = new PropagationContext(activityContext, default); var carrier = new Dictionary(); var propagator = new TraceContextPropagator(); diff --git a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTests.cs b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTests.cs index e80672fc86f..b5e648a576a 100644 --- a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTests.cs +++ b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTests.cs @@ -435,7 +435,7 @@ public void ProcessorDoesNotReceiveNotRecordDecisionSpan() activity.Stop(); Assert.False(activity.IsAllDataRequested); - Assert.Equal(ActivityTraceFlags.None, activity.ActivityTraceFlags); + Assert.Equal(ActivityTraceFlags.RandomTraceId, activity.ActivityTraceFlags); Assert.False(activity.Recorded); Assert.False(startCalled); Assert.False(endCalled); @@ -804,11 +804,12 @@ public void SdkSamplesLegacyActivityWithAlwaysOnSampler() Assert.True(activity.IsAllDataRequested); Assert.True(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded)); + Assert.True(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.RandomTraceId)); // Validating ActivityTraceFlags is not enough as it does not get reflected on // Id, If the Id is accessed before the sampler runs. // https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700 - Assert.EndsWith("-01", activity.Id, StringComparison.Ordinal); + Assert.EndsWith("-03", activity.Id, StringComparison.Ordinal); activity.Stop(); } @@ -831,7 +832,7 @@ public void SdkSamplesLegacyActivityWithAlwaysOffSampler() // Validating ActivityTraceFlags is not enough as it does not get reflected on // Id, If the Id is accessed before the sampler runs. // https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700 - Assert.EndsWith("-00", activity.Id, StringComparison.Ordinal); + Assert.EndsWith("-02", activity.Id, StringComparison.Ordinal); activity.Stop(); } @@ -859,7 +860,7 @@ public void SdkSamplesLegacyActivityWithCustomSampler(SamplingDecision samplingD // Validating ActivityTraceFlags is not enough as it does not get reflected on // Id, If the Id is accessed before the sampler runs. // https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700 - Assert.EndsWith(hasRecordedFlag ? "-01" : "-00", activity.Id, StringComparison.Ordinal); + Assert.EndsWith(hasRecordedFlag ? "-03" : "-02", activity.Id, StringComparison.Ordinal); activity.Stop(); }