How to change the IPerformanceCounterNameFormatter

Topics: Caching Application Block , Enterprise Library Core
Feb 4, 2007 at 1:32 PM
How do I change the IPerformanceCounterNameFormatter without recompiling the code? I want to change from the AppDomainNameFormatter to my own formatter without recompiling the code for the caching block.
Feb 4, 2007 at 6:23 PM
I am assuming you mean the formatter in the context for instrumentation? You can always initialize CachingInstrumentationListener passing in your own name formatter. Have a look at the documentation or sources for CachingInstrumentationListener.

Feb 4, 2007 at 9:30 PM
As usual there is no documentation for the class or how to use it!

Looking at the source this class is an internal class so how would you initialize it without recompiling code? Is there any other way to initialize the listner with my own IPerformanceCounterNameFormatter without changing the source code for the caching block. I think this should have been a setting in the config file.

Feb 5, 2007 at 5:54 PM
Hi Hakan -

This functionality hasn't been exposed as an extensibility point, at least not one you can hook into without changing code. However it shouldn't be too hard to hook into if you can stomach a recomile.


Feb 5, 2007 at 9:04 PM
Hi Tom,
The problem is that the performance counters are not accessable for web applications in Perfmon for Windows 2000. The problem seams to be the / in the app name. Making the IPerformanceCounterNameFormatter configrable or in some other way changeable would fix this problem.

Mar 2, 2007 at 7:08 AM
Wow. Thanks a lot for finding this. It's been driving me nuts for the past few days. It's not just a w2k problem as I can't see them in XP perfmon either. I was trying to write instrumentation code for my own stuff and just couldn't see the activity in perfmon. Thought something was wrong with my code and went over it again and again and all the plumbing seemed to be there.. Finally I decided to inspect the Entlib (2.0) Logging instrumentations and it was the same. Per your advice, I just stripped out the '/' for my stuff and perfmon is running again.

Looks like the default impl for EntLib is using AppDomain.FriendlyName which is /lm/w3svc/2/root/... in my world. A quick scan looks as though you can setup your own AppDomain for your app if you didn't want to recompile EntLib, though admittedly I haven't played with this approach all that much.

Thanks again Hakan!