进程连接到另一个进程以收集配置文件信息?
.Net 中是否有任何内置机制允许我们编写两个程序 A 和 B。A 是一个带有特殊钩子的进程,B 将其自身附加到该钩子上。 这将允许 B 收集这些钩子提供的任何信息。
特别是,如果能够拨入我们的另一个进程并收集此类指标,例如在过去 X 分钟内调用函数的次数、平均运行长度、这个或那个缓存中有多少项,那就太好了。 ETC。
Are there any built-in mechanisms in .Net that would allow us to write two programs, A and B. A is a process with special hooks onto which B attaches itself. This would allow B to gather whatever information those hooks provided.
In particular, it would be nice to be able to dial into another of our process and gather suchs metrics like how many times a function was called in the last X minutes, the average run length, how many items are in this or that cache, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用.NET Profiling API 编写应用程序。 或者,您可以使用日志记录,由运行时选项、配置文件或注册表设置控制日志的详细程度。 或者您可以为现有的商业分析解决方案支付大量资金。
您还可以使用 MSMQ 而不是记录。
You could write an application with the .NET Profiling API. Or, you could use logging, controlled by runtime options, config files, or registry settings for how verbose your logs will be. Or you could pay a lot of money for existing commercial profiling solutions.
You could also use MSMQ instead of logging.
这取决于你想做什么。 您描述的许多指标都可以使用调试器中的探查器捕获(因此您根本不需要编写程序 B,或以任何方式更改程序 A)。
或者,您可以实现一个消息传递接口(例如使用套接字),该接口允许程序 B 向程序 A 请求信息。程序 A 可以提供一个后台线程来提供此信息,以便无论何时发出请求,无论它还做什么其他工作,它都可以应答。可能会从事。
It depends what you want to do. A lot of the metrics you describe can be captured with a profiler from within your debugger (so you wouldn't need to write program B at all, or change program A in any way).
Or you could implement a messaging interface (e.g. using sockets) that allows program B to request information from program A. Program A could supply a background thread to provide this information so that it can answer whenever a request is made regardless of what other work it might be engaged in.