-
Notifications
You must be signed in to change notification settings - Fork 94
Custom status response #192
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
Conversation
The new configuration property: statusOkResponse will allow to globally configure the HTTP response body, used to respond with on a successful healthcheck.
When no healthtchecks were defined, the value of statusOkResponse would be returned as is. Therefore, memoizing its string representation would boost performance.
The new configuration property: statusErrorResponse will allow to globally configure the HTTP response body, used to respond with on an unsuccessful healthcheck. An unsuccessful healthcheck may override the global statusErrorResponse property by setting the statusResponse property on the Error object.
|
@gergelyke, @rxmarbles, any chance you can review the PR and, hopefully, merge it in any time soon? Being able to set custom status responses is a real need for me, and am eagerly waiting for the new version of |
|
@gergelyke, @rxmarbles, pinging to make sure there is a possibility for you to review the PR, and, hopefully, merge it in. The proposed functionality is of high demand in my project. |
|
@sindilevich sorry for the delay in this. Looks like this PR has conflicts. Mind taking care of that so this can land? |
…ustom-status-response
…ustom-status-response
|
@rxmarbles, thank you for finding time to look into my PR! |
|
@gergelyke Mind giving this a review when you have a chance. |
gergelyke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this is backward compatible, I am 👌👍👏
|
@gergelyke, @rxmarbles. thank you for investing your time, reviewing and approving the PR! |
|
@rxmarbles, thank you so much for advancing merging the fix! |
* Added statusOkResponse to configuration The new configuration property: statusOkResponse will allow to globally configure the HTTP response body, used to respond with on a successful healthcheck. * Memoize the value of statusOkResponse When no healthtchecks were defined, the value of statusOkResponse would be returned as is. Therefore, memoizing its string representation would boost performance. * Added statusErrorResponse to configuration The new configuration property: statusErrorResponse will allow to globally configure the HTTP response body, used to respond with on an unsuccessful healthcheck. An unsuccessful healthcheck may override the global statusErrorResponse property by setting the statusResponse property on the Error object. * Incorporated use of headers
Closes #189.
As noted in the PR, the hardcoded values for the top-level
statusproperty aren't playing well with other monitoring systems, such as Netfilx's Eureka Discovery server. Other monitoring systems may even expect a whole different JSON as status of an application.Since Kubernetes assures liveness of a container by an HTTP response with an HTTP code
>= 200and< 400, the hardcodedokmakes no difference to the health check process. Therefore, a response body of:{ status: 'up' }, with HTTP code200, would easily serve as a liveness indicator for both Kubernetes and the Netfilx's Eureka Discovery server.The proposed resolution in this PR, is to add two new configuration properties:
statusOkResponseandstatusErrorResponse. Those properties will allow to globally configure the HTTP response body, used to respond with on a successful or an unsuccessful healthcheck respectively.An unsuccessful healthcheck may override the global
statusErrorResponseproperty by setting thestatusResponseproperty on theErrorobject.As an example, the following configuration excerpt (for Express) can help monitoring application liveness for both Kubernetes and the Netfilx's Eureka Discovery server: