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

Tidy excessive logs #1165

Merged
merged 7 commits into from
Aug 24, 2024
Merged

Tidy excessive logs #1165

merged 7 commits into from
Aug 24, 2024

Conversation

JGreenlee
Copy link
Collaborator

@JGreenlee JGreenlee commented Aug 16, 2024

Logs have gotten very cluttered, which is causing issues with the size of the LoggerDB, and is likely inhibiting performance

I am removing logs that happen repeatedly; e.g.

  • logs on every single function call on a function that is called dozens / hundreds of times
  • logs on every UI/component re-render
  • redundant logs that convey information that is already being logged by another statement

I am being careful not to remove logs that would be useful for debugging, since logs are critical to ensuring we can resolve bugs affecting end users.

This is a performance optimization I found while investigating why so many log statements were printed when there were no unprocessed inputs.
when userInputList is `[]`, we should return early.
While investigating excessive log statements, I found several repetitive logs for config retrieval.
There were several retrievals occuring in parallel because the retrieval is not synchronous but was being requested by multiple parts of the codebase in succession.
A better pattern is to cache the promise rather than only caching the result once the promise completes

I also updated the return type of getConfig to properly reflect that the promise could resolve as `null`.
Throughout the codebase we already account for the possibility of it being null almost everywhere except tests. enketoHelper is the one place I saw that config being null could have been an issue.
For tests, we just tell TypeScript to assert non-null with `!`
This is one area we have been lacking in logs. Adds a standardized way to log on each commHelper function, including: the function called, the arguments passed, the message posted to the server (if applicable), and the result of the call

For functions with lightweight response data, the full JSON is logged; for heavy response data, the log just counts # of entries

I commented out unused commHelper functions
@shankari
Copy link
Contributor

@JGreenlee should I go ahead and merge this along with this weekend's changes?

@JGreenlee JGreenlee marked this pull request as ready for review August 24, 2024 03:41
@JGreenlee
Copy link
Collaborator Author

Yes. There might be more log statements to clean up later, but this is what I had time for this week

Copy link

codecov bot commented Aug 24, 2024

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Project coverage is 30.01%. Comparing base (e6aea4e) to head (f256364).
Report is 16 commits behind head on master.

Files Patch % Lines
www/js/config/dynamicConfig.ts 81.81% 2 Missing ⚠️
www/js/diary/LabelTab.tsx 0.00% 1 Missing ⚠️
www/js/diary/addressNamesHelper.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1165      +/-   ##
==========================================
- Coverage   30.10%   30.01%   -0.10%     
==========================================
  Files         118      118              
  Lines        5201     5184      -17     
  Branches     1162     1162              
==========================================
- Hits         1566     1556      -10     
+ Misses       3631     3624       -7     
  Partials        4        4              
Flag Coverage Δ
unit 30.01% <78.94%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
www/js/components/Chart.tsx 0.00% <ø> (ø)
www/js/diary/timelineHelper.ts 91.96% <100.00%> (-0.41%) ⬇️
www/js/metrics/MetricsTab.tsx 0.00% <ø> (ø)
www/js/metrics/customMetricsHelper.ts 95.83% <100.00%> (-0.09%) ⬇️
www/js/survey/enketo/enketoHelper.ts 68.03% <100.00%> (-0.26%) ⬇️
www/js/survey/inputMatcher.ts 63.18% <100.00%> (ø)
www/js/survey/multilabel/confirmHelper.ts 97.11% <ø> (+0.88%) ⬆️
www/js/diary/LabelTab.tsx 0.00% <0.00%> (ø)
www/js/diary/addressNamesHelper.ts 0.00% <0.00%> (ø)
www/js/config/dynamicConfig.ts 85.31% <81.81%> (+0.59%) ⬆️

@shankari shankari merged commit 9852fd9 into e-mission:master Aug 24, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants