Re: Gathering stats from messageReceived via MQTT
Joel Lucuik <[email protected]> Tue, 12 Apr 2016 10:40:04 -0400
| Newsgroups | gmane.comp.java.grinder.user |
|---|---|
| Message-ID | <CAA4qVTL0k6V5Hkx1LRydWFKCyAoXbz0o5_+nH71C5nKFBCfT7A@mail.gmail.com> |
--===============2853819574702515743== Content-Type: multipart/alternative; boundary=001a113b10e80dfde505304aa333 --001a113b10e80dfde505304aa333 Content-Type: text/plain; charset=UTF-8 Hi all, A little clarification. We are trying to run a performance test involving MQTT. MQTT does pub/sub. Our test subscribes to receive pubs and launches a separate Thread to receive the callbacks for the messages being published by others. The goal is to count the messages and measure the response times, etc of the receipt of the messages. When we instrument messageArrived (the callback), the messages are not received at all. They are only received when we don't instrument messageArrived. I am thinking of interacting with grinder at a lower level (similar to what the instrumentation would do), within messageArrived. Any suggestions would be great. Joel On Mon, Apr 11, 2016 at 4:36 PM, Joel Lucuik <[email protected]> wrote: > Hi, > > I am using MQTTv3 on a client project. I am trying to measure the grinder > stats for it. Specifically the messageArrived callback. > > I only get stats for messageArrived when it's ***not instrumented***. > > Any advice on how to instrument/gather stats? I put a try block in there > in case there were errors. To no avail. > > Code below: > > Thanks, > Joel > > "=========================================" > def instrumentMethod(test, method_name, c=TestRunner): > """Instrument a method with the given Test.""" > unadorned = getattr(c, method_name) > import new > method = new.instancemethod(test.wrap(unadorned), None, c) > setattr(c, method_name, method) > > > # Replace each method with an instrumented version. > # You can call the unadorned method using self.page1.__target__(). > # Only change these, as they seem to override the statements at the top > # of the script. > instrumentMethod(Test(3100, '%s - MESSAGE_ARRIVED' % testId), > 'messageArrived', TestRunnerCallback) > > > class TestRunnerCallback(MqttCallback): > > """ Constructor """ > def __init__(self): > self.receivedMessages = 0 > info("Callback init" ) > self.connectionLost = False > > def connectionLost(self, cause): > #This method is called when the connection to the server is lost. > info("connectionLost called" ) > > def deliveryComplete(self, token): > #Called when delivery for a message has been completed, and all > acknowledgments have been received. > info("deliveryComplete called") > > def messageArrived(self, topic, message): > try: > #info("User Data is : %s" % message.toString()) > info("Received msg for topic %s " % (topic)) > self.receivedMessages = self.receivedMessages + 1 > except MqttException, err: > raise RuntimeError("Exception caused by: %s" % str(err)) > > "=========================================" > > > > > > --001a113b10e80dfde505304aa333 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div><div><div><div><div><div><div>Hi all,<br><br></div>A = little clarification. We are trying to run a performance test involving MQT= T.<br><br></div>MQTT does pub/sub. Our test subscribes to receive pubs and = launches a separate Thread to receive the callbacks for the messages being = published by others.<br><br></div>The goal is to count the messages and mea= sure the response times, etc of the receipt of the messages.<br><br></div>W= hen we instrument messageArrived (the callback), the messages are not recei= ved at all. They are only received when we don't instrument messageArri= ved.<br><br></div>I am thinking of interacting with grinder at a lower leve= l (similar to what the instrumentation would do), within messageArrived.<br= ><br></div>Any suggestions would be great.<br><br></div>Joel<br><div><div><= div><div><div><div><div><div><div><div><div class=3D"gmail_extra"><br><div = class=3D"gmail_quote">On Mon, Apr 11, 2016 at 4:36 PM, Joel Lucuik <span di= r=3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_blank">jo= [email protected]</a>></span> wrote:<br><blockquote class=3D"gmail_quo= te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204= );padding-left:1ex"><div dir=3D"ltr">Hi,<br><div class=3D"gmail_quote"><div= dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr"><div><div><br></di= v>I am using MQTTv3 on a client project. I am trying to measure the grinder= stats for it. Specifically the messageArrived callback.<br><br></div><div>= I only get stats for messageArrived when it's ***not instrumented***.<b= r><br></div><div>Any advice on how to instrument/gather stats? I put a try = block in there in case there were errors. To no avail.<br><br>Code below:<b= r><br></div><div>Thanks,<br></div><div>Joel<br></div><br><div>"=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"<br>def instrumentMethod(te= st, method_name, c=3DTestRunner):<br>=C2=A0=C2=A0=C2=A0 """I= nstrument a method with the given Test."""<br>=C2=A0=C2=A0= =C2=A0 unadorned =3D getattr(c, method_name)<br>=C2=A0=C2=A0=C2=A0 import n= ew<br>=C2=A0=C2=A0=C2=A0 method =3D new.instancemethod(test.wrap(unadorned)= , None, c)<br>=C2=A0=C2=A0=C2=A0 setattr(c, method_name, method)<br>=C2=A0= =C2=A0=C2=A0 <br><br># Replace each method with an instrumented version.<br= ># You can call the unadorned method using self.page1.__target__().<br># On= ly change these, as they seem to override the statements at the top<br># of= the script.<br>instrumentMethod(Test(3100, '%s - MESSAGE_ARRIVED' = % testId), 'messageArrived', TestRunnerCallback)<br><br><br>class T= estRunnerCallback(MqttCallback):<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2= =A0 """ Constructor """<br>=C2=A0=C2=A0=C2=A0= def __init__(self):<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.rec= eivedMessages =3D 0<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info(&quo= t;Callback init" )<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self.= connectionLost =3D False<br><br>=C2=A0=C2=A0=C2=A0 def connectionLost(self,= cause):<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #This method is call= ed when the connection to the server is lost.<br>=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 info("connectionLost called" )<br>=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 def deliveryComplete(= self, token):=C2=A0 <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #Called = when delivery for a message has been completed, and all acknowledgments hav= e been received.<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info("d= eliveryComplete called")<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= <br>=C2=A0=C2=A0=C2=A0 def messageArrived(self, topic, message):=C2=A0 <br= >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try:<br>=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #info("User Data is : %s= " % message.toString())<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 info("Received msg for topic %s " % (top= ic))<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = self.receivedMessages =3D self.receivedMessages + 1<br>=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 except MqttException, err:<br>=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise RuntimeError("E= xception caused by: %s" % str(err))<br><br>"=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D"<br><br><br></div></div> </div><br></div> <br></div><br></div> </blockquote></div><br></div></div></div></div></div></div></div></div></di= v></div></div></div> --001a113b10e80dfde505304aa333-- --===============2853819574702515743== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z --===============2853819574702515743== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ grinder-use mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/grinder-use --===============2853819574702515743==--