我在Windows Azure中运行自定义性能计数器时遇到了严重问题。我正在通过* .cscfg文件中的配置更改动态地在PostSharp的帮助下实现的方面创建性能计数器。性能计数器是在模拟器中以及Azure环境中正确创建的(通过远程桌面检查),因为我可以在性能工具 - >下的计算机管理控制台中看到性能计数器实例。监控工具 - >性能监视器。我在 diagnostics.wadcfg。
中添加了性能计数器<?xml version="1.0" encoding="utf-8"?>
<DiagnosticMonitorConfiguration configurationChangePollInterval="PT1M" overallQuotaInMB="4096" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs />
<Directories>
<IISLogs container="wad-iis-logfiles" />
<CrashDumps container="wad-crash-dumps" />
</Directories>
<Logs bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
<PerformanceCounters bufferQuotaInMB="250" scheduledTransferPeriod="PT1M">
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT1S" />
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1S" />
<PerformanceCounterConfiguration counterSpecifier="\_Customer Category\average execution time for member call" sampleRate="PT1S" />
</PerformanceCounters>
<WindowsEventLog bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error">
<DataSource name="Application!*" />
</WindowsEventLog>
</DiagnosticMonitorConfiguration>
问题是我从未在 WADPerformanceCountersTable 中看到性能计数器值。如果我启动模拟器,我会看到此错误:
[MonAgentHost] Error: MA EVENT: 2013-09-05T15:30:49.373Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 8360
[MonAgentHost] Error: 12556
[MonAgentHost] Error: SysCounterListener.dll
[MonAgentHost] Error: 0
[MonAgentHost] Error: 5fd713ae-0085-4ba3-87f6-e21ad86
[MonAgentHost] Error: liscounter.cpp
[MonAgentHost] Error: SystemCounter::AddCounter
[MonAgentHost] Error: 660
[MonAgentHost] Error: ffffffffc0000bb8
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: PdhAddCounter(\_Customer Category\average execution time for member call) failed
创建类别的代码见下文(_categoryName =“_自定义类别”和_counterName =“成员调用的平均执行时间”)
private void CreateCategory()
{
if (!PerformanceCounterCategory.Exists(_categoryName))
{
Trace.TraceInformation("Creating new category '{0}'", _categoryName);
_counters = new CounterCreationDataCollection
{
new CounterCreationData(_counterName, _performanceCounterHelperText, PerformanceCounterType.AverageTimer32),
new CounterCreationData(_averageBasePerformanceCounterName, string.Empty, PerformanceCounterType.AverageBase)
};
PerformanceCounterCategory.Create(_categoryName, string.Empty, PerformanceCounterCategoryType.MultiInstance, _counters);
}
}
private void CreateOrGetPerformanceCounters()
{
string averageBasePerformanceCounterName = string.Format("{0} {1}", _counterName, "base");
Trace.TraceInformation("Get new instance '{0}' of counter '{1}' in the category '{2}'", _instanceName, _counterName, _categoryName);
_performanceCounterAverage = new PerformanceCounter(
_categoryName, _counterName, _instanceName, false);
_performanceCounterAverageBase = new PerformanceCounter(
_categoryName, averageBasePerformanceCounterName, _instanceName, false);
}
接下来的问题是,如何获得性能计数器的具体实例?在管理控制台中,我可以选择应该显示哪个实例,如何在Azure中执行此操作?
答案 0 :(得分:1)
有两个错误
_Custom Category
,我写了CustomER Category
\[Category Name]([Instance Name]|*)\[Performance Counter Name]
,所以在我的情况下是\_Custom Category(*)\average execution time for member call
。在这种情况下,asterix丢失了!