Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit log timer values should accumulate not overwrite #1435

Open
lrowe opened this issue Aug 5, 2017 · 2 comments
Open

Audit log timer values should accumulate not overwrite #1435

lrowe opened this issue Aug 5, 2017 · 2 comments

Comments

@lrowe
Copy link
Contributor

lrowe commented Aug 5, 2017

Bug Report

Restify Version

5.x

Node.js Version

6.x

Expected behaviour

Audit log timers should accumulate their value when startHandlerTimer/endHandlerTimer is called more than once for the same timer name.

Actual behaviour

Audit log timer is overwritten.

Repro case

See test in #1443.

Cause

var timers = {};
(req.timers || []).forEach(function (time) {
var t = time.time;
var _t = Math.floor((1000000 * t[0]) + (t[1] / 1000));
timers[time.name] = _t;
});

Are you willing and able to fix this?

Yes.

@retrohacker retrohacker added the Bug label Aug 7, 2017
@retrohacker
Copy link
Member

Hey @lrowe,

Could you give some context around why the proposed behavior is desirable? I don't know much about how audit log timers are used.

@lrowe
Copy link
Contributor Author

lrowe commented Aug 8, 2017

@retrohacker I'm using handler timers to provide insight into where time is spent within my endpoint handler (since almost all the cpu time is spent in the endpoint handler rather than middleware.)

Let's say I have an expensive function, 'collapse' and I call req.startHandlerTimer("collapse") / req.endHandlerTimer("collapse") around its invocation to record the time spent within a request. I collapse gets called multiple times in a single request its audit timer no longer shows what proportion of the request was spent executing collapse, only the duration of the final execution.

Ideally each individual time might be logged to an array, though that would involve downstream logging changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants