From 6b4f99394d952deb347e1d8c6ac2ade947f52fc6 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 9 Feb 2021 15:30:39 +1100 Subject: [PATCH] Fix mini profiler so that it actually profiles the Content APIs in the back office --- src/Umbraco.Web/Logging/WebProfiler.cs | 10 +++++++--- src/Umbraco.Web/Logging/WebProfilerProvider.cs | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/Logging/WebProfiler.cs b/src/Umbraco.Web/Logging/WebProfiler.cs index 512edb2296..740afba6a7 100755 --- a/src/Umbraco.Web/Logging/WebProfiler.cs +++ b/src/Umbraco.Web/Logging/WebProfiler.cs @@ -26,12 +26,16 @@ namespace Umbraco.Web.Logging _provider = new WebProfilerProvider(); //see https://miniprofiler.com/dotnet/AspDotNet - MiniProfiler.Configure(new MiniProfilerOptions + var options = new MiniProfilerOptions { SqlFormatter = new SqlServerFormatter(), - StackMaxLength = 5000, + StackMaxLength = 5000, 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) diff --git a/src/Umbraco.Web/Logging/WebProfilerProvider.cs b/src/Umbraco.Web/Logging/WebProfilerProvider.cs index dbb81cf232..f38a606745 100755 --- a/src/Umbraco.Web/Logging/WebProfilerProvider.cs +++ b/src/Umbraco.Web/Logging/WebProfilerProvider.cs @@ -85,7 +85,11 @@ namespace Umbraco.Web.Logging public override MiniProfiler Start(string profilerName, MiniProfilerBaseOptions options) { 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); CurrentProfiler = _startupProfiler;