Skip to content

Commit

Permalink
.NET 9 SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Nov 22, 2024
1 parent 107db01 commit 1c1a470
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/.github.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ runs:
with:
global-json-file: ./global.json

- name: Install Aspire workload
shell: bash
run: dotnet workload install aspire

- id: dotnet
shell: bash
run: |
Expand All @@ -53,6 +49,7 @@ runs:
echo "AGENT_VERSION=${AGENT_VERSION}" >> $GITHUB_ENV
echo "agent-version=${AGENT_VERSION}" >> $GITHUB_OUTPUT
echo "major-version=$(echo ${AGENT_VERSION} | cut -d"." -f1)" >> $GITHUB_OUTPUT
dotnet --version
# Setup git config
- uses: elastic/oblt-actions/git/setup@v1
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<NoWarn>$(NoWarn);NU1701</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion build/patch-dotnet-auto-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ case "$ARCHITECTURE" in
esac

test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto"
test -z "$VERSION" && VERSION="v1.7.0"
test -z "$VERSION" && VERSION="v1.9.0"

DOWNLOAD_DIR="${DOWNLOAD_DIR:=${TMPDIR:=$(mktemp -d)}}"

Expand Down
7 changes: 1 addition & 6 deletions build/scripts/Packaging.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,8 @@ let stageInstrumentationScript (stagedZips:List<ReleaseAsset * FileInfo>) =
let stageInstallationBashScript () =
let installScript = downloadFileInfo "otel-dotnet-auto-install.sh"
let staged = installScript.CopyTo ((stageFile installScript).FullName, true)
// temporary while https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/pull/3549 is not released.
// Should be released after 1.7.0.
// We should be able to read from `staged` instead after
let patchScript = fileInfo Paths.Root <| Path.Combine("build", "patch-dotnet-auto-install.sh")

let contents =
(File.ReadAllText patchScript.FullName)
(File.ReadAllText staged.FullName)
.Replace("/open-telemetry/opentelemetry-dotnet-instrumentation/", "/elastic/elastic-otel-dotnet/")
.Replace("opentelemetry-dotnet-instrumentation", "elastic-dotnet-instrumentation")
.Replace("v" + Software.OpenTelemetryAutoInstrumentationVersion.AsString, Software.Version.NormalizeToShorter())
Expand Down
6 changes: 3 additions & 3 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let private runTests suite _ =


let settingsArg = ["-s"; "tests/.runsettings"]
let tfmArgs = if OS.Current = OS.Windows then [] else ["-f"; "net8.0"]
let tfmArgs = if OS.Current = OS.Windows then [] else ["-f"; "net9.0"]
exec {
env (Map ["TEST_SUITE", suite.SuitName])
run "dotnet" (
Expand Down Expand Up @@ -128,13 +128,13 @@ let private generateApiChanges _ =
nugetPackages
|> Seq.iter(fun p ->
let outputFile = Path.Combine(output, $"breaking-changes-%s{p}.md")
let tfm = "net8.0"
let tfm = "net9.0"
let args =
[
"assembly-differ"
$"previous-nuget|%s{p}|%s{currentVersion}|%s{tfm}";
//$"directory|.artifacts/bin/%s{p}/release/%s{tfm}";
$"directory|.artifacts/bin/%s{p}/release_net8.0";
$"directory|.artifacts/bin/%s{p}/release_net9.0";
"-a"; "true"; "--target"; p; "-f"; "github-comment"; "--output"; outputFile
]
exec { run "dotnet" args }
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ host-based applications like [worker services](https://learn.microsoft.com/en-us
<!-- ✅ Any dependencies that need to be installed in addition to EDOT .NET -->
1. To take advantage of the OpenTelemetry SDK instrumentation for ASP.NET Core, add the following NuGet package to your project:
```xml
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="<LATEST>" />
```

This package includes instrumentation to collect traces for requests handled by ASP.NET Core endpoints.
Expand Down
6 changes: 4 additions & 2 deletions examples/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand Down
5 changes: 2 additions & 3 deletions examples/Example.AutoInstrumentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG OTEL_VERSION=1.7.0
ARG OTEL_VERSION=1.9.0
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
ARG TARGETPLATFORM
ARG TARGETARCH
Expand All @@ -18,7 +18,6 @@ ADD https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/relea
RUN chmod +x otel-dotnet-auto-install.sh
RUN OTEL_DOTNET_AUTO_HOME="/app/otel" sh otel-dotnet-auto-install.sh


FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build_example
ENV _PROJECT="Example.AutoInstrumentation"
ENV _PROJECTPATH="${_PROJECT}/${_PROJECT}.csproj"
Expand All @@ -33,7 +32,7 @@ RUN dotnet build "${_PROJECT}.csproj" -c Release -o /app/build_example
FROM build_example AS publish_example
RUN dotnet publish "Example.AutoInstrumentation.csproj" -c Release -o /app/example /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build_distro
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build_distro
ENV _PROJECT="Elastic.OpenTelemetry"
ENV _PROJECTPATH="${_PROJECT}/${_PROJECT}.csproj"
WORKDIR /work
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG OTEL_VERSION=1.7.0
ARG OTEL_VERSION=1.9.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETPLATFORM
ARG TARGETARCH
Expand Down
4 changes: 2 additions & 2 deletions examples/Example.Console/Example.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.15" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.9.0-beta.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/Example.MinimalApi/Example.MinimalApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/Example.WorkerService/Example.WorkerService.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-Example.Elastic.OpenTelemetry.Worker-3a9724de-5d6b-4e68-a21e-b90c655cc721</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

return builder;
Expand Down
6 changes: 3 additions & 3 deletions examples/ServiceDefaults/ServiceDefaults.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
Expand All @@ -10,8 +10,8 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.2.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.4.24156.9" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.404",
"version": "9.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>True</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.AutoInstrumentation" Version="1.7.0" GeneratePathProperty="true" PrivateAssets="contentfiles" />
<PackageReference Include="OpenTelemetry.AutoInstrumentation" Version="1.9.0" GeneratePathProperty="true" PrivateAssets="contentfiles" />
</ItemGroup>

<ItemGroup>
Expand All @@ -18,31 +18,26 @@
and link it as _instrument.cmd since we manually copy it over in the prebuild event -->
<Content Update="instrument.cmd" CopyToPublishDirectory="Never" CopyToOutputDirectory="Never" />
<Content Remove="instrument.cmd" />
<Content Include="_instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/_instrument.cmd"/>
<Content Include="instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/instrument.cmd"/>
<Content Include="_instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/_instrument.cmd" />
<Content Include="instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/instrument.cmd" />

<!-- ensure we remove the linked instrument.sh from base OpenTelemetry.AutoInstrumentation
and link it as _instrument.sh since we manually copy it over in the prebuild event -->

<Content Update="instrument.sh" CopyToPublishDirectory="Never" CopyToOutputDirectory="Never" />
<Content Remove="instrument.sh" />
<Content Include="_instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/_instrument.sh"/>
<Content Include="instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/instrument.sh"/>
<Content Include="_instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/_instrument.sh" />
<Content Include="instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/instrument.sh" />

<Content Include="instrument.props" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="build/elastic.opentelemetry.autoinstrumentation.props"/>
<Content Include="instrument.props" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="build/elastic.opentelemetry.autoinstrumentation.props" />

</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<!-- Copies the content files manually as physical files in the source repository -->
<!-- we manually repackage these as contentfiles (albeit renamed) -->
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.cmd" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.cmd"/>
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.sh" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.sh"/>
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.cmd" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.cmd" />
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.sh" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.sh" />
</Target>

<ItemGroup>
Expand Down
36 changes: 33 additions & 3 deletions src/Elastic.OpenTelemetry.AutoInstrumentation/_instrument.cmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
@echo off
setlocal
setlocal ENABLEDELAYEDEXPANSION

:: This script is expected to be used in a build that specified a RuntimeIdentifier (RID)
set BASE_PATH=%~dp0
set COR_PROFILER_PATH=%BASE_PATH%OpenTelemetry.AutoInstrumentation.Native.dll

:: Validate
IF EXIST %COR_PROFILER_PATH% (
set CORECLR_PROFILER_PATH=!COR_PROFILER_PATH!
) ELSE (
set "COR_PROFILER_PATH="

echo Unable to locate the native profiler inside current directory, possibly due to runtime identifier not being specified when building/publishing. ^
Attempting to use the native profiler from runtimes\win-x64\native and runtimes\win-x86\native subdirectories.

set COR_PROFILER_PATH_64=%BASE_PATH%runtimes\win-x64\native\OpenTelemetry.AutoInstrumentation.Native.dll
set COR_PROFILER_PATH_32=%BASE_PATH%runtimes\win-x86\native\OpenTelemetry.AutoInstrumentation.Native.dll

IF EXIST !COR_PROFILER_PATH_64! (
IF EXIST !COR_PROFILER_PATH_32! (
set CORECLR_PROFILER_PATH_32=!COR_PROFILER_PATH_32!
) ELSE (
set "COR_PROFILER_PATH_32="
)
set CORECLR_PROFILER_PATH_64=!COR_PROFILER_PATH_64!
) ELSE (
set "COR_PROFILER_PATH_64="
IF EXIST !COR_PROFILER_PATH_32! (
set CORECLR_PROFILER_PATH_32=!COR_PROFILER_PATH_32!
) ELSE (
set "COR_PROFILER_PATH_32="
echo Unable to locate the native profiler. 1>&2
exit /b 1
)
)
)

:: Settings for .NET Framework
set COR_ENABLE_PROFILING=1
set COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
set COR_PROFILER_PATH=%BASE_PATH%OpenTelemetry.AutoInstrumentation.Native.dll

:: On .NET Framework automatic assembly redirection MUST be disabled. This setting
:: is ignored on .NET. This is necessary because the NuGet package doesn't bring
Expand All @@ -20,7 +51,6 @@ set OTEL_DOTNET_AUTO_NETFX_REDIRECT_ENABLED=false
set ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper
set CORECLR_ENABLE_PROFILING=1
set CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
set CORECLR_PROFILER_PATH=%BASE_PATH%OpenTelemetry.AutoInstrumentation.Native.dll
set DOTNET_STARTUP_HOOKS=%BASE_PATH%OpenTelemetry.AutoInstrumentation.StartupHook.dll

:: Settings for OpenTelemetry
Expand Down
Loading

0 comments on commit 1c1a470

Please sign in to comment.