-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Return info msg for /health
endpoint
#1465
Return info msg for /health
endpoint
#1465
Conversation
1640594
to
e4e2c29
Compare
pkg/healthcheck/handler.go
Outdated
}, | ||
Ready: { | ||
statusCode: http.StatusOK, | ||
StatusMsg: "up", |
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.
perhaps Server available
pkg/healthcheck/internal_test.go
Outdated
assert.Equal(t, hc.upTimeStats.UpTime, hr.upTimeStats.UpTime) | ||
assert.True(t, hc.upTimeStats.StartedAt.Equal(hr.upTimeStats.StartedAt)) | ||
|
||
time.Sleep(300) |
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.
this will add an extra 5 minutes for each test run which is overkill
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.
Those are Nanosecond
. I wanted to check the case where some time's passed and the service went down, that the uptime does not get incremented.
pkg/healthcheck/handler.go
Outdated
}) | ||
} | ||
|
||
func (hc *HealthCheck) createRespBody(resp healthCheckResponse) []byte { | ||
|
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.
rm newline
pkg/healthcheck/handler.go
Outdated
Unavailable: http.StatusServiceUnavailable, | ||
Ready: http.StatusNoContent, | ||
upTimeStats: upTimeStats{ | ||
StartedAt: time.Now(), |
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.
technically, shouldn't this be set when the sever is first set to ready?
Codecov Report
@@ Coverage Diff @@
## master #1465 +/- ##
==========================================
+ Coverage 99.82% 99.82% +<.01%
==========================================
Files 173 173
Lines 8179 8203 +24
==========================================
+ Hits 8165 8189 +24
Misses 7 7
Partials 7 7
Continue to review full report at Codecov.
|
crossdock/main.go
Outdated
@@ -105,7 +105,7 @@ func (h *clientHandler) isInitialized() bool { | |||
func httpHealthCheck(logger *zap.Logger, service, healthURL string) { | |||
for i := 0; i < 240; i++ { | |||
res, err := http.Get(healthURL) | |||
if err == nil && res.StatusCode == 204 { | |||
if err == nil && res.StatusCode == 200 { |
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.
I'd say that the most appropriate is to check if the response is a 2xx class. That's what monitoring solutions do.
pkg/healthcheck/handler.go
Outdated
@@ -94,5 +136,8 @@ func (hc *HealthCheck) Get() Status { | |||
|
|||
// Ready is a shortcut for Set(Ready) (kept for backwards compatibility) | |||
func (hc *HealthCheck) Ready() { | |||
hc.upTimeStats = upTimeStats{ | |||
StartedAt: time.Now(), |
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.
The process' start time is recorded as a metric:
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.55480578686e+09
Should we add this one as well?
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.
Should I add this as well? This would introduce a new dependency to https://github.com/shirou/gopsutil as well
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.
I meant the other way around, to add the "Started At" as a metric.
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.
Where should I add it?
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.
Looks like the handler isn't receiving a metrics object. Perhaps it's better to open a follow-up issue for now.
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.
Perhaps a follow-up issue of what should be done would be more helpful, as on my local build the /metrics
endpoint does not return any process
information. :)
a00d1bd
to
0ea4d95
Compare
Return 200 OK for status `ready` and `upTimeStats` Resolves jaegertracing#1450 Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
0ea4d95
to
fc3fbe8
Compare
Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
Signed-off-by: stefan vassilev <stefanvassilev1@gmail.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
pkg/healthcheck/handler.go
Outdated
@@ -46,23 +48,43 @@ func (s Status) String() string { | |||
} | |||
} | |||
|
|||
type upTimeStats struct { | |||
StartedAt time.Time `json:"startedAt"` | |||
UpTime string `json:"upTime"` |
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.
uptime is one word, no need to capitalize T (fields and struct name)
pkg/healthcheck/handler.go
Outdated
@@ -94,5 +136,8 @@ func (hc *HealthCheck) Get() Status { | |||
|
|||
// Ready is a shortcut for Set(Ready) (kept for backwards compatibility) | |||
func (hc *HealthCheck) Ready() { | |||
hc.upTimeStats = upTimeStats{ |
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.
race condition
Thanks for the PR! |
Return info msg for `/health` endpoint (jaegertracing#1465)
Short description of the changes
ready
startedAt
andupTime
statisticsResolves #1450