'MiniProfiler .Ignore() extension method does not disable profiling
I have a method with a portion of code I want to ignore from profiling when using MiniProfiler.
As from documentation, the extension method that does this is .Ignore(), that when used in a using statement should disable profiling for the duration.
Unfortunately I'm not getting the results as expected. Suppose I have this method structure:
public async Task<IActionResult> FirstMethod()
{
using (MiniProfiler.Current.Step("FirstMethod"))
{
IActionResult result = this.SecondMethod();
using (MiniProfiler.Current.Ignore())
{
Thread.Sleep(100);
}
return result;
}
}
internal virtual IActionResult SecondMethod()
{
using (MiniProfiler.Current.CustomTiming("SQL", "QuerySecondMethod"))
{
// Some data logic
}
}
What I expected is that on profiler the FirstMethod step duration and the SecondMethod custom timing would be approximately the same, since FirstMethod only calls SecondMethod and is ignoring the Thread.Sleep().
But I keep getting that FirstMethod duration is 100 milliseconds longer than SecondMethod, which makes it looks like the Ignore is not really disabling the profiler for the code inside it.
What am I doing wrong? Am I misunderstanding the documentation and purpose of the Ignore method?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
