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

Proposed by Robert Collins
Status: Merged
Merged at revision: 11514
Proposed branch: lp:~lifeless/launchpad/oops
Merge into: lp:launchpad
Diff against target: 48 lines (+11/-7)
2 files modified
lib/lp/services/timeline/tests/test_timedaction.py (+2/-1)
lib/lp/services/timeline/timedaction.py (+9/-6)
To merge this branch: bzr merge lp:~lifeless/launchpad/oops
Reviewer Review Type Date Requested Status
Tim Penhey (community) release-critical Approve
Review via email: mp+34709@code.launchpad.net

Commit message

In TimedAction.logTuple use the time since start for the duration of incomplete actions.

Description of the change

The use of a large sentinel confuses oops-tools, instead use the time since the action started to report on incomplete actions.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/timeline/tests/test_timedaction.py'
2--- lib/lp/services/timeline/tests/test_timedaction.py 2010-09-05 05:07:57 +0000
3+++ lib/lp/services/timeline/tests/test_timedaction.py 2010-09-06 22:41:10 +0000
4@@ -55,9 +55,10 @@
5 action = TimedAction("foo", "bar", timeline)
6 # Set variable for deterministic results
7 action.start = timeline.baseline + datetime.timedelta(0, 0, 0, 2)
8+ action._interval_to_now = lambda: datetime.timedelta(0, 0, 0, 3)
9 log_tuple = action.logTuple()
10 self.assertEqual(4, len(log_tuple), "!= 4 elements %s" % (log_tuple,))
11 self.assertAlmostEqual(2, log_tuple[0])
12- self.assertAlmostEqual(1000001, log_tuple[1])
13+ self.assertAlmostEqual(5, log_tuple[1])
14 self.assertEqual("foo", log_tuple[2])
15 self.assertEqual("bar", log_tuple[3])
16
17=== modified file 'lib/lp/services/timeline/timedaction.py'
18--- lib/lp/services/timeline/timedaction.py 2010-09-05 05:07:57 +0000
19+++ lib/lp/services/timeline/timedaction.py 2010-09-06 22:41:10 +0000
20@@ -47,14 +47,14 @@
21 """Return a 4-tuple suitable for errorlog's use."""
22 offset = self._td_to_ms(self.start - self.timeline.baseline)
23 if self.duration is None:
24- # This action wasn't finished: give it a duration that will stand
25- # out. This is pretty normal when action ends are recorded by
26- # callbacks rather than stack-like structures. E.g. storm
27- # tracers in launchpad:
28+ # This action wasn't finished: pretend it has finished now
29+ # (even though it hasn't). This is pretty normal when action ends
30+ # are recorded by callbacks rather than stack-like structures. E.g.
31+ # storm tracers in launchpad:
32 # log-trace START : starts action
33 # timeout-trace START : raises
34 # log-trace FINISH is never called.
35- length = 999999
36+ length = self._td_to_ms(self._interval_to_now())
37 else:
38 length = self._td_to_ms(self.duration)
39 return (offset, offset + length, self.category, self.detail)
40@@ -66,4 +66,7 @@
41
42 def finish(self):
43 """Mark the TimedAction as finished."""
44- self.duration = datetime.datetime.now(UTC) - self.start
45+ self.duration = self._interval_to_now()
46+
47+ def _interval_to_now(self):
48+ return datetime.datetime.now(UTC) - self.start