Description
APM Agent version
Version: 1.28.0
Environment
Operating system and version: Windows 10
.NET Framework/Core name and version : .NET 8
Application Target Framework(s): net8.0
Describe the bug
The transaction created by the APM SDK when sending a request, using HttpClient, is not appended correctly as child to the current opened transaction.
To Reproduce
I created a POC for you to reproduce this bug easier. See GitHub repo: elatic-apm-parent-segment-bug
OR
Steps to reproduce the behavior:
- Create a new ASP.NET Web Api application in Visual Studio
- Create 3 services,
FirstService.cs
,SecondService.cs
,ThirdService.cs
with a dummy method in each - In the controller endpoint created automatically, call
FirstService
's method passingAgent.Tracer.CurrentTransaction
as a parameter - In the
FirstService
's method, create a new transaction using the transaction from the controller as parent. Then, callSecondService
's method, passing the new transaction as a parameter - In the
SecondService
's method, create a new span using the transaction fromFirstService
as parent. Then, callThirdService
's method, passing the new span as a parameter - In the
ThirdService
's method, create a new transaction using the span from theSecondService
as parent. Then, using a HttpClient, send a GET request to any website (ex. google.com)
Expected behavior
The transaction created by the APM SDK when using the HttpClient should be appended as a child of the newly created transaction in ThirdService
Actual behavior
The transaction created by the APM SDK when using the HttpClient is appended as a child of the span created in SecondService
. If the SecondService
creates a transaction instead of span, the transaction created by the HttpClient is appended correctly as a child of ThirdService