EntLib 2.0 and performance counters

Topics: Building and extending application blocks
Jun 5, 2007 at 7:26 PM
Hello. I am trying to create and use custom performance counters with the EntLib 2.0. I have the following code in oe of my instrumentation listeners (I'm leaving out the constructors for brevity):

static EnterpriseLibraryPerformanceCounterFactory factory = new EnterpriseLibraryPerformanceCounterFactory();

PerformanceCounter("Authentication Succeeded Events Raised/sec", "AuthenticationSucceededEventRaisedHelpResource", PerformanceCounterType.RateOfCountsPerSecond32)
private EnterpriseLibraryPerformanceCounter authenticationSucceededEventsRaised;

InstrumentationConsumer("AuthenticationSucceeded")
public void AuthenticationSucceededHandler(object sender, AuthenticationExecutionEventArgs e)
{
if (PerformanceCountersEnabled)
{
authenticationSucceededEventsRaised.Increment();
}
}

protected override void CreatePerformanceCounters(string[] instanceNames)
{
authenticationSucceededEventsRaised = factory.CreateCounter(counterCategoryName, "Authentication Succeeded Events Raised/sec", instanceNames);
}

I have a project installer class and have run InstallUtil over my assembly. When I run the code, my performance counters are not created (CreatePerformanceCounters(string[] instanceNames) is never called) and thus I get an error stating the counter does not exist. How can I get this to work?

Regards,

byronfromwes92

Jun 7, 2007 at 11:00 PM
A little help, please?
Aug 23, 2007 at 8:03 AM
Is there a walkthrough in using the Instrumentation block of EntLib or
using performance counters in EntLib??
Can you kindly post the link.
Thanks,

SaintCharlesX
Aug 23, 2007 at 11:01 AM
Just found this site:
http://geekswithblogs.net/akraus1/articles/63134.aspx
:)

Charles
Aug 23, 2007 at 3:07 PM
SaintCharlesX,

That's a good article. If you run into trouble getting it to work, feel free to hit me up. After fighting and fighting, I got it working.

Regards,

byronfromwes92