vector icon indicating copy to clipboard operation
vector copied to clipboard

[DNM] Add logOperationTime util with implementation in protocol module

Open jakekidd opened this issue 4 years ago • 4 comments

The Problem

  • We need accurate logging to document time it's taking for methods to execute, starting with protocol module

The Solution

  • Implemented logOperationTime, a util method
  • Used at start and completion of a method to log start and time it took to execute, respectively
  • Used performance(.mark()) as opposed to Date.now() for accuracy

jakekidd avatar Feb 24 '21 22:02 jakekidd

We should make this time logging part of the "debug" log config. IMO it should be in the code and be able to be enabled with a "switch flip" of sorts.

rhlsthrm avatar Feb 25 '21 09:02 rhlsthrm

We should make this time logging part of the "debug" log config. IMO it should be in the code and be able to be enabled with a "switch flip" of sorts.

Can you clarify what you mean by "debug" log config? Is there a configuration somewhere I should be aware of? The way it is currently, unless the method takes an inordinate amount of time to execute, it will always log it on debug level. Takes too long and it logs it as info, then warning

jakekidd avatar Feb 25 '21 20:02 jakekidd

Can you clarify what you mean by "debug" log config? Is there a configuration somewhere I should be aware of? The way it is currently, unless the method takes an inordinate amount of time to execute, it will always log it on debug level. Takes too long and it logs it as info, then warning

https://docs.connext.network/configuring-a-router here's the config.

Your implementation sounds good. The main thing I was trying to get at is we should have the ability to turn this on/off in the config. So as part of this PR I think we should add a config item called enableTimestampLogging or something which can turn the whole thing on/off.

rhlsthrm avatar Feb 25 '21 20:02 rhlsthrm

https://docs.connext.network/configuring-a-router

Ah, I misread your first comment. I thought you said it should NOT be able to be enabled by switch flip of sorts , haha.

Yes, agreed. I will target that functionality for this PR, thanks. (Meaning I will include addition of this config item)

EDIT: I'm going to go out on a limb and assume the responsibility to 'check' the switch should be relegated to the method itself (meaning I'll check the enableTimestampLogging config setting within the logOperationTime method)

jakekidd avatar Feb 25 '21 20:02 jakekidd