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

Fix error handling for metrics #1

Merged
merged 9 commits into from
Mar 15, 2018
Merged

Fix error handling for metrics #1

merged 9 commits into from
Mar 15, 2018

Conversation

fortuna
Copy link
Collaborator

@fortuna fortuna commented Mar 15, 2018

cc @trevj @sandrigo FYI

@fortuna fortuna self-assigned this Mar 15, 2018
@fortuna fortuna requested a review from dborkan March 15, 2018 17:03
Copy link
Contributor

@dborkan dborkan left a comment

Choose a reason for hiding this comment

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

Great stuff! Just 2 small comments, then we should be good

Copy link
Contributor

@trevj trevj left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. Man, that error handling.

});
});
});
export class CachedIpLocationService implements IpLocationService {
Copy link
Contributor

Choose a reason for hiding this comment

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

Servers could stay up for weeks - let's file an issue to make this cache:

  • bounded in size
  • an expiring cache

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the comment. We should make it LRU.

fulfill('ZZ');
}
} catch (e) {
reject(new Error(`Error loading country from reponse: ${e}`));
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like there's a chance this could log the IP address - I'd feel better if we weren't logging the error verbatim.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the cause error

countryPromises.push(lookupCountry(ip));
const countryPromise = ipLocationService.countryForIp(ip).catch((e) => {
console.warn('Failed countryForIp call: ', e);
return 'ERROR';
Copy link
Contributor

Choose a reason for hiding this comment

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

It's hard to figure out what the outcome of this is - are you filtering the unsuccessful lookups?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We save the country as ERROR on unsuccessful lookups

Copy link
Contributor

Choose a reason for hiding this comment

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

OK...and that makes it right through to BigQuery?

I think you should remove the console.warn. Seems like logging on first failure is sufficient.

Copy link
Collaborator Author

@fortuna fortuna Mar 15, 2018

Choose a reason for hiding this comment

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

This is the only place we log. The IpLocationService doesn't log anything.

I consider a good approach to log errors only where you handle them (like here). This about the duplicate logging.

if (!queryParam) {
return null;
}
if (typeof(queryParam) === 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, testing for strings is a minefield in JavaScript. Array.isArray might be safer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to Array.isArray

@trevj
Copy link
Contributor

trevj commented Mar 15, 2018

@fortuna One more request - and please consider a squash commit when merging.

Copy link
Contributor

@dborkan dborkan left a comment

Choose a reason for hiding this comment

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

👍

@fortuna fortuna merged commit 3c40d55 into master Mar 15, 2018
daniellacosse added a commit that referenced this pull request Oct 9, 2023
daniellacosse added a commit that referenced this pull request Oct 16, 2023
* chore: upgrade to lts/hydrogen

* update github workflows

* fix attempt #1

* ssl, restify upgrade

* more openssl options

* ah thanks sander, using middleware2

* fix ci

* reset package-lock.json

* revert middleware2

* fix optional chaining

* okay cool tests run, but fail

* partially update the node image (i can't find the other one)

* Update test.action.sh

* Update build.action.sh

* Update test.action.sh

* Update build.action.sh

* Update package.json

* Update webpack.config.js

* Update webpack.config.js

* Update build.action.sh

* Update build.action.sh

* Update package.json

* Update README.md
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.

3 participants