launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #07737
Re: Trying to add storm tracing to scripts
On 12 August 2011 16:09, Julian Edwards <julian.edwards@xxxxxxxxxxxxx> wrote:
> Dear hackers
>
> I need to add storm statement tracing to one of the scripts we've developed
> for Derived Distros so I can see if there's a performance improvement to be
> made. I figured it would be a simple case of adding these three lines to the
> script (as advised by Rob):
>
> from canonical.launchpad.webapp.adapter import LaunchpadStatementTracer
> from storm.tracer import install_tracer
> install_tracer(LaunchpadStatementTracer())
This tracer is installed by the act of importing its module, so the
install_tracer() call is a no-op.
Next, you'll need to use set_request_started() before
LaunchpadStatementTracer will start recording, then you'll need to
trigger an oops before calling clear_request_started() at the end of
the interesting bit (or just letting the script end). At least, this
is how checkwatches does it... which may or may not be a good
recommendation ;)
See the WorkingBase class in lib/lp/bugs/scripts/checkwatches/base.py
for some convenience stuff that should be easy to borrow.
Gavin.
Follow ups
References