WCF: performance counter names

The WCF has such structure of the performance counter names:
http://msdn.microsoft.com/en-us/library/ms735098.aspx

   ServiceName@ServiceBaseAddress
  (ServiceName).(ContractName)@(endpoint listener address)
  (ServiceName).(ContractName).(OperationName)@(first endpoint listener address)

In MSDN we have:
"There is a limit on the length of a performance counter instance's name. When a Windows Communication Foundation (WCF) counter instance name exceeds the maximum length, WCF replaces a portion of the instance name with a hash value."  http://msdn.microsoft.com/en-us/library/ms731052.aspx


In my case WCF has generated the names:

  notif28.inoti60.removebyrefer54@82rapper|notificationwrapper.svc
  notif28.inoti60.removebymsgid@82rapper|notificationwrapper.svc
  notif28.inoti60.removebyemailid@82rapper|notificationwrapper.svc
  notif28.inoti60.schedule@82rapper|notificationwrapper.svc

(Sorry for rapper :) Originally it was Wrapper)

The question is:
Can I use these names as hard-coded names or
next time the WCF could generate different names???
BTW Such names with a hash value are disaster if I need to use the performance counters in my code.

Say I'd like to get counters for the operation with name "RemoveByReferenceMessage" name.
How I can find my counters with code if I have names:
notif28.inoti60.removebyrefer54@82rapper|notificationwrapper.svc
notif28.inoti60.removebymsgid@82rapper|notificationwrapper.svc
notif28.inoti60.removebyemailid@82rapper|notificationwrapper.svc
notif28.inoti60.schedule@82rapper|notificationwrapper.svc


???
How many chars of the operation name I have to use for search?
How many chars of the endpoint name I have to use for search?
How many chars of the service name I have to use for search?
One good part of this is that is the hash algorithm always gives us the same names. Al last in my experience.
Now I know only one method to use WCF performance counter names in the custom code:
  1. Start WCF service and get the generated performance counter names from the PerfMon.
  2. Use these names in the code.
Disadvantages: After any change in the ServiceName, ContractName, OperationName, ServiceBaseAddress, EndpointListenerAddress we have to repeat these steps again.


Print | posted on Tuesday, October 14, 2008 10:04 AM

Feedback

# re: WCF: performance counter names

left by Jens Chr. Mikkelsen at 10/14/2008 11:15 AM Gravatar
I got a hint from Dejan Radisic that solved this issue for me. I used reflector to get the disassembly of the the code behind 'OperationPerformanceCounter' & 'EndpointPerformanceCounterss' from System.ServiceModel. The disassembly describes it all.
I can now replicate the hashed names allowing me to query performance counters based on my origional names for the WCF services and Contract.

I have now implemented two static class that can generate the exact instance names.

Send me a e-mail and i will send the code. It all rather simple.

NOTE! If MS developers modifies there code then my version of these methods will fail.

# re: WCF: performance counter names

left by qwe at 12/12/2008 8:20 AM Gravatar
Thanks for the point to "workaround"!

# re: WCF: performance counter names

left by Alex at 2/23/2009 1:54 PM Gravatar
Afaik you can get the instance name through WMI. Read something about that sometime on msdn.
Post A Comment
Title:
Name:
Email:
Comment:
Verification: