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

Trace only some endpoints in .Net Core #685

Closed
rvignesh89 opened this issue Jan 10, 2020 · 5 comments
Closed

Trace only some endpoints in .Net Core #685

rvignesh89 opened this issue Jan 10, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@rvignesh89
Copy link

rvignesh89 commented Jan 10, 2020

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

@rvignesh89 rvignesh89 added the enhancement New feature or request label Jan 10, 2020
@gregkalapos
Copy link
Contributor

Thanks for opening this.

Yeah, this totally makes sense.

Other agents offer a config for this: ELASTIC_APM_IGNORE_URLS. E.g. here is the doc for it in Java.

I think best would be to align with those. I feel that would also solve your problem - do you also think so?

Regarding:

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.

Yes, you can change it - easiest is to set the ELASTIC_APM_SERVER_URLS environment variable to your real apm server url - docs.

@rvignesh89
Copy link
Author

Yes, I think it's what I was looking for. If I can submit PR would it be possible to get this merged?

I'll also try out setting ELASTIC_APM_SERVER_URLS without calling UseElasticApm and see if that works for me.

@gregkalapos
Copy link
Contributor

If I can submit PR would it be possible to get this merged?

Yes, of course - all PRs get reviewed and once they are ok and approved we are happy to merge. We have a CONTRIBUTING.md to help (make sure to sign the CLA :) ).

@gregkalapos
Copy link
Contributor

gregkalapos commented Jan 14, 2020

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

I just opened #688 which is based on elastic/apm#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 #688.

@rvignesh89
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants