none
Problem with performance counter being accessed from multiple processes RRS feed

  • Question

  • Hi, 

    I am having a problem with my custom performance counters when they are being accessed from different processes - what seems to happen is that each process is maintaining it's own version of the performance counter data and is updating it only according to this value. for example I have a counter for the number of active connections being updated by two processes, what happens is:

    Process1: sets it to 1

    Process2: sets it to 10

    Process1: sets it to 2

    Process2: sets it to 11

    What I end up seeing in perfmon is values like 1->10->2->11 

    Looking at the documentation for CreateCounterSetInstance "The provider should keep the counter data up-to-date at all times." 

    This is how I am creating my counters:

        <counterSet guid="{GUID}" name="SQL Stats" description="SQL Stats"
                                instances="multipleAggregate" symbol="symbol" uri="Perf_ServiceSqlStats">
                        <counter id = "1" name = "Counter1" description="Counter 1."
                                 type = "perf_counter_rawcount" detailLevel  = "standard" uri = "Microsoft.TeamFoundation.Framework.Server.Perf_ServiceSqlStats_counter1" />
    </counterSet>

    and in my code:

    CounterSetInstance counterSetInstance = m_counterSet.CreateCounterSetInstance(counterSetInstanceName);
    ...
    counterSetInstance .Counters[counterName].Increment();

    Thanks,
    Riham


    • Moved by Mike FengModerator Thursday, October 25, 2012 9:26 AM (From:Building Development and Diagnostic Tools for .Net)
    Wednesday, October 24, 2012 7:23 PM

All replies

  • Hi Riham,

    Welcome to the MSDN Forum.

    Based on the test result, it seems that the different process didn't monitor the same counter instance object.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, October 25, 2012 9:30 AM
    Moderator
  • Hi Mike, yes, that what I think is the case too, how can I make sure both processes are monitoring the same counter instance? the counter and instance names are the same.

    I tried adding the aggregate attribute as mentioned here  - that still didn't seem to help

    Thursday, October 25, 2012 2:21 PM
  • Hi Riham,

    Welcome to the MSDN Forum.

    I am trying to involve some other one into this case.

    Please wait it patiently.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, November 8, 2012 4:03 PM
    Moderator
  • Hi Riham,

    For the post, we have reviewed the question.   For follow-up, the resolution would require further research and debugging outside of forum support to go over the scenario on why the counters are not updating.  

    Here is the link in case you need to engage further with developer support:

       https://gettechsupport.microsoft.com/Default.aspx?pesid=14694

    Best regards,

    Nathan

    Monday, November 19, 2012 4:18 PM