Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move StartupHooks over to netstandard2.0 #2239

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/scripts/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ module Build =
agentDir.Create()

// copy startup hook to root of agent directory
!! (Paths.BuildOutput "ElasticApmAgentStartupHook/netcoreapp2.2")
!! (Paths.BuildOutput "ElasticApmAgentStartupHook/netstandard2.0")
|> Seq.filter Path.isDirectory
|> Seq.map DirectoryInfo
|> Seq.iter (copyDllsAndPdbs agentDir)
Expand All @@ -231,14 +231,14 @@ module Build =
|> Seq.iter (copyDllsAndPdbs (agentDir.CreateSubdirectory(sprintf "%i.0.0" getCurrentApmDiagnosticSourceVersion.Major)))

// assemblies compiled against older version of System.Diagnostics.DiagnosticSource
!! (Paths.BuildOutput (sprintf "Elastic.Apm.StartupHook.Loader_%i.0.0/netcoreapp2.2" oldDiagnosticSourceVersion.Major))
!! (Paths.BuildOutput (sprintf "Elastic.Apm.StartupHook.Loader_%i.0.0/netstandard2.0" oldDiagnosticSourceVersion.Major))
++ (Paths.BuildOutput (sprintf "Elastic.Apm_%i.0.0/netstandard2.0" oldDiagnosticSourceVersion.Major))
|> Seq.filter Path.isDirectory
|> Seq.map DirectoryInfo
|> Seq.iter (copyDllsAndPdbs (agentDir.CreateSubdirectory(sprintf "%i.0.0" oldDiagnosticSourceVersion.Major)))

// assemblies compiled against 6.0 version of System.Diagnostics.DiagnosticSource
!! (Paths.BuildOutput (sprintf "Elastic.Apm.StartupHook.Loader_%i.0.0/netcoreapp2.2" oldDiagnosticSourceVersion.Major)) //using old version here, because it the netcoreapp2.2 app can't build with diagnosticsource6
!! (Paths.BuildOutput (sprintf "Elastic.Apm.StartupHook.Loader_%i.0.0/netstandard2.0" oldDiagnosticSourceVersion.Major)) //using old version here, because it the netcoreapp2.2 app can't build with diagnosticsource6
++ (Paths.BuildOutput (sprintf "Elastic.Apm_%i.0.0/net6.0" diagnosticSourceVersion6.Major))
|> Seq.filter Path.isDirectory
|> Seq.map DirectoryInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- TODO make this netstandard 2.0 and ref System.Runtime.Loader -->
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Elastic.Apm\Elastic.Apm.csproj" />
<ProjectReference Include="..\..\integrations\Elastic.Apm.AspNetCore\Elastic.Apm.AspNetCore.csproj" />
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.Elasticsearch\Elastic.Apm.Elasticsearch.csproj" />
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.EntityFrameworkCore\Elastic.Apm.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.GrpcClient\Elastic.Apm.GrpcClient.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Elastic.Apm\Elastic.Apm.csproj"/>
<ProjectReference Include="..\..\integrations\Elastic.Apm.AspNetCore\Elastic.Apm.AspNetCore.csproj"/>
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.Elasticsearch\Elastic.Apm.Elasticsearch.csproj"/>
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.EntityFrameworkCore\Elastic.Apm.EntityFrameworkCore.csproj"/>
<ProjectReference Include="..\..\instrumentations\Elastic.Apm.GrpcClient\Elastic.Apm.GrpcClient.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0"/>
</ItemGroup>

<ItemGroup>
<Compile Include="..\ElasticApmAgentStartupHook\StartupHookLogger.cs">
<Link>StartupHookLogger.cs</Link>
</Compile>
</ItemGroup>

<ItemGroup>
<Compile Include="..\ElasticApmAgentStartupHook\StartupHookLogger.cs">
<Link>StartupHookLogger.cs</Link>
</Compile>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- TODO make this netstandard 2.0 and ref System.Runtime.Loader -->
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>ElasticApmAgentStartupHook</AssemblyName>
<IsPackable>false</IsPackable>
<RootNamespace>ElasticApmStartupHook</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
</Project>
24 changes: 12 additions & 12 deletions src/startuphook/ElasticApmAgentStartupHook/StartupHookLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ public static StartupHookLogger Create()

public void WriteLine(string message)
{
if (_enabled)
if (!_enabled)
return;

try
{
var log = $"[{DateTime.Now:u}] {message}";
Console.Out.WriteLine(log);
Console.Out.Flush();
File.AppendAllLines(_logPath, new[] { log });
}
catch
{
try
{
var log = $"[{DateTime.Now:u}] {message}";
Console.Out.WriteLine(log);
Console.Out.Flush();
File.AppendAllLines(_logPath, new[] { log });
}
catch
{
// if we can't log a log message, there's not much that can be done, so ignore
}
// if we can't log a log message, there's not much that can be done, so ignore
}
}
}
Expand Down
Loading