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

[BUG] Transaction constructor always throws and handles System.InvalidOperationException when WebRequestTransactionCreator invokes StartTransactionAsync in Elastic.Apm.AspNetCore when the http request has distributedTracingData #2446

Open
alex-tselikovsky opened this issue Sep 18, 2024 · 0 comments
Labels
bug Something isn't working community triage

Comments

@alex-tselikovsky
Copy link

alex-tselikovsky commented Sep 18, 2024

APM Agent version

1.28.6

Environment

Linux&Windows

.Net Core 6

Describe the bug

We use AspNetCoreDiagnosticSubscriber.

Invoking WebRequestTransactionCreator.StartTransactionAsync creates new Transaction for incoming request. A new System.Diagnostics activity is created in a new transaction, and the parent of new Activity is set to "Microsoft.AspNetCore.Hosting.HttpRequestIn" which is created by Asp.NetCore.

The problem occurs when the request has the distributed tracing data. In this case the APM transaction constructor tries to set for a new activity another parent from the distributed tracing. In this moment InvalidOperationException occurs, because the parent activity already exists.

Image

Elastic.Apm.Model.Transaction.cs source code

Image

The exception is handled but it creates noise in the .Net counter metrics and can affect the performance.
Image

To Reproduce

Steps to reproduce the behavior:

  1. Use default config.
  2. Use external service which transfers distributed tracing data to our service in http request
  3. See error in net counters

Expected behavior

Therea aren't any System.InvalidOpertionExeptions in .Net counters

Actual behavior

Therea are a lot of System.InvalidOpertionExeptions in .Net counters

@alex-tselikovsky alex-tselikovsky added the bug Something isn't working label Sep 18, 2024
@alex-tselikovsky alex-tselikovsky changed the title [BUG] Transaction constructor always throws and handles System.InvalidOperationException when WebRequestTransactionCreator invoke StartTransactionAsync in Elastic.Apm.AspNetCore when the http request has distributedTracingDatadata [BUG] Transaction constructor always throws and handles System.InvalidOperationException when WebRequestTransactionCreator invoke StartTransactionAsync in Elastic.Apm.AspNetCore when the http request has distributedTracingData Sep 18, 2024
@alex-tselikovsky alex-tselikovsky changed the title [BUG] Transaction constructor always throws and handles System.InvalidOperationException when WebRequestTransactionCreator invoke StartTransactionAsync in Elastic.Apm.AspNetCore when the http request has distributedTracingData [BUG] Transaction constructor always throws and handles System.InvalidOperationException when WebRequestTransactionCreator invokes StartTransactionAsync in Elastic.Apm.AspNetCore when the http request has distributedTracingData Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community triage
Projects
None yet
Development

No branches or pull requests

1 participant