From 217488872f55b6e61959d74626c74698d73ccdb0 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 30 May 2020 18:48:26 +0000 Subject: [PATCH] --- devdocs/todo.txt | 3 +- server/AyaNova/AyaNova.csproj | 1 + server/AyaNova/Startup.cs | 75 ++++++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 07e605b4..8efeb956 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -2,7 +2,8 @@ - +todo: enable response compression + https://www.infoworld.com/article/3256012/how-to-use-response-compression-in-aspnet-core.html TODO: Why is this adding UTC bit to this query check the source code maybe something is up diff --git a/server/AyaNova/AyaNova.csproj b/server/AyaNova/AyaNova.csproj index 183a2168..08052ca2 100644 --- a/server/AyaNova/AyaNova.csproj +++ b/server/AyaNova/AyaNova.csproj @@ -30,6 +30,7 @@ all + diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 76a8904e..3050601e 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -21,6 +21,7 @@ using AyaNova.Util; using AyaNova.Generator; using AyaNova.Biz; using NLog.Extensions.Logging; +using StackExchange.Profiling; namespace AyaNova { @@ -281,6 +282,77 @@ namespace AyaNova #endregion + + #region Mini Profiler + // services.AddMemoryCache(); + services.AddMiniProfiler(options => + { + // All of this is optional. You can simply call .AddMiniProfiler() for all defaults + + // (Optional) Path to use for profiler URLs, default is /mini-profiler-resources + // options.RouteBasePath = "/profiler"; + + // (Optional) Control storage + // (default is 30 minutes in MemoryCacheStorage) + // (options.Storage as System.Runtime.MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(60); + + // (Optional) Control which SQL formatter to use, InlineFormatter is the default + // options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(); + + // (Optional) To control authorization, you can use the Func options: + // (default is everyone can access profilers) + // options.ResultsAuthorize = request => MyGetUserFunction(request).CanSeeMiniProfiler; + // options.ResultsListAuthorize = request => MyGetUserFunction(request).CanSeeMiniProfiler; + // Or, there are async versions available: + // options.ResultsAuthorizeAsync = async request => (await MyGetUserFunctionAsync(request)).CanSeeMiniProfiler; + // options.ResultsAuthorizeListAsync = async request => (await MyGetUserFunctionAsync(request)).CanSeeMiniProfilerLists; + + // (Optional) To control which requests are profiled, use the Func option: + // (default is everything should be profiled) + // options.ShouldProfile = request => MyShouldThisBeProfiledFunction(request); + + // (Optional) Profiles are stored under a user ID, function to get it: + // (default is null, since above methods don't use it by default) + // options.UserIdProvider = request => MyGetUserIdFunction(request); + + // (Optional) Swap out the entire profiler provider, if you want + // (default handles async and works fine for almost all applications) + // options.ProfilerProvider = new MyProfilerProvider(); + + // (Optional) You can disable "Connection Open()", "Connection Close()" (and async variant) tracking. + // (defaults to true, and connection opening/closing is tracked) + // options.TrackConnectionOpenClose = true; + + // (Optional) Use something other than the "light" color scheme. + // (defaults to "light") + // options.ColorScheme = StackExchange.Profiling.ColorScheme.Auto; + + // The below are newer options, available in .NET Core 3.0 and above: + + // (Optional) You can disable MVC filter profiling + // (defaults to true, and filters are profiled) + // options.EnableMvcFilterProfiling = true; + // ...or only save filters that take over a certain millisecond duration (including their children) + // (defaults to null, and all filters are profiled) + // options.MvcFilterMinimumSaveMs = 1.0m; + + // (Optional) You can disable MVC view profiling + // (defaults to true, and views are profiled) + // options.EnableMvcViewProfiling = true; + // ...or only save views that take over a certain millisecond duration (including their children) + // (defaults to null, and all views are profiled) + // options.MvcViewMinimumSaveMs = 1.0m; + + // (Optional - not recommended) You can enable a heavy debug mode with stacks and tooltips when using memory storage + // It has a lot of overhead vs. normal profiling and should only be used with that in mind + // (defaults to false, debug/heavy mode is off) + //options.EnableDebugMode = true; + }); + + #endregion + + + _newLog.LogDebug("Generator"); services.AddSingleton(); @@ -301,7 +373,8 @@ namespace AyaNova // { // app.UseDeveloperExceptionPage(); // } - + _newLog.LogDebug("Profiler"); + app.UseMiniProfiler(); //Store a reference to the dependency injection service for static classes ServiceProviderProvider.Provider = app.ApplicationServices;