Microsoft.Diagnostics 中的 PerformanceCounter 与 Microsoft.Diagnostics.EventFlow

PerformanceCounter in Microsoft.Diagnostics vs Microsoft.Diagnostics.EventFlow

我打算在我的一个项目中使用 PerformanceCounter。我只知道 Microsoft Azure 官方项目下的 Microsoft.Diagnostics. However I stumbled upon a rather newer library Microsoft.Diagnostics.EventFlow,似乎提供了类似的功能。

我不熟悉 Azure 服务及其库,如果这两个库完全正交,我深表歉意。

EventFlow 库使用 Microsoft.Diagnostics 命名空间中的性能计数器,可以看出 here。它本身不提供任何性能计数器。

EventFlow 库允许您捕获特定性能计数器的数据并将该数据输出到支持的输出之一。它不是为了直接读取数据而设计的,而是将其路由到另一个目的地,如介绍中所述的应用程序洞察:

The EventFlow library suite allows applications to define what diagnostics data to collect, and where they should be outputted to

因此,总结:要直接读取性能计数器的值,请使用 Microsoft.Diagnostics 命名空间中的 类。要在其他地方记录值,请使用 EventFlow 库。