public void Init(HttpApplication context) { context.BeginRequest += (sender, e) => { MiniProfiler.Start(); }; // TODO: You can control who sees the profiling information /* * context.AuthenticateRequest += (sender, e) => * { * if (!CurrentUserIsAllowedToSeeProfiler()) * { * StackExchange.Profiling.MiniProfiler.Stop(discardResults: true); * } * }; */ context.EndRequest += (sender, e) => { MiniProfiler.Stop(); }; }
protected void Application_BeginRequest() { if (_miniProfilerEnabled) { MiniProfiler.Start(); } }
protected void Application_BeginRequest(object src, EventArgs e) { if (Request.IsLocal) { MiniProfiler.Start(); } }
protected void Application_BeginRequest(object sender, EventArgs e) { //ignore static resources var webHelper = EngineContext.Current.Resolve <IWebHelper>(); if (webHelper.IsStaticResource(this.Request)) { return; } //keep alive page requested (we ignore it to prevent creating a guest customer records) string keepAliveUrl = string.Format("{0}keepalive/index", webHelper.GetStoreLocation()); if (webHelper.GetThisPageUrl(false).StartsWith(keepAliveUrl, StringComparison.InvariantCultureIgnoreCase)) { return; } EnsureDatabaseIsInstalled(); if (CanPerformProfilingAction()) { MiniProfiler.Start(); } }
protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } }
protected void Application_BeginRequest() { if (Request.Url.Host.Contains("fotomsk") || Request.IsLocal || Request.Url.Host.Contains("ngweb")) { MiniProfiler.Start(); } }
protected void Application_BeginRequest() { if (Request.IsLocal)//这里是允许本地访问启动监控,可不写 { MiniProfiler.Start(); } }
public void Init(HttpApplication context) { context.BeginRequest += (sender, e) => { var request = ((HttpApplication)sender).Request; //TODO: Might want to decide here (or maybe inside the action) whether you want // to profile this request - for example, using an "IsSystemAdmin" flag against // the user, or similar; this could also all be done in action filters, but this // is simple and practical; just return null for most users. For our test, we'll // profile only for local requests (seems reasonable) if (request.IsLocal) { MiniProfiler.Start(); } }; // TODO: You can control who sees the profiling information /* * context.AuthenticateRequest += (sender, e) => * { * if (!CurrentUserIsAllowedToSeeProfiler()) * { * StackExchange.Profiling.MiniProfiler.Stop(discardResults: true); * } * }; */ context.EndRequest += (sender, e) => { MiniProfiler.Stop(); }; }
protected void Application_BeginRequest(object sender, EventArgs e) { if (Request.Cookies["Profiling"] != null) { MiniProfiler.Start(); } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (ProfilingEnabled) { MiniProfiler.Start(); } }
public void OnActionExecuting(ActionExecutingContext context) { MiniProfiler.Start(); if (MiniProfiler.Current != null) { Stack <IDisposable> stack; if (context.ActionDescriptor.Properties.ContainsKey(StackKey)) { stack = context.ActionDescriptor.Properties[StackKey] as Stack <IDisposable>; } else { stack = new Stack <IDisposable>(); context.ActionDescriptor.Properties[StackKey] = (object)stack; } MiniProfiler current = MiniProfiler.Current; if (current != null) { string controllerName = context.Controller.GetType().Name; string actionName = context.ActionDescriptor.DisplayName; stack.Push(MiniProfiler.Current.Step("Controller: " + controllerName + actionName)); } } }
protected void Application_BeginRequest() { if (ShouldProfile()) { MiniProfiler.Start(); } }
protected void Application_BeginRequest() { if (Sitecore.Context.Item != null && !Sitecore.Context.PageMode.IsExperienceEditorEditing && !Sitecore.Context.PageMode.IsPreview) { MiniProfiler.Start(); } }
protected void Application_BeginRequest(object sender, EventArgs e) { Current.Context.Response.BufferOutput = true; // MvcMiniProfiler stuff: MiniProfiler profiler = null; // might want to decide here (or maybe inside the action) whether you want // to profile this request - for example, using an "IsSystemAdmin" flag against // the user, or similar; this could also all be done in action filters, but this // is simple and practical; just return null for most users. For our test, we'll // profile only for local requests (seems reasonable) //if (Request.IsLocal) //{ // profiler = MvcMiniProfiler.MiniProfiler.Start(); //} #if DEBUG profiler = MiniProfiler.Start(); #endif using (profiler.Step("Application_BeginRequest")) { // you can start profiling your code immediately } }
protected void Application_BeginRequest(Object source, EventArgs e) { if (ConfigurationManager.AppSettings["Profiler"].ToString() == "true") { MiniProfiler.Start(); } //Application initialisation whth HttpContext HttpApplication app = (HttpApplication)source; HttpContext context = app.Context; //First Request Initialization FirstRequestInitialization.Initialize(context); //check db connection if (DbConnection == false) { DbConnection = DbConfig.TestConnection(); if ((bool)DbConnection == false) { context.Response.Redirect("~/DbError.html"); } } //Start Livecycle session var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(context)); if (routeData != null && routeData.RouteHandler is MvcRouteHandler) { HttpContext.Current.Items["_EntityContext"] = new Db(); HttpContext.Current.Items["_HttpContext"] = context; } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (Request.IsLocal) { MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue; MiniProfiler.Start(); } //HttpApplication app = (HttpApplication)sender; //string acceptEncoding = app.Request.Headers["Accept-Encoding"]; //System.IO.Stream prevUncompressedStream = app.Response.Filter; //if (acceptEncoding == null || acceptEncoding.Length == 0) // return; //acceptEncoding = acceptEncoding.ToLower(); //if (acceptEncoding.Contains("gzip")) //{ // // gzip // app.Response.Filter = new System.IO.Compression.GZipStream(prevUncompressedStream, // System.IO.Compression.CompressionMode.Compress); // app.Response.AppendHeader("Content-Encoding", // "gzip"); //} //else if (acceptEncoding.Contains("deflate")) //{ // // defalte // app.Response.Filter = new System.IO.Compression.DeflateStream(prevUncompressedStream, // System.IO.Compression.CompressionMode.Compress); // app.Response.AppendHeader("Content-Encoding", // "deflate"); //} }
protected void Application_BeginRequest() { if (bool.Parse(ConfigurationManager.AppSettings["OpenMiniProfiler"])) { MiniProfiler.Start(); } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (SmartContext.Config.DisplayMiniProfiler == true) { MiniProfiler.Start(); } }
public void Init(HttpApplication context) { context.BeginRequest += (sender, e) => { var request = ((HttpApplication)sender).Request; //TODO: By default only local requests are profiled, optionally you can set it up // so authenticated users are always profiled if (request.IsLocal) { MiniProfiler.Start(); } }; // TODO: You can control who sees the profiling information context.PostAuthenticateRequest += (sender, e) => { if (!context.Request.IsLocal) { StackExchange.Profiling.MiniProfiler.Stop(discardResults: true); } }; context.EndRequest += (sender, e) => { MiniProfiler.Stop(); }; }
private void Application_BeginRequest(object sender, EventArgs e) { if (Request.IsLocal) { MiniProfiler.Start(); } }
/// <summary> /// This is common of usages /// </summary> /// <param name="logger">The logger.</param> private static void MiniProfilerProvider(ILog logger) { MiniProfilerLog.SetUpLog4Net(logger); var mp = MiniProfiler.Start("Provider"); using (mp.Step("Level 1")) using (var conn = GetConnection()) { conn.Query <long>("select 1"); using (mp.Step("Level 2")) { conn.Query <long>("select 1"); conn.Query("select 2"); using (mp.Step("Level 3.1")) { Thread.Sleep(500); } } using (mp.Step("Level 2.2")) { conn.Query("select 1"); Thread.Sleep(500); } } MiniProfiler.Stop(); }
public void StepIf_Basic() { using (GetRequest()) { MiniProfiler.Start(); var mp1 = MiniProfiler.Current; Increment(); // 1 ms Timing goodTiming; Timing badTiming; using (goodTiming = (Timing)(mp1.StepIf("Yes", 1))) { Increment(2); } using (badTiming = (Timing)(mp1.StepIf("No", 5))) { Increment(); // 1 ms } MiniProfiler.Stop(); Assert.True(mp1.Root.Children.Contains(goodTiming)); Assert.True(!mp1.Root.Children.Contains(badTiming)); } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Request.IsLocal) { MiniProfiler.Start(); } }
public void CustomTimingIf_Basic() { using (GetRequest()) { MiniProfiler.Start(); var mp1 = MiniProfiler.Current; Increment(); // 1 ms CustomTiming goodTiming; CustomTiming badTiming; using (goodTiming = mp1.CustomTimingIf("Cat1", "Yes", 1)) { Increment(2); } using (badTiming = mp1.CustomTimingIf("Cat1", "No", 5)) { Increment(); // 1 ms } MiniProfiler.Stop(); Assert.True(mp1.Root.CustomTimings["Cat1"].Contains(goodTiming)); Assert.True(!mp1.Root.CustomTimings["Cat1"].Contains(badTiming)); } }
public void Init(HttpApplication context) { context.BeginRequest += (sender, e) => MiniProfiler.Start(); context.AuthorizeRequest += (sender, e) => { bool stopProfiling; var httpContext = HttpContext.Current; if (httpContext == null) { stopProfiling = true; } else { // Temporarily removing until we figure out the hammering of request we saw. //var userCanProfile = httpContext.User != null && HttpContext.Current.User.IsInRole(Const.AdminRoleName); var requestIsLocal = httpContext.Request.IsLocal; //stopProfiling = !userCanProfile && !requestIsLocal stopProfiling = !requestIsLocal; } if (stopProfiling) { MiniProfiler.Stop(true); } }; context.EndRequest += (sender, e) => MiniProfiler.Stop(); }
/// <summary> /// Returns a profiler for <paramref name="url"/>. Only child steps will take any time, /// e.g. when <paramref name="childDepth"/> is 0, the resulting <see cref="MiniProfiler.DurationMilliseconds"/> will be zero. /// </summary> /// <param name="childDepth">number of levels of child steps underneath result's <see cref="MiniProfiler.Root"/></param> /// <param name="stepsEachTakeMilliseconds">Amount of time each step will "do work for" in each step</param> /// <returns>the mini profiler</returns> public static MiniProfiler GetProfiler( string url = DefaultRequestUrl, int childDepth = 0, int stepsEachTakeMilliseconds = StepTimeMilliseconds) { MiniProfiler result = null; Action step = null; var curDepth = 0; // recursively add child steps step = () => { if (curDepth++ < childDepth) { using (result.Step("Depth " + curDepth)) { IncrementStopwatch(stepsEachTakeMilliseconds); step(); } } }; using (GetRequest(url, startAndStopProfiler: false)) { result = MiniProfiler.Start(); step(); MiniProfiler.Stop(); } return(result); }
private void InitializeProfiler() { var doProfile = false; // Check if cookie already exists or if startProfile is found in the query string. if (CookieUtil.AppProfiler == "do") { doProfile = true; } else if (Request.QueryString["startProfiler"] != null) { CookieUtil.AppProfiler = "do"; doProfile = true; } // Check if stopPrilie is found in the query string. if (Request.QueryString["stopProfiler"] != null) { CookieUtil.RemoveAppProfiler(); doProfile = false; } if (doProfile) { MiniProfiler.Start(); } }
protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } //or any number of other checks, up to you }
public void Init(HttpApplication context) { if (this.enableProfiling) { context.BeginRequest += (sender, e) => { var request = ((HttpApplication)sender).Request; //TODO: By default only local requests are profiled, optionally you can set it up // so authenticated users are always profiled if (request.IsLocal) { MiniProfiler.Start(); } }; // TODO: You can control who sees the profiling information /* * context.AuthenticateRequest += (sender, e) => * { * if (!CurrentUserIsAllowedToSeeProfiler()) * { * StackExchange.Profiling.MiniProfiler.Stop(discardResults: true); * } * }; */ context.EndRequest += (sender, e) => { MiniProfiler.Stop(); }; } }
protected void Application_BeginRequest() { if (Configuration.EnableMiniProfiler && Request.IsLocal) { MiniProfiler.Start(); } }