€cdocutils.nodes document q)q}q(U nametypesq}q(Xrequest_hook_tut.rstqˆX&an introduction to boto's request hookqNXadding your own hookqNXcreating a connectionq NuUsubstitution_defsq }q Uparse_messagesq ]q Ucurrent_sourceqNU decorationqNUautofootnote_startqKUnameidsq}q(hUrequest-hook-tut-rstqhU&an-introduction-to-boto-s-request-hookqhUadding-your-own-hookqh Ucreating-a-connectionquUchildrenq]q(cdocutils.nodes target q)q}q(U rawsourceqX.. _request_hook_tut.rst:UparentqhUsourceqXF/Users/kyleknap/Documents/GitHub/boto/docs/source/request_hook_tut.rstqUtagnameq Utargetq!U attributesq"}q#(Uidsq$]Ubackrefsq%]Udupnamesq&]Uclassesq']Unamesq(]Urefidq)huUlineq*KUdocumentq+hh]ubcdocutils.nodes section q,)q-}q.(hUhhhhUexpect_referenced_by_nameq/}q0hhsh Usectionq1h"}q2(h&]h']h%]h$]q3(hheh(]q4(hheuh*Kh+hUexpect_referenced_by_idq5}q6hhsh]q7(cdocutils.nodes title q8)q9}q:(hX&An Introduction to boto's request hookq;hh-hhh Utitleqcdocutils.nodes Text q?X&An Introduction to boto's request hookq@…qA}qB(hh;hh9ubaubcdocutils.nodes paragraph qC)qD}qE(hXGThis tutorial shows you how to use the request hook for data gathering.qFhh-hhh U paragraphqGh"}qH(h&]h']h%]h$]h(]uh*Kh+hh]qIh?XGThis tutorial shows you how to use the request hook for data gathering.qJ…qK}qL(hhFhhDubaubhC)qM}qN(hXðIt is often important to measure things we do as developers to better understand application performance and the interactions between components of the system. Boto plays a key role in some of those interactions as any client library would.qOhh-hhh hGh"}qP(h&]h']h%]h$]h(]uh*K h+hh]qQh?XðIt is often important to measure things we do as developers to better understand application performance and the interactions between components of the system. Boto plays a key role in some of those interactions as any client library would.qR…qS}qT(hhOhhMubaubhC)qU}qV(hXLWe'll go over how to use the request hook to do some simple request logging.qWhh-hhh hGh"}qX(h&]h']h%]h$]h(]uh*Kh+hh]qYh?XLWe'll go over how to use the request hook to do some simple request logging.qZ…q[}q\(hhWhhUubaubh,)q]}q^(hUhh-hhh h1h"}q_(h&]h']h%]h$]q`hah(]qah auh*Kh+hh]qb(h8)qc}qd(hXCreating a connectionqehh]hhh h>> from boto import ec2 >>> conn = ec2.connect_to_region('us-west-2')hh]hhh U literal_blockquh"}qv(U xml:spaceqwUpreserveqxh$]h%]h&]h']h(]uh*Kh+hh]qyh?XF>>> from boto import ec2 >>> conn = ec2.connect_to_region('us-west-2')qz…q{}q|(hUhhsubaubhC)q}}q~(hX]You will be using this conn object for the remainder of the tutorial to send commands to EC2.qhh]hhh hGh"}q€(h&]h']h%]h$]h(]uh*Kh+hh]qh?X]You will be using this conn object for the remainder of the tutorial to send commands to EC2.q‚…qƒ}q„(hhhh}ubaubeubh,)q…}q†(hUhh-hhh h1h"}q‡(h&]h']h%]h$]qˆhah(]q‰hauh*Kh+hh]qŠ(h8)q‹}qŒ(hXAdding your own hookqhh…hhh hdef handle_request_data(self, request, response, error=False):hh…hhh huh"}qœ(hwhxh$]h%]h&]h']h(]uh*K"h+hh]qh?X>def handle_request_data(self, request, response, error=False):qž…qŸ}q (hUhhšubaubhC)q¡}q¢(hXÊIn boto.requestlog.py, there is an implementation of this interface which is written to handle multiple threads sending data to a single log writing thread. Exammining this file, you'll see a log file, queue and thread are created, then as requests are made, the handle_request_data() method is called. It extracts data from the request and respose object to create a log message. That's inserted into the queue and handled by the _request_log_worker thread.q£hh…hhh hGh"}q¤(h&]h']h%]h$]h(]uh*K$h+hh]q¥h?XÊIn boto.requestlog.py, there is an implementation of this interface which is written to handle multiple threads sending data to a single log writing thread. Exammining this file, you'll see a log file, queue and thread are created, then as requests are made, the handle_request_data() method is called. It extracts data from the request and respose object to create a log message. That's inserted into the queue and handled by the _request_log_worker thread.q¦…q§}q¨(hh£hh¡ubaubhC)q©}qª(hXOne thing to note is that the boto request object has an additional value "start_time", which is a datetime.now() as of the time right before the request was issued. This can be used along with the current time (after the request) to calculate the duration of the request.q«hh…hhh hGh"}q¬(h&]h']h%]h$]h(]uh*K,h+hh]q­h?XOne thing to note is that the boto request object has an additional value "start_time", which is a datetime.now() as of the time right before the request was issued. This can be used along with the current time (after the request) to calculate the duration of the request.q®…q¯}q°(hh«hh©ubaubhC)q±}q²(hX'To add this logger to your connection::q³hh…hhh hGh"}q´(h&]h']h%]h$]h(]uh*K1h+hh]qµh?X&To add this logger to your connection:q¶…q·}q¸(hX&To add this logger to your connection:hh±ubaubhr)q¹}qº(hXX>>> from boto.requestlog import RequestLogger >>> conn.set_request_hook(RequestLogger())hh…hhh huh"}q»(hwhxh$]h%]h&]h']h(]uh*K3h+hh]q¼h?XX>>> from boto.requestlog import RequestLogger >>> conn.set_request_hook(RequestLogger())q½…q¾}q¿(hUhh¹ubaubhC)qÀ}qÁ(hX=That's all you need to do! Now, if you make a request, like::qÂhh…hhh hGh"}qÃ(h&]h']h%]h$]h(]uh*K6h+hh]qÄh?X<That's all you need to do! Now, if you make a request, like:qÅ…qÆ}qÇ(hX<That's all you need to do! Now, if you make a request, like:hhÀubaubhr)qÈ}qÉ(hX>>> conn.get_all_volumes()hh…hhh huh"}qÊ(hwhxh$]h%]h&]h']h(]uh*K8h+hh]qËh?X>>> conn.get_all_volumes()qÌ…qÍ}qÎ(hUhhÈubaubhC)qÏ}qÐ(hX9The log message produced might look something like this::qÑhh…hhh hGh"}qÒ(h&]h']h%]h$]h(]uh*K:h+hh]qÓh?X8The log message produced might look something like this:qÔ…qÕ}qÖ(hX8The log message produced might look something like this:hhÏubaubhr)q×}qØ(hXB'2014-02-26 21:38:27', '200', '0.791542', '592', 'DescribeVolumes'hh…hhh huh"}qÙ(hwhxh$]h%]h&]h']h(]uh*KUhttp://www.python.org/dev/peps/r?Usyntax_highlightr@UlongrAUinput_encoding_error_handlerrBjUauto_id_prefixrCUidrDUdoctitle_xformrE‰Ustrip_elements_with_classesrFNU _config_filesrG]Ufile_insertion_enabledrHˆU raw_enabledrIKU dump_settingsrJNubUsymbol_footnote_startrKKUidsrL}rM(hh-hh…hh-hh]uUsubstitution_namesrN}rOh h+h"}rP(h&]h$]h%]Usourcehh']h(]uU footnotesrQ]rRUrefidsrS}rTh]rUhasub.