How to create a 'Custom' performance counter Call Handlre

Apr 20, 2012 at 10:33 AM

 

Hi,

I am using VS 2010 & MS Enterprise Library 5.0; and aware that Performance counter can be set in web.config using EntLib config tool provided.

In this way (for example) we can set the 'MatchingRule' property to 'MemberNameMatchingRule' so that web.config will look as bellow:

<policyInjection>

<policies>

<addname="Performance Counter Policy">

<matchingRules>

<addtype="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.MemberNameMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Member Name Matching Rule">

<matches>

<addmatch="AddProduct" />

</matches>

</add>

</matchingRules>

<handlers>

<addtype="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.PerformanceCounterCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

categoryName="BharatMishraCategory"instanceName="default"name="Performance Counter Call Handler" />

</handlers>

</add>

</policies>

</policyInjection>

Now What I want is to Create a 'Custom' performance counter Call Handlre so that I can monitor the performance of specified method.

Please help me out with C# code example.

Thanks in advance.

Bharat Mishra