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

Allow ElasticApmStartupHook to work with System.Diagnostics.DiagnosticSource 4 and 5 #1138

Merged

Conversation

russcam
Copy link
Contributor

@russcam russcam commented Jan 16, 2021

This commit updates the startup hook implementation to allow it to work with applications that are compiled against either
System.Diagnostics.DiagnosticSource 4 or 5.

Introduce a UseDiagnosticSourceFour MSBuild property to Elastic.Apm to conditionally reference System.Diagnostics.DiagnosticSource 4.x.x or 5.x.x. The build agent-zip task uses the property to compile Elastic.Apm against both System.Diagnostics.DiagnosticSource 4.x.x and 5.x.x, and package both into the startup hook zip file.

Split the startup hook agent assembly and dependency loading into its own assembly, Elastic.Apm.StartupHook.Loader, compiled against Elastic.Apm, allowing different versions to be compiled for different referenced System.Diagnostics.DiagnosticSource versions. ElasticApmStartupHook now determines if a version of System.Diagnostics.DiagnosticSource is already loaded, using this to determine which version of Elastic.Apm.StartupHook.Loader to load and invoke.

Update the build project pack target to build nuget packages and the zip file for startup hooks, and update CI linux scripts to use the build project pack target. This change requires the CI scripts to look in one directory for nuget packages, and allows artifacting the zip file.

Closes #1072
Closes #1134

This commit updates the pack and publish build functions
to pack and publish all releasable artifacts.
…cSource 4 and 5

This commit updates the startup hook implementation to allow
it to work with applications that are compiled against either
System.Diagnostics.DiagnosticSource 4 or 5.

Introduce a `UseDiagnosticSourceFour` MSBuild property to
Elastic.Apm to conditionally reference
System.Diagnostics.DiagnosticSource 4.x.x or 5.x.x. The
build agent-zip task uses the property to compile
Elastic.Apm against both
System.Diagnostics.DiagnosticSource 4.x.x and 5.x.x, and package
both into the startup hook zip file.

Split the startup hook agent assembly and dependency loading
into its own assembly, Elastic.Apm.StartupHook.Loader, compiled against Elastic.Apm, allowing
different versions to be compiled for different referenced
System.Diagnostics.DiagnosticSource versions.
ElasticApmStartupHook now determines if a version of
System.Diagnostics.DiagnosticSource is already loaded, using
this to determine which version of Elastic.Apm.StartupHook.Loader
to load and invoke.
@codecov-io
Copy link

codecov-io commented Jan 16, 2021

Codecov Report

Merging #1138 (bd3b238) into master (f89b43e) will increase coverage by 29.71%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1138       +/-   ##
===========================================
+ Coverage   49.83%   79.55%   +29.71%     
===========================================
  Files         155      160        +5     
  Lines        6188     6543      +355     
===========================================
+ Hits         3084     5205     +2121     
+ Misses       3104     1338     -1766     
Impacted Files Coverage Δ
.../Elastic.Apm.Specification/TypeValidationResult.cs 52.17% <0.00%> (ø)
...lastic.Apm.Specification/ImplementationProperty.cs 88.88% <0.00%> (ø)
...c/Elastic.Apm.Specification/TypeValidationError.cs 22.72% <0.00%> (ø)
src/Elastic.Apm.Specification/Validator.cs 67.57% <0.00%> (ø)
.../Elastic.Apm.Specification/JsonSchemaExtensions.cs 42.85% <0.00%> (ø)
src/Elastic.Apm/ServerInfo/ElasticVersion.cs 23.52% <0.00%> (+0.84%) ⬆️
src/Elastic.Apm/AgentComponents.cs 100.00% <0.00%> (+2.32%) ⬆️
src/Elastic.Apm/Helpers/PlatformDetection.cs 68.35% <0.00%> (+3.79%) ⬆️
...stic.Apm/DiagnosticSource/DiagnosticInitializer.cs 95.45% <0.00%> (+4.54%) ⬆️
src/Elastic.Apm/ApmAgentExtensions.cs 89.47% <0.00%> (+5.26%) ⬆️
... and 102 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f89b43e...bd3b238. Read the comment docs.

@apmmachine
Copy link
Contributor

apmmachine commented Jan 16, 2021

💔 Tests Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1138 updated

    • Start Time: 2021-01-27T05:48:23.381+0000
  • Duration: 62 min 15 sec

  • Commit: 758eb49

Test stats 🧪

Test Results
Failed 1
Passed 16439
Skipped 59
Total 16499

Test errors 1

Expand to view the tests failures

Initializing / Parallel / Windows .NET Framework / IIS Tests / ErrorsTests.Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.HttpCallWithResponseForbidden – Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests
    Expand to view the error details

     Expected receivedData.Spans.First().Context.Http.StatusCode to be 403, but found 503. 
    

    Expand to view the stacktrace

     Expected receivedData.Spans.First().Context.Http.StatusCode to be 403, but found 503.
    Stack Trace:
       at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\XUnit2TestFramework.cs:line 32
       at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 181
       at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Numeric\NumericAssertions.cs:line 50
       at Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.<>c__DisplayClass2_0.<HttpCallWithResponseForbidden>b__0(ReceivedData receivedData) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\ErrorsTests.cs:line 72
       at Elastic.Apm.AspNetFullFramework.Tests.TestsBase.WaitAndCustomVerifyReceivedData(Action`1 verifyAction, Boolean shouldGatherDiagnostics) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\TestsBase.cs:line 359
       at Elastic.Apm.AspNetFullFramework.Tests.TestsBase.WaitAndCustomVerifyReceivedData(Action`1 verifyAction, Boolean shouldGatherDiagnostics) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\TestsBase.cs:line 397
       at Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.HttpCallWithResponseForbidden() in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\ErrorsTests.cs:line 66
    --- End of stack trace from previous location where exception was thrown ---
    Standard Output:
        Elastic APM .NET Tests> 37> Xunit> [2021-01-27 06:37:51.955 +00:00][Info] - {LoggingTestBase} Starting test: Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.HttpCallWithResponseForbidden...
        Elastic APM .NET Tests> 37> Xunit> [2021-01-27 06:38:27.695 +00:00][Error] - {AspNetFullFramework.Tests.TestsBase} Reached max number of attempts to verify payload - Rethrowing the last exception...
        Elastic APM .NET Tests> 37> Xunit> +-> Exception: Xunit.Sdk.XunitException: Expected receivedData.Spans.First().Context.Http.StatusCode to be 403, but found 503.
        Elastic APM .NET Tests> 37> Xunit>    at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\XUnit2TestFramework.cs:line 32
        Elastic APM .NET Tests> 37> Xunit>    at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 181
        Elastic APM .NET Tests> 37> Xunit>    at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Numeric\NumericAssertions.cs:line 50
        Elastic APM .NET Tests> 37> Xunit>    at Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.<>c__DisplayClass2_0.<HttpCallWithResponseForbidden>b__0(ReceivedData receivedData) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\ErrorsTests.cs:line 72
        Elastic APM .NET Tests> 37> Xunit>    at Elastic.Apm.AspNetFullFramework.Tests.TestsBase.WaitAndCustomVerifyReceivedData(Action`1 verifyAction, Boolean shouldGatherDiagnostics) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\TestsBase.cs:line 359
        Elastic APM .NET Tests> 37> Xunit> [2021-01-27 06:38:32.123 +00:00][Info] - {LoggingTestBase} Finished test: Elastic.Apm.AspNetFullFramework.Tests.ErrorsTests.HttpCallWithResponseForbidden 
    

Steps errors 1

Expand to view the steps failures

Test IIS
  • Took 19 min 44 sec . View more details on here
  • Description: .ci/windows/test-iis.bat

Log output

Expand to view the last 100 lines of log output

[2021-01-27T06:50:25.360Z]       Executing ObjectResult, writing value of type 'System.String'.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) in 8.6446ms
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
[2021-01-27T06:50:25.360Z]       Request finished in 8.9725ms 200 text/plain; charset=utf-8
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
[2021-01-27T06:50:25.360Z]       Request starting HTTP/1.1 POST http://localhost:23698/intake/v2/events application/x-ndjson; charset=utf-8 3337
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
[2021-01-27T06:50:25.360Z]       Route matched with {action = "Post", controller = "IntakeV2Events"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Post() on controller Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController (Elastic.Apm.Tests.MockApmServer).
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
[2021-01-27T06:50:25.360Z]       Executing action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) - Validation state: Valid
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer), returned result Microsoft.AspNetCore.Mvc.OkObjectResult in 2.5905ms.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
[2021-01-27T06:50:25.360Z]       Executing ObjectResult, writing value of type 'System.String'.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) in 2.8253ms
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
[2021-01-27T06:50:25.360Z]       Request finished in 3.0597ms 200 text/plain; charset=utf-8
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
[2021-01-27T06:50:25.360Z]       Request starting HTTP/1.1 POST http://localhost:23698/intake/v2/events application/x-ndjson; charset=utf-8 19382
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
[2021-01-27T06:50:25.360Z]       Route matched with {action = "Post", controller = "IntakeV2Events"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Post() on controller Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController (Elastic.Apm.Tests.MockApmServer).
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
[2021-01-27T06:50:25.360Z]       Executing action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) - Validation state: Valid
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer), returned result Microsoft.AspNetCore.Mvc.OkObjectResult in 6.3207ms.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
[2021-01-27T06:50:25.360Z]       Executing ObjectResult, writing value of type 'System.String'.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) in 6.6058ms
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
[2021-01-27T06:50:25.360Z]       Request finished in 6.8597ms 200 text/plain; charset=utf-8
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
[2021-01-27T06:50:25.360Z]       Request starting HTTP/1.1 POST http://localhost:23698/intake/v2/events application/x-ndjson; charset=utf-8 3338
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
[2021-01-27T06:50:25.360Z]       Route matched with {action = "Post", controller = "IntakeV2Events"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Post() on controller Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController (Elastic.Apm.Tests.MockApmServer).
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
[2021-01-27T06:50:25.360Z]       Executing action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) - Validation state: Valid
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer), returned result Microsoft.AspNetCore.Mvc.OkObjectResult in 2.7641ms.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
[2021-01-27T06:50:25.360Z]       Executing ObjectResult, writing value of type 'System.String'.
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.360Z]       Executed action Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) in 3.0079ms
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
[2021-01-27T06:50:25.360Z]       Request finished in 3.2395ms 200 text/plain; charset=utf-8
[2021-01-27T06:50:25.360Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
[2021-01-27T06:50:25.361Z]       Request starting HTTP/1.1 POST http://localhost:23698/intake/v2/events application/x-ndjson; charset=utf-8 2080
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
[2021-01-27T06:50:25.361Z]       Route matched with {action = "Post", controller = "IntakeV2Events"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Post() on controller Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController (Elastic.Apm.Tests.MockApmServer).
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
[2021-01-27T06:50:25.361Z]       Executing action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) - Validation state: Valid
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.361Z]       Executed action method Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer), returned result Microsoft.AspNetCore.Mvc.OkObjectResult in 2.9137ms.
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
[2021-01-27T06:50:25.361Z]       Executing ObjectResult, writing value of type 'System.String'.
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
[2021-01-27T06:50:25.361Z]       Executed action Elastic.Apm.Tests.MockApmServer.Controllers.IntakeV2EventsController.Post (Elastic.Apm.Tests.MockApmServer) in 3.2079ms
[2021-01-27T06:50:25.361Z] info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
[2021-01-27T06:50:25.361Z]       Request finished in 3.5974ms 200 text/plain; charset=utf-8
[2021-01-27T06:50:26.733Z] Elastic APM .NET Tests> 99> Console> [2021-01-27 06:50:26.596 +00:00][Info] - {LoggingTestBase} Finished test: Elastic.Apm.AspNetFullFramework.Tests.CentralConfigTests+MaxSpansAndSampleRateTests.MaxSpans_invalid_value
[2021-01-27T06:50:26.733Z] [xUnit.net 00:18:39.42]   Finished:    Elastic.Apm.AspNetFullFramework.Tests
[2021-01-27T06:50:26.991Z]   Passed Elastic.Apm.AspNetFullFramework.Tests.CentralConfigTests+MaxSpansAndSampleRateTests.MaxSpans_invalid_value [10 s]
[2021-01-27T06:50:26.991Z] 
[2021-01-27T06:50:26.991Z] JunitXML Logger - Results File: C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet\test\Elastic.Apm.AspNetFullFramework.Tests\junit-NETCoreApp21-Elastic.Apm.AspNetFullFramework.Tests.xml
[2021-01-27T06:50:26.991Z] 
[2021-01-27T06:50:26.991Z] Test Run Failed.
[2021-01-27T06:50:26.991Z] Total tests: 114
[2021-01-27T06:50:26.991Z]      Passed: 113
[2021-01-27T06:50:26.991Z]      Failed: 1
[2021-01-27T06:50:26.991Z]  Total time: 18.7002 Minutes
[2021-01-27T06:50:26.991Z] 
[2021-01-27T06:50:26.991Z] Build FAILED.
[2021-01-27T06:50:26.991Z]     0 Warning(s)
[2021-01-27T06:50:26.991Z]     0 Error(s)
[2021-01-27T06:50:26.991Z] 
[2021-01-27T06:50:26.991Z] Time Elapsed 00:18:42.96
[2021-01-27T06:50:28.131Z] Post stage
[2021-01-27T06:50:28.141Z] Running in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1138\apm-agent-dotnet
[2021-01-27T06:50:28.163Z] Archiving artifacts
[2021-01-27T06:50:28.653Z] Recording test results
[2021-01-27T06:50:32.121Z] Post stage
[2021-01-27T06:50:32.137Z] [WS-CLEANUP] Deleting project workspace...
[2021-01-27T06:50:32.137Z] [WS-CLEANUP] Deferred wipeout is disabled by the job configuration...
[2021-01-27T06:50:36.662Z] [WS-CLEANUP] done
[2021-01-27T06:50:36.762Z] Failed in branch Windows .NET Framework
[2021-01-27T06:50:36.867Z] Stage "Release to feedz.io" skipped due to earlier failure(s)
[2021-01-27T06:50:36.919Z] Stage "Release" skipped due to earlier failure(s)
[2021-01-27T06:50:36.940Z] Stage "Release" skipped due to earlier failure(s)
[2021-01-27T06:50:36.993Z] Stage "Release" skipped due to earlier failure(s)
[2021-01-27T06:50:37.083Z] Stage "AfterRelease" skipped due to earlier failure(s)
[2021-01-27T06:50:37.104Z] Stage "AfterRelease" skipped due to earlier failure(s)
[2021-01-27T06:50:37.699Z] Running on Jenkins in /var/lib/jenkins/workspace/net_apm-agent-dotnet-mbp_PR-1138
[2021-01-27T06:50:37.769Z] [INFO] getVaultSecret: Getting secrets
[2021-01-27T06:50:38.110Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-01-27T06:50:38.990Z] + chmod 755 generate-build-data.sh
[2021-01-27T06:50:38.991Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-dotnet/apm-agent-dotnet-mbp/PR-1138/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-dotnet/apm-agent-dotnet-mbp/PR-1138/runs/24 FAILURE 3735350
[2021-01-27T06:50:39.541Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-dotnet/apm-agent-dotnet-mbp/PR-1138/runs/24/steps/?limit=10000 -o steps-info.json
[2021-01-27T06:50:40.092Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-dotnet/apm-agent-dotnet-mbp/PR-1138/runs/24/tests/?status=FAILED -o tests-errors.json

@russcam
Copy link
Contributor Author

russcam commented Jan 17, 2021

run tests

@russcam
Copy link
Contributor Author

russcam commented Jan 19, 2021

run tests

@russcam
Copy link
Contributor Author

russcam commented Jan 19, 2021

The build target agent-docker builds a docker image containing all of the assemblies to auto instrument using startup hooks. This can be tested by

  1. Building the docker image with

    ./build.bat agent-docker
    

    (use ./build.sh on macOS or Linux)

  2. Build a docker image that uses the built docker image. An example Dockerfile

    FROM observability/apm-agent-dotnet:1.7.1 AS agent
    
    FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
    WORKDIR /sampleapp
    
    RUN dotnet new mvc
    RUN dotnet publish -c Release -o out
    
    # Build runtime image
    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
    WORKDIR /app
    ENV DOTNET_STARTUP_HOOKS=/usr/agent/ElasticApmAgentStartupHook.dll
    COPY --from=agent /usr/agent /usr/agent
    COPY --from=build-env /sampleapp/out .
    ENTRYPOINT ["dotnet", "sampleapp.dll"]
    

    To build the image. In the directory container the above Dockerfile

    docker build --tag startuphook-sample .
    
  3. Run the startuphook-sample image

    docker run --publish 5000:80 -e ELASTIC_APM_LOG_LEVEL=Trace -e ELASTIC_APM_STARTUP_HOOKS_LOGGING=1 --rm startuphook-sample
    

A similar approach would help with #1073

@russcam russcam marked this pull request as ready for review January 19, 2021 08:30
@russcam russcam requested a review from gregkalapos January 19, 2021 08:31
Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Added a few minor things I noticed.

.ci/linux/build.sh Show resolved Hide resolved
.ci/windows/msbuild.bat Show resolved Hide resolved
src/Elastic.Apm.StartupHook.Loader/Loader.cs Outdated Show resolved Hide resolved
src/Elastic.Apm.StartupHook.Loader/Loader.cs Outdated Show resolved Hide resolved
src/Elastic.Apm/Elastic.Apm.csproj Outdated Show resolved Hide resolved
src/ElasticApmAgentStartupHook/StartupHook.cs Outdated Show resolved Hide resolved
@russcam
Copy link
Contributor Author

russcam commented Jan 27, 2021

Will merge this in and follow up with a PR with automated tests. Manually tested with ASP.NET Core 3.1 and ASP.NET 5

@russcam russcam merged commit 914d301 into elastic:master Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading agent with DOTNET_STARTUP_HOOK on .NET 5 Build ElasticApmAgent_<Version>.zip on CI
4 participants