我正在寻找以下环境的分析解决方案,有人可以建议吗?
我研究了MiniProfiler和Glimpse。
httpAngular 2,但我认为Angular 5现在正在使用。HttpClientinterceptorDataContext (System.Data.Linq)使用 MiniProfile 进行 SQL 分析。文档建议Connection包装方法。我想这是一个单独的问题。profiling glimpse mvc-mini-profiler asp.net-core-2.0 angular
我已将以下代码添加到与实体框架配合使用的 asp.net core .net 5 应用程序中。在startup.cs中我有:
services.AddMiniProfiler(options =>
{
options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft;
options.PopupShowTimeWithChildren = true;
options.RouteBasePath = "/profiler";
}).AddEntityFramework();
Run Code Online (Sandbox Code Playgroud)
在我的 app.useRouting 之前我有
app.UseMiniProfiler();
Run Code Online (Sandbox Code Playgroud)
我添加到一个控制器,我知道它被称为以下内容:
using System.Collections.Generic;
using System.Linq;
using EFSvcc.Models;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Profiling;
namespace WebAppReactCRA.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly svcodecampContext _dbContext;
public WeatherForecastController(svcodecampContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public List<DiscountCode> Get()
{
List<DiscountCode> discountCodes;
using (MiniProfiler.Current.Step("WeatherForecastController: Groupby Clause For Total and Sent"))
{
var z = _dbContext.DiscountCodes;
discountCodes = z.ToList(); …Run Code Online (Sandbox Code Playgroud) mvc-mini-profiler entity-framework-core miniprofiler asp.net-core
我正在使用MVC Mini事件探查器,并且仅向处于“事件探查器”角色的经过身份验证的用户显示事件探查器。MiniProfiler.cs中提供的示例使用的是AuthenticateRequest方法来确定是否应该停止分析,但是我切换了我的方法以使用PostAuthorizeRequest(在阅读完此问题之后),以便可以访问IPrincipal和IsInRole方法。我可以仅在PostAuthorizeRequest方法中启动分析器,还是应该继续停止并在PostAuthorizeRequest中丢弃结果?每个请求启动和停止分析器的开销是多少?
当前代码:
public void Init(HttpApplication context)
{
context.BeginRequest += (sender, e) =>
{
MiniProfiler.Start();
};
context.PostAuthorizeRequest += (sender, e) =>
{
var user = ((HttpApplication)sender).Context.User;
if (user == null || !user.Identity.IsAuthenticated || !user.IsInRole("Profiler"))
{
MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);
}
};
context.EndRequest += (sender, e) =>
{
MiniProfiler.Stop();
};
}
Run Code Online (Sandbox Code Playgroud)
建议代码:
public void Init(HttpApplication context)
{
context.PostAuthorizeRequest += (sender, e) =>
{
var user = ((HttpApplication)sender).Context.User;
if (user != null && user.Identity.IsAuthenticated && user.IsInRole("Profiler"))
{
MiniProfiler.Start();
}
};
context.EndRequest += …Run Code Online (Sandbox Code Playgroud) 我在我的asp.net MVC 3应用程序上使用mini-profiler.我使用mvc nuget包实现了探查器.一切都适用于标准页面请求我获取配置文件信息sql一切.
但是,最初似乎没有显示ajax请求.只是让我确认请求已经完成而没有错误.我调试了这个,他们完成了他们也在fiddler中返回http 200响应.
ajax请求附带的迷你探查器没有请求.当我然后导航到另一个页面,即标准页面请求时,现在显示在最后一页上进行的所有ajax请求.
这是我在App_Start中的迷你探查器配置页面
public static class MiniProfilerPackage
{
public static void PreStart()
{
//Setup sql formatter
MiniProfiler.Settings.SqlFormatter = new OracleFormatter();
//Make sure the MiniProfiler handles BeginRequest and EndRequest
DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
//Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter());
//Settings
MiniProfiler.Settings.PopupShowTimeWithChildren = true;
MiniProfiler.Settings.PopupShowTrivial = false;
//Ignore glimpse details in miniprofiler
var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();
ignored.Add("Glimpse.axd");
MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();
}
public static void PostStart()
{
// Intercept ViewEngines to profile all partial views and regular …Run Code Online (Sandbox Code Playgroud) 如何让MiniProfiler分析我的ajax请求
例如:
<div id="nav">
<ul>
<li onclick="javascript:updateContent(1);">foo 1</li>
<li onclick="javascript:updateContent(2);">foo 2</li>
<li onclick="javascript:updateContent(3);">foo 3</li>
</ul>
</div>
<div id="content"></div>
<script type="text/javascript">
function updateContent(productId) {
$.ajax({
url: '@Url.Action("GetProduct", "Product")',
contentType: 'application/html; charset=utf-8',
type: 'GET',
dataType: 'html',
traditional: true,
data: {
productId: productId
}
})
.success(function (result) {
// Display the section contents.
$('#content').html(result);
})
.error(function (xhr, status) {
alert(xhr.responseText);
});
}
</script>
Run Code Online (Sandbox Code Playgroud)
我想看看每个updateContent的性能.
有任何想法吗?
我正在使用通过NuGet安装的Asp.net MVC 3和MiniProfiler 1.9
我通过nuget在我的项目中安装了MiniProfiler和MiniProfiler.EF.
在使用MiniProfiler之前,我会在我的模型库中使用它来打开一个连接:
public class NotificationRepository
{
private CBNotificationModel.CB_NotificationEntities db;
public NotificationRepository()
{
db = new CB_NotificationEntities();
}
public NotificationContact GetNotificationContacts()
{
return db.NotificationContacts.ToList();
}
}
Run Code Online (Sandbox Code Playgroud)
要使用我创建的迷你探查器:
public static class ConnectionHelper
{
public static CB_NotificationEntities GetEntityConnection()
{
var conn = new StackExchange.Profiling.Data.EFProfiledDbConnection(GetConnection(), MiniProfiler.Current);
return ObjectContextUtils.CreateObjectContext<CB_NotificationEntities>(conn); // resides in the MiniProfiler.EF nuget pack
}
public static EntityConnection GetConnection()
{
return new EntityConnection(ConfigurationManager.ConnectionStrings["CB_NotificationEntities"].ConnectionString);
}
}
Run Code Online (Sandbox Code Playgroud)
模型库现在使用
db = ConnectionHelper.GetEntityConnection();
Run Code Online (Sandbox Code Playgroud)
但是这会给出错误:
mscorlib.dll中发生了未处理的"System.StackOverflowException"类型异常
我错过了一步吗?我尝试在Application_start()中添加MiniProfilerEF.Initialize()和MiniProfilerEF.Initialize_EF42(),但这只会更改给定的错误.
设置实体框架项目以使用miniprofiler似乎没有太多信息,除非它是代码优先的.
我们以两种方式使用mini profiler:
几周之后,我们发现写入分析DB需要很长时间(秒),并且在网站上引起实际问题.截断所有分析器表可以解决问题.
通过查看SqlServerStorage代码,看起来插入也会进行检查以确保具有该id的行不存在.这是为了确保数据库不可知代码吗?这似乎会随着行数的增加而引入大量惩罚.
如何从性能分析器中删除性能损失?还有其他人经历过这种减速吗?或者是我们做错了什么?
欢呼任何帮助或建议.
我正在尝试使用Mini Profiler来描述我们的一些Rails控制器,但我想我正在尝试将它用于它不是为它构建的东西.我已经很好地分析了SQL查询,但我需要分解非SQL代码,因为我们在某些页面中看到了很多问题,但SQL似乎不是问题所在.
这是我正在谈论的截图:http://cl.ly/image/2J3i1C1c072O
您可以看到顶级(Executing action: show)需要9136ms才能完成,但执行的查询只是总时间的一小部分.我想我要问的是,是否有办法显示有关正在执行的代码的更多"详细"信息,或者我是否需要找到一个不同的工具来使用.不幸的是,New Relic不是一个选择.
谢谢你的帮助.
所以,在我的Index.cshtml页面中,当我最初加载页面时,我有:
@inherits ViewPage
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="app.ext.js"></script>
<script type="text/javascript" src="dump.js"></script>
@ServiceStack.MiniProfiler.Profiler.RenderIncludes().AsRaw()
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

好的,我可以看到它的分析索引,一堆ExtJS,以及服务器端的第一个ajax调用我的ServiceStack(在/ api/session中).
现在,在我的ExtJS表单中,当我点击它时,我有一个Customers选项卡发送ajax请求,/api/customers当我点击它时,我有一个标签/api/orders.
但是,当我开始点击,比如客户选项卡时,Miniprofiler不再将任何后续的ajax请求添加到列表中?我以为Miniprofiler可以记录ajax请求没什么特别需要做的吗?为什么不为我记录后续的ajax请求?我错过了什么?
我正在使用MiniProfiler用于asp.net web api站点,该站点的帮助页面具有mvc方面.
我试图描述其中一个api方法,这在我的本地机器上是成功的,但是当我部署到我的测试服务器(win2008r2/IIS 7.5)时,我能够浏览到/mini-profiler-resources/results,但页面是空白的,因为我得到了404上includes.js
我一直在审查这里的答案,其中讨论了添加条目<system.webServer><handlers>和/或添加<system.webServer><modules runAllManagedModulesForAllRequests="true"/>,在我的案例中没有一个是成功的.
这是我的global.asax中的相关代码.我不确定是否MiniProfilerHandler.RegisterRoutes()有必要:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
AutofacConfig.Register(GlobalConfiguration.Configuration);
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
FluentValidationConfig.RegisterForWebApi(GlobalConfiguration.Configuration);
MiniProfilerHandler.RegisterRoutes();
MiniProfilerEF6.Initialize();
Database.SetInitializer<OasisIntegrationEntities>(null);
// UseMiniProfilerUi(object) returns true.
MiniProfiler.Settings.Results_Authorize = UseMiniProfilerUi;
MiniProfiler.Settings.Results_List_Authorize = UseMiniProfilerUi;
}
Run Code Online (Sandbox Code Playgroud)
miniprofiler是不是打算在服务器上运行,还是我错过了什么?
asp.net-mvc ×3
profiling ×2
ajax ×1
angular ×1
asp.net ×1
asp.net-core ×1
c# ×1
extjs ×1
glimpse ×1
iis-7.5 ×1
javascript ×1
miniprofiler ×1
servicestack ×1