Fix mini profiler so that it actually profiles the Content APIs in the back office

This commit is contained in:
Shannon
2021-02-09 15:30:39 +11:00
parent febb15445a
commit 6b4f99394d
2 changed files with 12 additions and 4 deletions

View File

@@ -26,12 +26,16 @@ namespace Umbraco.Web.Logging
_provider = new WebProfilerProvider(); _provider = new WebProfilerProvider();
//see https://miniprofiler.com/dotnet/AspDotNet //see https://miniprofiler.com/dotnet/AspDotNet
MiniProfiler.Configure(new MiniProfilerOptions var options = new MiniProfilerOptions
{ {
SqlFormatter = new SqlServerFormatter(), SqlFormatter = new SqlServerFormatter(),
StackMaxLength = 5000, StackMaxLength = 5000,
ProfilerProvider = _provider ProfilerProvider = _provider
}); };
// this is a default path and by default it performs a 'contains' check which will match our content controller
// (and probably other requests) and ignore them.
options.IgnoredPaths.Remove("/content/");
MiniProfiler.Configure(options);
} }
public void UmbracoApplicationBeginRequest(object sender, EventArgs e) public void UmbracoApplicationBeginRequest(object sender, EventArgs e)

View File

@@ -85,7 +85,11 @@ namespace Umbraco.Web.Logging
public override MiniProfiler Start(string profilerName, MiniProfilerBaseOptions options) public override MiniProfiler Start(string profilerName, MiniProfilerBaseOptions options)
{ {
var first = Interlocked.Exchange(ref _first, 1) == 0; var first = Interlocked.Exchange(ref _first, 1) == 0;
if (first == false) return base.Start(profilerName, options); if (first == false)
{
var profiler = base.Start(profilerName, options);
return profiler;
}
_startupProfiler = new MiniProfiler("StartupProfiler", options); _startupProfiler = new MiniProfiler("StartupProfiler", options);
CurrentProfiler = _startupProfiler; CurrentProfiler = _startupProfiler;