将ETW事件发送到Application Insights?

时间:2017-01-27 12:08:13

标签: azure-webjobs azure-application-insights etw

我在Azure WebJob(.exe)中托管了一些遗留代码,这些遗留代码会生成大量ETW事件以便记录到自定义事件提供程序。

如何以简单的方式将这些ETW事件传递给Application Insights?我希望它们出现在与托管WebJob的网站相同的AI实例中。

1 个答案:

答案 0 :(得分:2)

以下是事件源跟踪模块的简单示例。 https://github.com/AlexBulankou/ai-samples/blob/master/ETWTrackingModule.cs

模块包装订阅已配置事件源的ETW侦听器。您可以指定要订阅的事件源以及是否希望ETW事件被跟踪事件和/或作为跟踪。在ApplicationInsights.config中,按如下方式注册此模块:

 <Add Type="Microsoft.ApplicationInsights.Samples.ETWTrackingModule, YourAssemblyName">
  <TrackEvent>True</TrackEvent>
  <TrackTrace>True</TrackTrace>
  <EventSources>
    <Add Name="System.Collections.Concurrent.ConcurrentCollectionsEventSource" EventLevel="LogAlways"/>
    <Add Name="System.Diagnostics.Eventing.FrameworkEventSource" EventLevel="LogAlways"/>
  </EventSources>
</Add>