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
1=== modified file 'lib/canonical/launchpad/utilities/searchservice.py'
2--- lib/canonical/launchpad/utilities/searchservice.py 2010-08-20 20:31:18 +0000
3+++ lib/canonical/launchpad/utilities/searchservice.py 2010-09-09 21:57:54 +0000
4@@ -20,6 +20,7 @@
5 import urllib
6 from urlparse import urlunparse
7
8+from lazr.restful.utils import get_current_browser_request
9 from lazr.uri import URI
10 from zope.interface import implements
11
12@@ -32,6 +33,7 @@
13 ISearchService,
14 )
15 from canonical.launchpad.webapp import urlparse
16+from lp.services.timeline.requesttimeline import get_request_timeline
17
18
19 class PageMatch:
20@@ -193,8 +195,13 @@
21 """
22 search_url = self.create_search_url(terms, start=start)
23 from canonical.lazr.timeout import urlfetch
24- gsp_xml = urlfetch(search_url)
25-
26+ request = get_current_browser_request()
27+ timeline = get_request_timeline(request)
28+ action = timeline.start("google-search-api", search_url)
29+ try:
30+ gsp_xml = urlfetch(search_url)
31+ finally:
32+ action.finish()
33 page_matches = self._parse_google_search_protocol(gsp_xml)
34 return page_matches
35
36@@ -251,7 +258,6 @@
37 """
38 return self._getElementsByAttributeValue(doc, path, name, value)[0]
39
40-
41 def _parse_google_search_protocol(self, gsp_xml):
42 """Return a `PageMatches` object.
43