2 Replies Latest reply on Nov 14, 2013 5:37 AM by Mikhail Tal

    Aborting a custom timer in TM ART at runtime

    Mikhail Tal

      Hi,

       

      Is there a way to not store a custom timer (started via the MeasureStart funtion) in case a certain condition is met? I can see from the response data that sometimes there was an error, and during those cases I want to ignore / not count the response time at all. I tried to do this from several angles, but ultimately didn't accomplish my goal. I did manage to set the response time to "0" for those "error" cases, which is better than nothing I guess. Here's what I did, explained via pseudo code:

       

      Attempt #1

      IF [error not found] THEN MeasureStop

      --> So I only entered the MeasureStop function if the error was verified to not be there. My presumption was that if you never end the timer, it doesn't store it.

      --> Unfortunately I was wrong, it uses the main transaction end time as the end time for the custom timer, so this resulted in completely false data.

       

      Attempt #2

      IF [error found] THEN exit transaction

      --> I split the various custom timers into separate subtransactions TMain, TMain2, TMain3, etc., and exited that transaction via "return 0" if the error was found.

      --> The subtransactions actually appeared as new transactions in the TM ART GUI, which made everything look quite messy. But the biggest problem was that even though I exited the entire transaction before the custom timer ended, it STILL saved the response time. At this point I pretty much gave up, and decided to try a different approach.

       

      Attempt #3

      IF [error found] THEN set custom timer = "0"

      --> I thought I could at least make the "wrong" data differ from the real data, by setting it to be zero. That way I can e.g. search for data straight from the database with the clause "if value > 0".

      --> I used the function MeasureSet and it appeared to work at first. Unfortunately when looking at the results from the GUI, I noticed that it also saves the original measure. So it's not really an act of "replacing" data, it just adds another result under that timer name; so for a single run, it would save e.g. 1.4 seconds and 0 seconds, resulting in Count = 2 and Average = 0.7. This again results in completely false data.

       

      Attempt #4

      Save response time into TEMP timer

      IF [error not found] THEN save TEMP timer into REAL timer ELSE set REAL timer = "0"

      --> This way I only get one "real" timer per each run, and loads of "temp" timers which I can just ignore.

      --> Best one so far, I get a single result for each custom timer, and it's either 0, or in case of no errors, the actual response time.

       

      Of course I would prefer that if the error comes up, the response time wouldn't be saved at all. Is there any way to achieve this?

        • 1. Re: Aborting a custom timer in TM ART at runtime
          Flavio Bonacordi


          Hi,

          You may try the following code:

           

              MeasureSet("My Measure",MEASURE_COUNTER_CUSTOMCOUNTER,0);
              MeasureGet("My Measure",MEASURE_COUNTER_CUSTOMCOUNTER,MEASURE_KIND_LAST,fValue);
          

           

          Where you can set the 0 to any value... So.. you may try create a IF to define the 0 or the current measure... and then create a third measure (My Measure) to store the value...

           

          Try use this into the Attempt #3

           

          And into TMART, configure to only show custom counters.. with that you may achived what you are looking for.

          1 of 1 people found this helpful
          • 2. Re: Aborting a custom timer in TM ART at runtime
            Mikhail Tal

            Thanks Flavio, sometimes the answer is right in front of you, but you just need a good night's sleep to get it Attempt #4 was basically as close as it gets, all I had to change was from this:

            Save response time into TEMP timer

            IF [error not found] THEN save TEMP timer into REAL timer ELSE set REAL timer = "0"

            --> to this:

            Save response time into TEMP timer

            IF [error not found] THEN save TEMP timer into REAL timer

             

            So if I just do nothing when the error comes up, the custom timer isn't created for that monitor run. I have no idea why I didn't think to do this yesterday...

             

            Support suggested to use the "bIgnoreOnError" parameter for MeasureStop, but that requires an availability error to be generated, which I don't want to do.