diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 8efeb956..7da11e5e 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -1,5 +1,6 @@ {"login": "manager","password": "l3tm3in"} +{"login": "OpsAdminLimited","password": "OpsAdminLimited"} todo: enable response compression diff --git a/server/AyaNova/AyaNova.csproj b/server/AyaNova/AyaNova.csproj index 08052ca2..839328b0 100644 --- a/server/AyaNova/AyaNova.csproj +++ b/server/AyaNova/AyaNova.csproj @@ -30,7 +30,7 @@ all - + diff --git a/server/AyaNova/Controllers/ServerMetricsController.cs b/server/AyaNova/Controllers/ServerMetricsController.cs index 9fa61dc5..d8e55d1a 100644 --- a/server/AyaNova/Controllers/ServerMetricsController.cs +++ b/server/AyaNova/Controllers/ServerMetricsController.cs @@ -14,7 +14,7 @@ using Newtonsoft.Json.Linq; using AyaNova.Models; using AyaNova.Api.ControllerHelpers; using AyaNova.Biz; - +using StackExchange.Profiling; namespace AyaNova.Api.Controllers { @@ -33,6 +33,7 @@ namespace AyaNova.Api.Controllers private readonly ApiServerState serverState; private const int DEFAULT_MAX_RECORDS = 400; private const long MB = (1024 * 1024); + /// /// ctor @@ -40,15 +41,37 @@ namespace AyaNova.Api.Controllers /// /// /// + /// public ServerMetricsController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) { ct = dbcontext; log = logger; - serverState = apiServerState; + serverState = apiServerState; } + + + + /// + /// + /// + /// + [HttpGet("prof")] + public async Task GetProfileMetrics() + { + using (MiniProfiler.Current.Step("Get Metrics test")) + { + await Task.Delay(1500); + //await Task.CompletedTask; + } + + //MiniProfiler.Current.RenderPlainText() + return Content(MiniProfiler.Current.RenderPlainText()); + + } + /// /// Get Memory and CPU server metrics for time period specified /// diff --git a/server/AyaNova/Program.cs b/server/AyaNova/Program.cs index a21d0771..eae2f20b 100644 --- a/server/AyaNova/Program.cs +++ b/server/AyaNova/Program.cs @@ -10,6 +10,7 @@ using NLog.Web; using NLog.Targets; using NLog.Config; using AyaNova.Util; +using StackExchange.Profiling; namespace AyaNova { @@ -20,6 +21,7 @@ namespace AyaNova public static void Main(string[] args) { + //Get config var config = new ConfigurationBuilder().AddEnvironmentVariables().AddCommandLine(args).Build(); ServerBootConfig.SetConfiguration(config); @@ -216,6 +218,7 @@ namespace AyaNova logger.Info("AyaNova server shutting down"); NLog.LogManager.Shutdown(); } + } diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 3050601e..c2cd88ff 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -107,6 +107,12 @@ namespace AyaNova FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical(_hostingEnvironment.ContentRootPath); #region DATABASE + // //NOTE: this is required to workaround a bug with miniprofiler + // //if I don't add the memory cache service miniprofiler does but the + // //addition of npgsql below fucks up the config for memory cache somehow + // //documented here: https://github.com/MiniProfiler/dotnet/issues/433 + // services.AddMemoryCache(); + _connectionString = ServerBootConfig.AYANOVA_DB_CONNECTION; //Check DB server exists and can be connected to @@ -283,75 +289,7 @@ 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(); @@ -373,7 +311,7 @@ namespace AyaNova // { // app.UseDeveloperExceptionPage(); // } - _newLog.LogDebug("Profiler"); + _newLog.LogDebug("Profiler"); app.UseMiniProfiler(); //Store a reference to the dependency injection service for static classes diff --git a/server/AyaNova/biz/BizObjectNameFetcherDirect.cs b/server/AyaNova/biz/BizObjectNameFetcherDirect.cs index e07625da..39126ba6 100644 --- a/server/AyaNova/biz/BizObjectNameFetcherDirect.cs +++ b/server/AyaNova/biz/BizObjectNameFetcherDirect.cs @@ -29,7 +29,10 @@ namespace AyaNova.Biz switch (ayaType) { //Oddballs only, otherwise let default handle it - + case AyaType.Global: + return "Global"; + case AyaType.GlobalOps: + return "GlobalOps"; case AyaType.FileAttachment: TABLE = "afileattachment"; COLUMN = "displayfilename"; diff --git a/server/AyaNova/generator/CoreJobMetricsSnapshot.cs b/server/AyaNova/generator/CoreJobMetricsSnapshot.cs index 2a355c31..34daf2e5 100644 --- a/server/AyaNova/generator/CoreJobMetricsSnapshot.cs +++ b/server/AyaNova/generator/CoreJobMetricsSnapshot.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Logging; using AyaNova.Util; using AyaNova.Models; using Microsoft.EntityFrameworkCore; - +using StackExchange.Profiling; namespace AyaNova.Biz @@ -177,7 +177,7 @@ namespace AyaNova.Biz DateTime ClearDate = DateTime.UtcNow - tsDataRetention; using (AyContext ct = ServiceProviderProvider.DBContext) { - // ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}"); + // ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}"); } _lastDDSnapshot = now; }