如何在ASP.NET中的页面、业务和数据访问层记录每个方法的执行时间?

发布于 2024-10-04 09:46:17 字数 564 浏览 0 评论 0原文

我有一个复杂的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱要勇敢去追 2024-10-11 09:46:18

您可能需要查看 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文