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

use got to push influx metrics #6257

Merged
merged 1 commit into from Mar 12, 2021
Merged

Conversation

chris48s
Copy link
Member

refs #4655

Nice bit of low hanging fruit here 🍏
Because this is stand-alone utility code and not part of the services I haven't routed it through fetchFactory/sendRequest. I've just gone straight from request to got.

@chris48s chris48s added operations Hosting, monitoring, and reliability for the production badge servers core Server, BaseService, GitHub auth labels Mar 11, 2021
@shields-ci
Copy link

Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 2eab29a

Copy link
Member

@calebcartwright calebcartwright 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 for my own edification, but LGTM

auth,
username: this._config.username,
password: this._config.password,
throwHttpErrors: false,
Copy link
Member

Choose a reason for hiding this comment

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

this just prevents got from throwing on some non-successful response status code right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. By default got throws an exception if it gets a 404, 500 or whatever. This tells it to return a response. I mainly did this because the existing error handling code assumes this behaviour from request, but I could have rewritten the error handling code here

} catch (error) {
log.error(
new Error(`Cannot push metrics. Cause: ${error.name}: ${error.message}`)
)
}
if (response && response.statusCode >= 300) {
log.error(
new Error(
`Cannot push metrics. ${response.request.href} responded with status code ${response.statusCode}`
)
)
}
}

to handle both cases in the catch block instead. I don't think it makes much difference either way though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth operations Hosting, monitoring, and reliability for the production badge servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants