Merge lp:~lifeless/launchpad/oops into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11523
Proposed branch: lp:~lifeless/launchpad/oops
Merge into: lp:launchpad
Diff against target: 42 lines (+9/-3)
1 file modified
lib/canonical/launchpad/utilities/searchservice.py (+9/-3)
To merge this branch: bzr merge lp:~lifeless/launchpad/oops
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+35044@code.launchpad.net

Commit message

Gather time spend in google searches into the request timeline.

Description of the change

Gather time spend in google searches into the request timeline.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

The linked bugs seem strange...

But this change looks fine.

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

The bugs are all fixed released and not relevant to this mp.... I can file a code bug if you like but I think its a dupe.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/utilities/searchservice.py'
--- lib/canonical/launchpad/utilities/searchservice.py 2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/utilities/searchservice.py 2010-09-09 21:57:54 +0000
@@ -20,6 +20,7 @@
20import urllib20import urllib
21from urlparse import urlunparse21from urlparse import urlunparse
2222
23from lazr.restful.utils import get_current_browser_request
23from lazr.uri import URI24from lazr.uri import URI
24from zope.interface import implements25from zope.interface import implements
2526
@@ -32,6 +33,7 @@
32 ISearchService,33 ISearchService,
33 )34 )
34from canonical.launchpad.webapp import urlparse35from canonical.launchpad.webapp import urlparse
36from lp.services.timeline.requesttimeline import get_request_timeline
3537
3638
37class PageMatch:39class PageMatch:
@@ -193,8 +195,13 @@
193 """195 """
194 search_url = self.create_search_url(terms, start=start)196 search_url = self.create_search_url(terms, start=start)
195 from canonical.lazr.timeout import urlfetch197 from canonical.lazr.timeout import urlfetch
196 gsp_xml = urlfetch(search_url)198 request = get_current_browser_request()
197199 timeline = get_request_timeline(request)
200 action = timeline.start("google-search-api", search_url)
201 try:
202 gsp_xml = urlfetch(search_url)
203 finally:
204 action.finish()
198 page_matches = self._parse_google_search_protocol(gsp_xml)205 page_matches = self._parse_google_search_protocol(gsp_xml)
199 return page_matches206 return page_matches
200207
@@ -251,7 +258,6 @@
251 """258 """
252 return self._getElementsByAttributeValue(doc, path, name, value)[0]259 return self._getElementsByAttributeValue(doc, path, name, value)[0]
253260
254
255 def _parse_google_search_protocol(self, gsp_xml):261 def _parse_google_search_protocol(self, gsp_xml):
256 """Return a `PageMatches` object.262 """Return a `PageMatches` object.
257263