Page MenuHomeSoftware Heritage

statsd: make TimedContextManagerDecorator report errors
ClosedPublic

Authored by douardda on Mar 27 2019, 10:51 AM.

Details

Summary

using an incremented counter, instead of pushing an inacurrate timing
data (if calling the encapsulated function raises an exception).

Depends on D1296

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

olasd requested changes to this revision.Mar 27 2019, 11:37 AM
olasd added a subscriber: olasd.

No tests for the error behavior? Sad :(

This revision now requires changes to proceed.Mar 27 2019, 11:37 AM
vlorentz added inline comments.
swh/core/statsd.py
100–106

You can drop the start = None and replace

finally:
    if start is not None:
        self._send(start)

by:

else:
    self._send(start)

(same comment for the block below)

swh/core/statsd.py
100–106

gheez, you are damn right!

swh/core/statsd.py
100–106

In fact no, at least not exactly, because of the return statement in the try block.

swh/core/statsd.py
100–106

Oops indeed. The return could be at the end of the function, though.

Add tests and follow vlorentz' advice

This revision is now accepted and ready to land.Mar 28 2019, 11:15 AM
This revision was automatically updated to reflect the committed changes.