Skip to content

Commit

Permalink
.NET9 support (#3796)
Browse files Browse the repository at this point in the history
* Typo fix

* Update End OF Support validation rule

* Update Min Supported framework rule

* Update code space

* CHANGELOG

* Update developing documentation

* Update documentation

* Use .NET9 in build pipeline
drops .NET7 and .NET6

* Bump LangVersion to 13

* Update SDK Version analyzer

* Compile against .NET9

drops .NET6 and .NET7

* Adjust nuke build

* Fix build tests

* Update examples documentation

* Cleanup net6 references in project files

* Fix tests

* Cleanup target frameworks for generated tests targets

* Adjust conditional compilation

* Remove legacy code from LogBuilderExtensions

* Fix dev comment

* Adjust CI to execute scripts tests against .net9

* revert demo target versions.

It should be fixed just after next release

* Centos Stream9 - install .NET9

* Fix LoggingBuilder integration for version 9.*

* drop debugger launch

* cleanup using

* sync versions in the comments

* DuckTyping - include GH item in TODO comment

* TransientDependenciesTests - update comment
  • Loading branch information
Kielek authored Nov 21, 2024
1 parent 5c98a61 commit e205769
Show file tree
Hide file tree
Showing 157 changed files with 463 additions and 731 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
docker build -t mybuildimage -f "./docker/${{ matrix.base-image }}.dockerfile" ./docker
docker run --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project --rm mybuildimage /bin/sh -c '
set -e
dotnet publish -f net8.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
dotnet publish -f net9.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/bin/tracer-home"
. ./instrument.sh
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net8.0/publish/TestApplication.Smoke
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net9.0/publish/TestApplication.Smoke
test "$(ls -A /var/log/opentelemetry/dotnet )"
'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build-nuget-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down Expand Up @@ -102,10 +101,10 @@ jobs:
shell: bash
run: |
set -e
dotnet publish -f net8.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
dotnet publish -f net9.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/bin/tracer-home"
. ./instrument.sh
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net8.0/publish/TestApplication.Smoke
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net9.0/publish/TestApplication.Smoke
test "$(ls -A '${{ matrix.log-dir }}' )"
- name: Test the Windows PowerShell module instructions from README.md
Expand All @@ -116,12 +115,12 @@ jobs:
Import-Module "${PWD}/bin/installation-scripts/OpenTelemetry.DotNet.Auto.psm1"
[System.Environment]::SetEnvironmentVariable("OTEL_DOTNET_AUTO_INSTALL_DIR", "${PWD}/bin/tracer-home", [System.EnvironmentVariableTarget]::Machine)
Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName"
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net8.0/TestApplication.Smoke.exe
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net9.0/TestApplication.Smoke.exe
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (-not (Test-Path $log_path)) { throw "Log file does not exist. Instrumentation test failed." }
Remove-Item $log_path
Unregister-OpenTelemetryForCurrentSession
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net8.0/TestApplication.Smoke.exe
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net9.0/TestApplication.Smoke.exe
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (Test-Path $log_path) { throw "Log file exists. Instrumentation unregister failed." }
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-sdk-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2

- name: Setup .NET 8
- name: Setup .NET
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: 8.0.403
dotnet-version: 9.0.100

- name: Run VerifySdkVersions
run: ./build.cmd VerifySdkVersions
22 changes: 9 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
test-tfm: [ net8.0, net7.0, net6.0, net462 ]
test-tfm: [ net9.0, net8.0, net462 ]
machine: [ windows-2022, ubuntu-20.04, macos-13, otel-linux-arm64 ]
exclude:
- test-tfm: net462
Expand Down Expand Up @@ -66,9 +66,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down Expand Up @@ -131,9 +130,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down Expand Up @@ -171,9 +169,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down Expand Up @@ -276,9 +273,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Check for NuGet packages cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # tag: v4.1.2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2

- name: Setup .NET 8
- name: Setup .NET
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: 8.0.403
dotnet-version: 9.0.100

- name: dotnet format
run: dotnet format .\OpenTelemetry.AutoInstrumentation.sln --no-restore --verify-no-changes
20 changes: 9 additions & 11 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Test the PowerShell module instructions from README.md
shell: powershell
run: |
mkdir testapp
cd testapp
dotnet new console
dotnet publish -f net8.0 -c Release
dotnet publish -f net9.0 -c Release
$module_url = "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/OpenTelemetry.DotNet.Auto.psm1"
$dl_path = Join-Path $env:temp "OpenTelemetry.DotNet.Auto.psm1"
$log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*"
Expand All @@ -32,12 +31,12 @@ jobs:
Install-OpenTelemetryCore
$install_dir = Get-OpenTelemetryInstallDirectory
Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName"
./bin/Release/net8.0/publish/testapp
./bin/Release/net9.0/publish/testapp
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (-not (Test-Path $log_path)) { throw "Log file does not exist. Instrumentation test failed." }
Remove-Item $log_path
Unregister-OpenTelemetryForCurrentSession
./bin/Release/net8.0/publish/testapp
./bin/Release/net9.0/publish/testapp
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (Test-Path $log_path) { throw "Log file exists. Instrumentation unregister failed." }
Uninstall-OpenTelemetryCore
Expand Down Expand Up @@ -68,9 +67,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Install MacOS CoreUtils
if: ${{ runner.os == 'macOS' }}
Expand All @@ -87,13 +85,13 @@ jobs:
mkdir testapp
cd testapp
dotnet new console
dotnet publish -f net8.0 -c Release
dotnet publish -f net9.0 -c Release
curl -sSfL https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/otel-dotnet-auto-install.sh -O
sh ./otel-dotnet-auto-install.sh
test "$(ls -A "$HOME/.otel-dotnet-auto")"
curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/instrument.sh -O
. ./instrument.sh
./bin/Release/net8.0/publish/testapp
./bin/Release/net9.0/publish/testapp
test "$(ls -A '${{ matrix.log-dir }}' )"
shell-scripts-container:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/verify-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ jobs:
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # tag: v4.1.0
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
8.0.404
9.0.100
- name: Run BuildTracer and ManagedTests
run: ./build.cmd BuildTracer ManagedTests --containers ${{ matrix.containers }} --test-project "${{ github.event.inputs.testProject }}" --test-name '"${{ github.event.inputs.testName }}"' --test-count ${{ github.event.inputs.count }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h

### Added

- Support for .NET9.
- Support for [RabbitMQ.Client](https://www.nuget.org/packages/RabbitMQ.Client/)
traces instrumentation for versions `7.0.0`+.

Expand All @@ -20,6 +21,7 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h

### Removed

- Support for .NET 6 and .NET 7. Both framework reached end of support.
- Support for macOS Monterey 12 x64.
macOs libraries are built and tested against [macOS Ventura 13 x64](https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md).

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<LangVersion>11.0</LangVersion>
<LangVersion>13.0</LangVersion>
</PropertyGroup>
</Project>
17 changes: 1 addition & 16 deletions build/Build.NuGet.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,13 @@ partial class Build
.Description("Builds the TestApplications.* used by the NuGetPackagesTests")
.Executes(() =>
{
string MapToNet8RuntimeIdentifiers(string oldRuntimeIdentifier)
{
#if NET8_0_OR_GREATER
return oldRuntimeIdentifier;
#else
switch (oldRuntimeIdentifier)
{
case "ubuntu.20.04-x64": return "linux-x64";
case "osx.11.0-x64": return "osx-x64";
case "win10-x64": return "win-x64";
}
throw new NotSupportedException($"{oldRuntimeIdentifier} is not supported. Extend MapToNet8RuntimeIdentifiers.");
#endif
}

foreach (var packagesTestApplicationProject in Solution.GetNuGetPackagesTestApplications())
{
// Unlike the integration apps these require a restore step.
DotNetBuild(s => s
.SetProjectFile(packagesTestApplicationProject)
.SetProperty("NuGetPackageVersion", VersionHelper.GetVersion())
.SetRuntime(MapToNet8RuntimeIdentifiers(RuntimeInformation.RuntimeIdentifier))
.SetRuntime(RuntimeInformation.RuntimeIdentifier)
.SetSelfContained(true)
.SetConfiguration(BuildConfiguration)
.SetPlatform(Platform));
Expand Down
27 changes: 9 additions & 18 deletions build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ partial class Build
private static readonly IEnumerable<TargetFramework> TargetFrameworks = new[]
{
TargetFramework.NET462,
TargetFramework.NET6_0
TargetFramework.NET8_0
};

private static readonly IEnumerable<TargetFramework> TestFrameworks = TargetFrameworks
.Concat(TargetFramework.NET7_0
#if NET8_0_OR_GREATER
, TargetFramework.NET8_0
#endif
);
.Concat(TargetFramework.NET9_0);

Target CreateRequiredDirectories => _ => _
.Unlisted()
Expand Down Expand Up @@ -291,24 +287,24 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x) =>
.SetFramework(TargetFramework.NETCore3_1)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NETCore3_1)));

// AutoInstrumentationLoader publish is needed only for .NET 6.0 to support load from AutoInstrumentationStartupHook.
// AutoInstrumentationLoader publish is needed only for .NET 8.0 to support load from AutoInstrumentationStartupHook.
DotNetPublish(s => s
.SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationLoader))
.SetConfiguration(BuildConfiguration)
.SetTargetPlatformAnyCPU()
.EnableNoBuild()
.SetNoRestore(NoRestore)
.SetFramework(TargetFramework.NET6_0)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET6_0)));
.SetFramework(TargetFramework.NET8_0)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET8_0)));

DotNetPublish(s => s
.SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationAspNetCoreBootstrapper))
.SetConfiguration(BuildConfiguration)
.SetTargetPlatformAnyCPU()
.EnableNoBuild()
.SetNoRestore(NoRestore)
.SetFramework(TargetFramework.NET6_0)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET6_0)));
.SetFramework(TargetFramework.NET8_0)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET8_0)));

RemoveFilesInNetFolderAvailableInAdditionalStore();

Expand Down Expand Up @@ -593,14 +589,9 @@ void RemoveFilesInNetFolderAvailableInAdditionalStore()
// To allow roll forward for applications, like Roslyn, that target one tfm
// but have a later runtime move the libraries under the original tfm folder
// to the latest one.
if (folderRuntimeName == TargetFramework.NET6_0)
{
depsJson.RollFrameworkForward(TargetFramework.NET6_0, TargetFramework.NET8_0, architectureStores);
}
else if (folderRuntimeName == TargetFramework.NET7_0 || folderRuntimeName == TargetFramework.NET8_0)
if (folderRuntimeName == TargetFramework.NET8_0 || folderRuntimeName == TargetFramework.NET9_0)
{
depsJson.RollFrameworkForward(TargetFramework.NET6_0, TargetFramework.NET8_0, architectureStores);
depsJson.RollFrameworkForward(TargetFramework.NET7_0, TargetFramework.NET8_0, architectureStores);
depsJson.RollFrameworkForward(TargetFramework.NET8_0, TargetFramework.NET9_0, architectureStores);
}

// Write the updated deps.json file.
Expand Down
1 change: 1 addition & 0 deletions build/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<PackageVersion Include="Mono.Cecil" Version="0.11.6" />
<PackageVersion Include="Nuke.Common" Version="8.1.4" />
<PackageVersion Include="Nuget.CommandLine" Version="6.11.1" />
<PackageVersion Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions build/Extensions/DepsJsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ public static string GetFolderRuntimeName(this JsonObject depsJson)
var runtimeName = depsJson["runtimeTarget"]["name"].GetValue<string>();
var folderRuntimeName = runtimeName switch
{
".NETCoreApp,Version=v6.0" => "net6.0",
".NETCoreApp,Version=v7.0" => "net7.0",
".NETCoreApp,Version=v8.0" => "net8.0",
".NETCoreApp,Version=v9.0" => "net9.0",
_ => throw new ArgumentOutOfRangeException(nameof(runtimeName), runtimeName,
"This value is not supported. You have probably introduced new .NET version to AutoInstrumentation")
};
Expand Down
Loading

0 comments on commit e205769

Please sign in to comment.