question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trace only some endpoints in .Net Core

See original GitHub issue

Is your feature request related to a problem? Please describe. Yes. I would like to install the .Net Core APM agent on a Web API to trace a particular endpoint which is slow. However when I install Elastic.Apm.AspNetCore it starts listening to all requests through the ApmMiddleware. Since my API has very high request rates, I’d most likely have to set a TransactionSampleRate config to avoid any performance hits. However, I’m afraid by setting this I’ll miss samples from the single endpoint for which I want to monitor all the calls. The reason I can’t sample calls on that particular endpoint is because the response time of that endpoint varies wildly based on the parameters it receives which is exactly what I’d like to observe.

Describe the solution you’d like I’d like to have a way to enable tracing only on particular controllers instead of listening in on all using the middleware appraoch.

Describe alternatives you’ve considered A couple of alternative approaches that I can think off-

  1. I realize that I can achieve what I want by initiating the elastic apm agent as done in the (ApmMiddlewareExtensions) but it’s not easy for me to just instantiate the agent without turning on the middleware.
  2. If the lib can provide a way to instantiate the Agent without adding the middleware I could easily start a transaction myself wherever I need to trace. Actually I’m able to do that right now, but the agent tries to write the logs to localhost:8200 which I’m guessing the default endpoint used when not properly configured.

Additional context

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rvignesh89commented, Jan 15, 2020

I’m fine with closing this. Will follow up with #688. Thanks!

0reactions
gregkalaposcommented, Jan 14, 2020

@rvignesh89 there were some differences on this across agents. We had 1 issue to harmonize this across agents.

I just opened https://github.com/elastic/apm-agent-dotnet/issues/688 which is based on https://github.com/elastic/apm/issues/144 - that’s usually our process to be aligned across agents - first we have an APM issue in https://github.com/elastic/apm/ and then each agent creates a corresponding issue.

In case you open a PR, please make sure you follow the new issue.

I’d close this one if you are ok with it and keep https://github.com/elastic/apm-agent-dotnet/issues/688.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trace Propagation & Public API Endpoints in .NET - Honeycomb
The easiest way around the propagation issue is to ignore all incoming trace headers. This is fine if your service only has public...
Read more >
How to disable ASP.NET Core activities but continue ...
NET Core Activities but continue endpoint tracing: using OpenTelemetry.Resources; using OpenTelemetry.Trace; using System.
Read more >
Tracing in ASP.NET Web API 2
From a controller, this method is accessible through the ApiController.Configuration property. To write a trace, you can call the ITraceWriter.
Read more >
Routing in ASP.NET Core
Routing is responsible for matching incoming HTTP requests and dispatching those requests to the app's executable endpoints.
Read more >
Trace Propagation and Public API Endpoints in .NET
The easiest way around the propagation issue is to ignore all incoming trace headers. This is fine if your service only has public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found