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
=== modified file 'lib/lp/services/timeline/tests/test_timedaction.py'
--- lib/lp/services/timeline/tests/test_timedaction.py 2010-09-05 05:07:57 +0000
+++ lib/lp/services/timeline/tests/test_timedaction.py 2010-09-06 22:41:10 +0000
@@ -55,9 +55,10 @@
55 action = TimedAction("foo", "bar", timeline)55 action = TimedAction("foo", "bar", timeline)
56 # Set variable for deterministic results56 # Set variable for deterministic results
57 action.start = timeline.baseline + datetime.timedelta(0, 0, 0, 2)57 action.start = timeline.baseline + datetime.timedelta(0, 0, 0, 2)
58 action._interval_to_now = lambda: datetime.timedelta(0, 0, 0, 3)
58 log_tuple = action.logTuple()59 log_tuple = action.logTuple()
59 self.assertEqual(4, len(log_tuple), "!= 4 elements %s" % (log_tuple,))60 self.assertEqual(4, len(log_tuple), "!= 4 elements %s" % (log_tuple,))
60 self.assertAlmostEqual(2, log_tuple[0])61 self.assertAlmostEqual(2, log_tuple[0])
61 self.assertAlmostEqual(1000001, log_tuple[1])62 self.assertAlmostEqual(5, log_tuple[1])
62 self.assertEqual("foo", log_tuple[2])63 self.assertEqual("foo", log_tuple[2])
63 self.assertEqual("bar", log_tuple[3])64 self.assertEqual("bar", log_tuple[3])
6465
=== modified file 'lib/lp/services/timeline/timedaction.py'
--- lib/lp/services/timeline/timedaction.py 2010-09-05 05:07:57 +0000
+++ lib/lp/services/timeline/timedaction.py 2010-09-06 22:41:10 +0000
@@ -47,14 +47,14 @@
47 """Return a 4-tuple suitable for errorlog's use."""47 """Return a 4-tuple suitable for errorlog's use."""
48 offset = self._td_to_ms(self.start - self.timeline.baseline)48 offset = self._td_to_ms(self.start - self.timeline.baseline)
49 if self.duration is None:49 if self.duration is None:
50 # This action wasn't finished: give it a duration that will stand50 # This action wasn't finished: pretend it has finished now
51 # out. This is pretty normal when action ends are recorded by51 # (even though it hasn't). This is pretty normal when action ends
52 # callbacks rather than stack-like structures. E.g. storm 52 # are recorded by callbacks rather than stack-like structures. E.g.
53 # tracers in launchpad:53 # storm tracers in launchpad:
54 # log-trace START : starts action54 # log-trace START : starts action
55 # timeout-trace START : raises 55 # timeout-trace START : raises
56 # log-trace FINISH is never called.56 # log-trace FINISH is never called.
57 length = 99999957 length = self._td_to_ms(self._interval_to_now())
58 else:58 else:
59 length = self._td_to_ms(self.duration)59 length = self._td_to_ms(self.duration)
60 return (offset, offset + length, self.category, self.detail)60 return (offset, offset + length, self.category, self.detail)
@@ -66,4 +66,7 @@
6666
67 def finish(self):67 def finish(self):
68 """Mark the TimedAction as finished."""68 """Mark the TimedAction as finished."""
69 self.duration = datetime.datetime.now(UTC) - self.start69 self.duration = self._interval_to_now()
70
71 def _interval_to_now(self):
72 return datetime.datetime.now(UTC) - self.start