I am trying to register how much time each method takes to execute. I do not want to use any 3rd party tools which does this. I also looked at few older posts that have some suggestion but they are pretty old, so I am looking for recommendation if there is a newer way to do it. Also, this instrumentation logic should work with .net core and .net full framework.
I do not want to do something like this
class myClass{
public void mytest(){
StopWatch sw = new StopWatch();
sw.start();
// DO SOMETHING
sw.stop();
log(sw.elapse());
}
}
Also, I want to tie everything to a ID and do not want to pass the ID to all the methods which would be a lot of work. So, want to create an interface and it does all the performance logging for all the methods which are used.
Please let me know if this is not clear enough. I can provide with any clarification.
What I am writing is a Nuget Package. This nuget packagae can be used in a .net core webapp or it can be used in a legacy WCF application. With that said the nuget package received a request, it then does some business logic and then calls a geospatical database. What I am looking for is a way to know the duration of each call that is done in the business logic or calling the DB. The reason for this is that when the geo data changes, some queries that we have may not function optimally or some others rules set in the business logic could become unoptimized and hence I would look at this speeds to see where the issue is and debug it accordingly.