Skip to content

[BUG] Transaction created by the HttpClient is not appended as a child to the current Transaction #2408

Open
@cosmin19

Description

@cosmin19

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:

  1. Create a new ASP.NET Web Api application in Visual Studio
  2. Create 3 services, FirstService.cs, SecondService.cs, ThirdService.cs with a dummy method in each
  3. In the controller endpoint created automatically, call FirstService's method passing Agent.Tracer.CurrentTransaction as a parameter
  4. In the FirstService's method, create a new transaction using the transaction from the controller as parent. Then, call SecondService's method, passing the new transaction as a parameter
  5. In the SecondService's method, create a new span using the transaction from FirstService as parent. Then, call ThirdService's method, passing the new span as a parameter
  6. In the ThirdService's method, create a new transaction using the span from the SecondService 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions