如何在ASP.NET中的页面、业务和数据访问层记录每个方法的执行时间?
我有一个复杂的 ASP.NET 应用程序,它自 2009 年以来一直运行。 我需要监视它的性能并确定哪些层中的哪些方法消耗时间或资源。然后我可以优化方法。
现在,我正在使用 SQL Profiler 检查查询并逐步调整数据库。我想对其他层(UI、服务和存储库)执行相同的操作。
我使用了 Postsharp 和企业库策略注入应用程序块。
我已经实现了一些属性并将它们添加到一些类中,这有助于我自动获取 BeforeMethodEntry 和 AfterMethodEntry (AOP 模型)。因此,我可以获得每个方法的执行时间。它还处理异常日志和页面视图日志。
但是,我认为可能还有另一种实现/标准的解决方案来监视正在运行的应用程序。
PS:我已经实现了一些其他解决方案,例如实现 ExceptionHttpModule 和 PageViewHttpModule ,它们不需要任何第三方库。它不符合我的要求。
*简单地说,我想记录和监视层的活动(特别是方法执行持续时间)。 *
I have a complex ASP.NET application and it's running since 2009.
I need to monitor it's performance and determine which methods in which layers are time or resource consuming. Then I can optimize methods.
Right now, I'm using SQL Profiler to check the queries and I tune the database step by step. I want to do the same for other layers (UI, Service, and Repository).
I've used Postsharp and Enterprise Library Policy Injection Application Block.
I've implemented some attributes and add them to some classes which helps me to get BeforeMethodEntry and AfterMethodEntry (AOP model) automatically. Therefore, I can get the execution time of each method. It also handles exception log and page view log.
But, I think there may be another implemented/standard solution to monitor the running application.
PS: I've implemented some other solution like implementing ExceptionHttpModule and PageViewHttpModule which don't need any Third Party libraries. It doesn't meet my requirements.
*In a simple words, I want to log and monitor layer's activities (specially mehod execution duration). *
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要查看 Spring.Net Aop。如果您使用AroundAdvice,您将能够在方法执行之前启动StopWatch,并在方法完成后立即停止。有一种方法可以像使用 PostSharp 一样使用它(即使用属性)。
You may want to look into Spring.Net Aop. If you an AroundAdvice, you will be able to start a StopWatch before the execution of the method, and stopping right after it finishes. There is a way to use it as you would with PostSharp (i.e. using attributes).