1

I have played around with the Miniprofiler recently. It works fine in our application, and have found some interesting things we're working on.

However, I have a use case, where I need to make a custom injection with a record, where I can set the duration.

In the picture below, you can see the "hack" I've made to show it right now, but I'd like it to show correctly:

enter image description here

My situation

I am consuming a third party API. Every single page has a lot of calls, and is called from different views.

The API has a .NET client, which has a delegate that's called after it's dine:

 private static void LogApiRequest(string httpMethod, string url, TimeSpan duration)

The issue is this method obviously is just used for logging, but I'd like to inject a duration here.

Any idea how to do it? :-)

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182

1 Answers1

1

if I understood well, just surround your API's calls with the following code:

ApiClient thirdPartyClient = new ApiClient();
using (profiler.Step("Calling third party API Methods"))
{ 
    thirdPartyClient.MethodX();
}

Or, using custom categories:

ApiClient thirdPartyClient = new ApiClient();
using(MiniProfiler.Current.CustomTiming("3rd Party API","API.MethodY")
{
    thirdPartyClient.MethodY();
}