2

我已经设置了一个带有很多性能计数器(90+)的 diagnostics.wadcfg。但是,它没有反映在 wad-control-container blob 上。我还确保该文件位于BIN文件夹下。

我的 webrole 在 OnStart() 下面有代码片段:

   // Get the diagnostic monitor for the specified role instance.
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = 
         new RoleInstanceDiagnosticManager(myStorageAccount, 
                                           "28281fc7754b44faa9ccf4911983edf1",
                                           "MyWebRole",
                                           "deployment(1).MyAzureProject.WebRole1.0");

// Get the current diagnostic monitor for the role.
DiagnosticMonitorConfiguration currentConfiguration = roleInstanceDiagnosticManager.GetCurrentConfiguration();

// Use 30 seconds for the performance counter sample rate.
TimeSpan perfSampleRate = TimeSpan.FromSeconds(30.0);

// Add a performance counter for processor time to the current configuration.
currentConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
{
      CounterSpecifier = @"\Processor(_Total)\% Processor Time",
      SampleRate = perfSampleRate
});

// Apply the modified configuration to the diagnostic monitor for the role instance.
roleInstanceDiagnosticManager.SetCurrentConfiguration(currentConfiguration);

OnStart() 逻辑是否有可能优先并覆盖我在 diagnostics.wadcfg 上的内容?

我的 diagnostics.wadcfg 文件如下:

<DiagnosticMonitorConfiguration
  xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"
  configurationChangePollInterval="PT1M"
  overallQuotaInMB="8192">

  <PerformanceCounters bufferQuotaInMB="100" scheduledTransferPeriod="PT1M">

    <!-- 1. AZURE_ASP_NET -->
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Application Restarts" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Applications Running" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Request Execution Time" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Current" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Disconnected" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Request Wait Time" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\State Server Sessions Abandoned" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\State Server Sessions Active" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\State Server Sessions Timed Out" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\State Server Sessions Total" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Worker Processes Running" sampleRate="PT30S" />
    <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Worker Process Restarts" sampleRate="PT30S" />

  </PerformanceCounters>

</DiagnosticMonitorConfiguration>

谢谢。

4

1 回答 1

2

如果该部署、角色和实例的 BLOB 存储中的 wad-control-container 中已有文件,它将优先。这样,如果您在系统外部修改该文件,则角色的回收不会丢失设置。

MSDN 文档

“如果 wad-control-container blob 存储容器中已有 XML 配置,则忽略 .wadcfg 文件。”

可以在http://msdn.microsoft.com/en-us/library/windowsazure/dn205146.aspx找到优先顺序。

我的理解是,通过在您的解决方案中包含 wadcfg 文件,诊断子系统会选择该文件并将其用作默认值。如果那里还没有文件,则该文件的副本将放置在 wad-control-container 中。

另一件需要注意的事情是您共享了配置该性能计数器的代码,但是您是否传递了该配置?您可以为处理诊断配置的任何代码行发布更多 OnStart 吗?

于 2013-05-03T11:35:40.090 回答