Performance Counters installation issue

Topics: Enterprise Library Core, General discussion, Logging Application Block, Policy Injection Application Block
May 18, 2007 at 12:24 AM
I am using windows 2003 and running under an administrator user. I have run "Install Instrumentation".

In perfmon I have the enterprise library counters added as perfomance objects with a complete list but without any instances added.

I do not see any activity logged to these counters for running applicaitons using the library. The configuration I am using looks like:
<configSections>
<section name="policyInjection" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<policyInjection>
<policies>
<add name="Policy">
<handlers>
<add categoryName="APS"
instanceName="ServiceFramework"
useTotalCounter="true"
incrementNumberOfCalls="true"
incrementCallsPerSecond="true"
incrementAverageCallDuration="true"
incrementTotalExceptions="false"
incrementExceptionsPerSecond="false"
type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.PerformanceCounterCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Performance Counters Handler" />
</handlers>
</add>
</policies>
</policyInjection>
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true"
defaultCategory="General"
logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="trace.log" header="----------------------------------------"
footer="----------------------------------------" formatter=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="FlatFile TraceListener" />
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="ANYA" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

I have added a new category and events using the code example in the documentation. Interesting, again no instances are created.

Any ideas? Any tips on where to look?
May 20, 2007 at 12:56 AM
Assuming you've installed the performance counters used by the PIAB perf counter handler as described in the docs (either through code or by doing: installutil /category:<category name> Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.dll) then the instances should be created automatically the first time the handler gets updated.

The problem is in your configuration. You've configured the handler, but I don't see any matching rules saying which methods the policy applies to. Without that, the handler will never be added, and no updates of the performance counters. Try configuring a matching rule and see what happens.
May 20, 2007 at 8:11 PM
I now believe the issue I am experiencing is not directly related of the enterprise library. Note: I am using Virtual PC 2007, Windows 2003 (all patches applied).

I can create and use a single instance performance counter without issue...sort of - will explain later.

I am not able to get a multiple instance performance counter to work. Ther performance counter is added but <No Instances> are shown so I am not able ot select the performance counter to monitor. The code below that adds an instance runs without throwing an error.

The code:
if (!PerformanceCounterCategory.Exists("JUNK"))
{
CounterCreationData ccd = new CounterCreationData("numberOf", "numbers", PerformanceCounterType.NumberOfItems32);
CounterCreationDataCollection ccdc = new CounterCreationDataCollection(new CounterCreationData[] { ccd });

PerformanceCounterCategory cat = PerformanceCounterCategory.Create("JUNK", "junk category", PerformanceCounterCategoryType.MultiInstance, ccdc);

using (PerformanceCounter c = new PerformanceCounter("JUNK", "numberOf", "instance1", false))
{
c.RawValue = 10;
}
}

using (PerformanceCounter c1 = new PerformanceCounter("JUNK", "numberOf", "instance1", false))
{
for (int i = 0; i < 10; i++)
c1.Increment();
}

A single instance performance counter works but not as expected (the above code, but category marked as single instance and the instance not being specified when creating the counter). The counter is added and I can view in perfmon, but it is not until I have the counter added to perfmon that the incrementing is persisted (re. shows in perfmon). When running in the debugger, the instance is created and incremented without exceptions being thrown; but nothing is shown in perfmon.

Any ideas?
Mar 19, 2009 at 1:22 AM
I am having this exact same problem. The only time that instance names ever show up is when I use the debugger and watch everything get initialized.

I did some checking though, and even when the isntance names don't show up in perfmon (outside of the debugger), the Performance Counter object still has those instances added to it.
Mar 19, 2009 at 9:09 AM
What version of entlib is this?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Mar 19, 2009 at 11:42 AM
This is enterprise library 4.1 being developed on Windows XP under the 3.5 Framework.
Mar 20, 2009 at 2:44 AM
This kinda weird, anyway, as i've understand your situation, when you try to add counters in the perfmon, you never see the instance of your running application? I only repro this behavior when i dont add a instrumentation(and setting the performanceCountersEnabled to true) in the config of my app. verify that you have the intrumentation in your config.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com