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

NEWRELIC-5279 refactored Error Collector to reduce complexity #1431

Merged
merged 1 commit into from Nov 23, 2022
Merged

NEWRELIC-5279 refactored Error Collector to reduce complexity #1431

merged 1 commit into from Nov 23, 2022

Conversation

jmartin4563
Copy link
Contributor

Proposed Release Notes

  • refactored Error Collector to reduce complexity and fixed/added JSDocs

Links

Closes NEWRELIC-5279

Details

  • Updated error collector to reduce cognitive complexity
  • Fixed existing jsdoc issues and added jsdocs for new methods

@codecov
Copy link

codecov bot commented Nov 21, 2022

Codecov Report

Merging #1431 (8425344) into main (1083c7e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1431   +/-   ##
=======================================
  Coverage   96.23%   96.23%           
=======================================
  Files         194      194           
  Lines       37635    37704   +69     
  Branches       23       23           
=======================================
+ Hits        36217    36286   +69     
  Misses       1418     1418           
Flag Coverage Δ
esm-unit-tests-14.x 47.57% <ø> (ø)
esm-unit-tests-16.x 92.14% <ø> (ø)
esm-unit-tests-18.x 92.14% <ø> (ø)
integration-tests-14.x 77.23% <98.38%> (+0.04%) ⬆️
integration-tests-16.x 77.34% <98.38%> (+0.04%) ⬆️
integration-tests-18.x 77.34% <98.38%> (+0.04%) ⬆️
unit-tests-14.x 89.76% <100.00%> (+0.02%) ⬆️
unit-tests-16.x 89.82% <100.00%> (+0.01%) ⬆️
unit-tests-18.x 89.80% <100.00%> (+0.01%) ⬆️
versioned-tests-14.x 74.66% <90.32%> (+0.04%) ⬆️
versioned-tests-16.x 76.03% <90.32%> (+0.03%) ⬆️
versioned-tests-18.x 76.03% <90.32%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
lib/errors/error-collector.js 97.50% <100.00%> (+0.46%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bizob2828 bizob2828 self-assigned this Nov 21, 2022
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question and a small suggestion

lib/errors/error-collector.js Show resolved Hide resolved
* @param {Array} errorTrace list of error information
* @param {Transaction} transaction the transaction associated with the trace
*/
_maybeRecordErrorMetrics(errorTrace, transaction) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 384 and 385 can be combined right? I thought we had a rule eslint rule to catch that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we do have a rule, but it only kicks in if the logic doesn't change from the combining, in this case, the logic would change in that we would start logging "other" error metrics if the transaction doesn't exist. All that being said, I think it would be safe to combine regardless. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind. this should stay. other has a special meaning within a transaction

@bizob2828
Copy link
Member

really nice refactor overall. that collect method was doing so much before

expectedErrors
)
} else if (isErroredTransaction) {
;[collectedErrors, expectedErrors] = this._processTransactionErrors(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these semicolons doing here? Did eslint put them there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we do not use semi-colons, this is necessary for destructuring of let variables. The AST parser does not know how to handle it without it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I don't think this is necessary. It's only needed when object destructuring

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is an AST parser issue but how ESLint parses code without semi colons

@bizob2828 bizob2828 merged commit bf555a7 into newrelic:main Nov 23, 2022
Node.js Engineering Board automation moved this from Needs PR Review to Done: Issues recently completed Nov 23, 2022
This was referenced Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Node.js Engineering Board
  
Done: Issues recently completed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants