thor icon indicating copy to clipboard operation
thor copied to clipboard

Adding api-logs-enabled flag

Open otherview opened this issue 9 months ago • 6 comments

Description

Part of the Replay feature functionality - Ticket https://github.com/vechain/protocol-board-repo/issues/183 This flag adds the ability to log incoming requests to disk. Logs are written to the instanceDir and the default is a maximum of 10 files of 10 MBs each. It defaults to NOT ENABLED. Can be enabled in thor solo to display logs into the stdout.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added unit tests.

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes
  • [x] New and existing E2E tests pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules
  • [x] I have not added any vulnerable dependencies to my code

otherview avatar May 09 '24 15:05 otherview

@otherview does this persist all requests indefinitely ? Maybe we should have a daily cleanup action that clears log files older than X time? Or once it's using more the Y GB of storage

darrenvechain avatar May 09 '24 16:05 darrenvechain

Codecov Report

Attention: Patch coverage is 51.72414% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 61.78%. Comparing base (aedfc6b) to head (b1434a0).

Files Patch % Lines
cmd/thor/main.go 0.00% 8 Missing :warning:
api/api.go 0.00% 3 Missing :warning:
api/request_logger.go 83.33% 2 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #734      +/-   ##
==========================================
+ Coverage   61.77%   61.78%   +0.01%     
==========================================
  Files         195      196       +1     
  Lines       18246    18272      +26     
==========================================
+ Hits        11271    11290      +19     
- Misses       5876     5880       +4     
- Partials     1099     1102       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar May 09 '24 16:05 codecov-commenter

@otherview does this persist all requests indefinitely ? Maybe we should have a daily cleanup action that clears log files older than X time? Or once it's using more the Y GB of storage

It rotates files, a max of 10 files of 10mbs each. I'll add this to the comments 👍

otherview avatar May 09 '24 16:05 otherview

@otherview does this persist all requests indefinitely ? Maybe we should have a daily cleanup action that clears log files older than X time? Or once it's using more the Y GB of storage

It rotates files, a max of 10 files of 10mbs each. I'll add this to the comments 👍

Should we make it configurable with defaults? I feel like this would be used very quickly on @kgapos mainnet nodes

darrenvechain avatar May 09 '24 16:05 darrenvechain

@otherview does this persist all requests indefinitely ? Maybe we should have a daily cleanup action that clears log files older than X time? Or once it's using more the Y GB of storage

It rotates files, a max of 10 files of 10mbs each. I'll add this to the comments 👍

Should we make it configurable with defaults? I feel like this would be used very quickly on @kgapos mainnet nodes

Yeap, done 👍

otherview avatar May 09 '24 16:05 otherview

~~@otherview IMO we probably don't need to log requests to the console, as it would make debugging quite difficult in nodes with a lot a traffic~~

Never mind, my mistake, this is just solo I think?

image

darrenvechain avatar May 10 '24 09:05 darrenvechain

I would prefer the feature to be done outside of the protocol client. Such as reverse proxy with log enabled.

libotony avatar May 13 '24 07:05 libotony

Feature scope change, the api request logs are now issued to the log stdou following the same structure as other logs in the app.

otherview avatar May 14 '24 13:05 otherview