Hi,
I have a WCF service in IIS7 that communicates with a winform application over TCP(WAS), now I need to monitor the performance.
I have added this to the web.config file:
<system.serviceModel>
<diagnostics performanceCounters="All" />
After opening the Performance Monitor I run a couple of tests with my winform to make sure that the service is activated.
I then open the Performance Monitor (live), right click and add counters. I expand the ServiceModelService 4.0.0.0 and select Calls and Calls Duration, I also select my service(svc) that is stated in the Instance of selected object listbox and click Add button.
When selecting Calls and Calls Duration under ServiceModelOperation 4.0.0.0 there is however no Instance or operation to select? The same goes for ServiceModelEndpoint 4.0.0.0?
When clicking Ok two counters will be added(ServiceModelService).
I then click unfreeze display and start my winform application that makes a couple of calls, however I do not see anything in the Performance Monitor. I have tried to right-click on one of the performance counters and select "Scale Selected Counter" but this does nothing?
The goal is simply to see how well the WCF service performs (speed, duration, amount, connections and so on) and it would also be great to check individual operations.
Please help!
Note : this is the article I have tried to follow : http://dkochnev.blogspot.com/2011/06/wcf-framework-40-monitoring-service.html
It looks like this might be a bug (or a design-feature) with how performance counters work. After some poking, I've found this on the MSDN forums:
I have the same problem. It appears that Microsoft truncates the tail end of the operation name when naming the counter instance. They replace the truncated part with some sort of 2-digit base-10 magic number. I'm guessing it's a hash, but who knows how it's actually generated. The rub is that this number is not guaranteed unique and can cause collisions in counter names. If such a collision happens, it seems to cause all Endpoint and Operation counters to vanish (at least for me).
I have two methods named UpdateMarkupChunk and UpdateMarkupCancel. If I comment out one or the other so that the other doesn't exist, they both resolve to UpdateMarkupC53 in the counter instance name. When I comment them both in, none of the counter instances appear for ServiceModelEndpoint or ServiceModelOperation.
Can you suggest a workaround for this, Microsoft? I have a production service already in place that I would like to monitor, and changing the operation names is not an option.
And Microsoft responded with:
You are correct. And this behaviour is by design. There is a limit on the length of a performance counter instance's name.
Operation performance counters are found under the ServiceModelOperation 4.0.0.0 performance object when viewing with the Performance Monitor (Perfmon.exe). Each operation has an individual instance. That is, if a given contract has 10 operations, 10 operation counter instances are associated with that contract. The object instances are named using the following pattern:
(ServiceName).(ContractName).(OperationName)@(first endpoint listener address)
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.
So it seems because of this maximum name limitation, the large chances of a hash collision when there's only a two-digit hash suffix, and that when two instances of a counter have the same name, it wipes out the entire counter that it's not actually possible.
Which is more than a little frustrating. So unless Microsoft fixes this problem (either long hash values, or better collision handling by perf counters), or provides a suitable workaround we are working blind.